Skip to content
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

angle_signed for 3D Vectors #314

Closed
CristianoPizzamiglio opened this issue Sep 18, 2022 · 2 comments · Fixed by #315
Closed

angle_signed for 3D Vectors #314

CristianoPizzamiglio opened this issue Sep 18, 2022 · 2 comments · Fixed by #315

Comments

@CristianoPizzamiglio
Copy link
Collaborator

Hi @ajhynes7!

The angle_between method allows to compute the unsigned angle between two either 2D or 3D vectors, while the angle_signed computes the signed angle but supports 2D vectors only.

I had a use case where I needed to compute the signed angle between two 3D vectors. Would you be interested in changing the angle_signed method to support 3D vectors as well? If you wouldn't, don't worry, I understand.

I was thinking about the following solution that does not break the current interface. Only the angle_signed method would be modified.

I would add the keyword argument positive_direction or plane_normal which is a Vector that is necessary to actually determine if the angle between two 3D vectors is positive or not. Its default value is None. This vector is just the normal of the plane where the two 3D vectors lie. We need to validate this input to actually check if it's a Vector and normal.

If the user provides two 2D vectors, the method works as it is now and the positive_direction argument is ignored regardless of its value.

If the user provides two 3D vectors and the positive_direction is not None, then the cross product of the two input vectors is computed and eventually the cosine similarity is computed between the cross product and the positive_direction vector which will be used to determine the sign of the angle.
If positive_direction is None a positive angle will be always returned.

Thanks!

@ajhynes7
Copy link
Owner

Hi @CristianoPizzamiglio , do you want to try creating a PR for this?

@CristianoPizzamiglio
Copy link
Collaborator Author

Yes, I do, it's a pleasure!

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

Successfully merging a pull request may close this issue.

2 participants