Skip to content

Adding orientation to Mobject #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
XorUnison opened this issue Jul 8, 2020 · 2 comments
Closed

Adding orientation to Mobject #187

XorUnison opened this issue Jul 8, 2020 · 2 comments
Labels
enhancement Additions and improvements in general help wanted We would appreciate help on this issue/PR

Comments

@XorUnison
Copy link
Collaborator

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 result

My 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?

@XorUnison XorUnison added enhancement Additions and improvements in general help wanted We would appreciate help on this issue/PR labels Jul 8, 2020
@XorUnison
Copy link
Collaborator Author

I've had a look at this again and utils/space_ops.py seems to be the place. Any other thoughts?

@behackl
Copy link
Member

behackl commented Nov 15, 2020

This has been implemented via #647, closing.

@behackl behackl closed this as completed Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additions and improvements in general help wanted We would appreciate help on this issue/PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants