-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
As some of you know I intent to add 3 general purpose geometry classes to geometry.py (ArcPolygon/Graph/Tiling), most relevant for this issue ArcPolygon. While I've used ArcPolygon in my own work most notably for ExclusionZone, that is an extremely narrow and specific class that doesn't really have any business in vanilla manim. One of the things I added to ArcPolygon is the ability to get and force orientation, which I need for ExclusionZone. However orientation checking/manipulation is a very general purpose ability that I think should go into the base Mobject as there's many other uses for it too, such as controlling animation direction and making any work on Mobjects that relies on known orientation possible in the first place.
My implementation relies on this shoelace method I've doctored together myself from online examples and my specific usecase, and orientation needs some shoelace:
def shoelace(x_y, absoluteValue=False, orientation=True):
x = x_y[:, 0]
y = x_y[:, 1]
result = 0.5 * np.array(np.dot(x, np.roll(y, 1)) - np.dot(y, np.roll(x, 1)))
if absoluteValue:
return abs(result)
else:
if orientation:
if result > 0:
return "CW"
else:
return "CCW"
else:
return resultMy question and help request:
Is anyone aware of a proper shoelace implementation in any of the libraries we're already using, such as numpy/etc? Ideally I would like to avoid adding new methods like this if not necessary.
And alternatively if no such implementation exists/becomes known to us, where would this method go in manim?