Skip to content

Function to draw angle between two lines #12414

Closed

Description

@daniel-s-ingram

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.

Activity

  1. ImportanceOfBeingErnest commented on Oct 5, 2018

    @ImportanceOfBeingErnest
    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.

  2. WeatherGod commented on Oct 5, 2018

    @WeatherGod
    Member
  3. daniel-s-ingram commented on Oct 5, 2018

    @daniel-s-ingram
    ContributorAuthor

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

  4. ImportanceOfBeingErnest commented on Oct 5, 2018

    @ImportanceOfBeingErnest
    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?

  5. daniel-s-ingram commented on Oct 6, 2018

    @daniel-s-ingram
    ContributorAuthor

    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?

  6. ImportanceOfBeingErnest commented on Oct 6, 2018

    @ImportanceOfBeingErnest
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions