-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
As some of you know I've been working with arcs. A lot. At some point I'd want to add ArcPolygons to this manim fork, but first I want to work on the Arc derived class I usually work with, ArcBetweenPoints.
As per the tags there are 3 things to do here.
The bug:
ArcBetweenPoints, unlike all other classes I know that use points (Line, etc.), does not support points in the form [x,y,z], instead they have to be passed as np.array([x,y,z]). First running into this problem myself wasted a lot of time because I wasn't accustomed to the error messages, and this will likely cause grief to the one or the other person as well. The issue is this line of code:
self.put_start_and_end_on(start, end)Or rather where it leads towards, in mobject.py, where arithmetic with points happens (Point1-Point2), and Python's List does not support that, while np.array does.
In that place, line 553 is where I'd place the fix:
target_vect = end - start↓
target_vect = np.array(end) - np.array(start)If np.array gets a numpy array it's not going to change anything so all this does is make the code more robust and ArcBetweenPoints easier to use, like it's the case with other point driven classes already.
The enhancement:
Defining ArcBetweenPoints with a given angle is all nice and stuff, but sometimes (or in my case basically always) you'll want to define such an arc by its radius. The ArcBetweenPoints class should be able to take in a radius instead of an angle, and calculate the according angle itself. I've got the code for that already usable, waiting for a better implementation than an outside function.
My issue here though is that this code needs math and cmath to work.
Question 1:
What is the correct way of making sure those are available in geometry.py? Sure they can just be imported at the top of the file but is that actually the right way to go around it?
The documentation:
I'd prefer it if all classes are equipped with some sort of in place usage examples. Something along the lines of:
class ArcBetweenPoints(Arc):
"""
ArcBetweenPoints needs at least 2 points to draw the arc between.
The curvature of the arc can be specified via angle or radius.
When both are given, radius is used and angle is ignored.
ArcBetweenPoints([x,y,z],[x2,y2,z2],angle=1) results in this...
ArcBetweenPoints([x,y,z],[x2,y2,z2],radius=1) results in that...
"""Question 2:
What is the exact format for such comments we should go with?