Skip to content

Function to draw angle between two lines #12414

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
daniel-s-ingram opened this issue Oct 5, 2018 · 6 comments
Closed

Function to draw angle between two lines #12414

daniel-s-ingram opened this issue Oct 5, 2018 · 6 comments

Comments

@daniel-s-ingram
Copy link
Contributor

Would anyone be interested in having a function to draw an angle? I made a function for this that you can see here:

https://github.com/AtsushiSakai/PythonRobotics/blob/master/ArmNavigation/two_joint_arm_to_point_control/Planar_Two_Link_IK.ipynb

If this is something enough people are interested in, I can clean the code up and submit a PR for it.

@ImportanceOfBeingErnest
Copy link
Member

Thanks for reaching out. I think this is probably a bit too specialized to get its own function in the library; on the other hand, I suppose a lot of people might make use of something like that. So to strike a balance, one could opt for providing this as an example in the gallery.
Let's see what others think.

From the code perspective I'm wondering if using a matplotlib.patches.Arc wouldn't be better suited? I also think one would usually desire this arc to be at a fixed distance/radius to the intersecting point, independent on the axis limits or zoom level, and also have it appear circular even with unequal aspect. An example showing this would definitely be useful.
I haven't thought this through, so I don't know if there is a good solution possible only with transforms or whether one would need to write a callback for this.

@WeatherGod
Copy link
Member

WeatherGod commented Oct 5, 2018 via email

@daniel-s-ingram
Copy link
Contributor Author

@ImportanceOfBeingErnest

I agree about having the arc appear circular for any aspect ratio; that's something I can look into. I disagree about the fixed radius, however, as I found it useful to be able to increase or decrease the radius for my diagrams, so why not have that as an optional argument?

@ImportanceOfBeingErnest
Copy link
Member

Of course the radius should be a parameter to be set programmatically. By "fixed" I mean if you zoom in and out, the radius on screen should be the same. I.e the radius is fixed in screen coordinates, not fixed in data coordinates.

Detailed description

Original View

image

Zoom

The angle is scaled together with the data.
image

Expected when zooming

The angle marker should still be the same amount of pixels distant to the intersecting point.

image


The join-style idea is interesting, except I don't see how one can equip this with different linestyle, color etc. In addition the usual use case does not necessarily contain a single line, but probably several, or some polygon shapes. So the limit might be to create a single object of same color, linestyle etc.

image

Here everything that's black would be the line with the "funny" joint-style. Is that the idea?

@daniel-s-ingram
Copy link
Contributor Author

Ah, my mistake, I misunderstood. I'll see if I can put together something more robust over the next few weeks. I think you're right that this may work better as a submission to the example gallery, so should I update here or is there a better place for this exchange?

@ImportanceOfBeingErnest
Copy link
Member

Yes, we can discuss here. Or, once you have something ready, you can submit a pull request with the example (examples are in matplotlib/examples/, though I don't currently know which category this would best fit into).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants