-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add function to find Direction3d perpendicular to two other Direction3ds #125
Comments
The simplest name and signature would probably be Direction3d.cross :
Direction3d coordinates
-> Direction3d coordinates
-> Maybe (Direction3d coordinates) but that doesn't help if you don't remember what cross products do! One option would be to call it
Thoughts? |
Side note: (Direction3d.toVector dir0) |> Vector3d.cross (Direction3d.toVector dir1) instead of Vector3d.cross (Direction3d.toVector dir0) (Direction3d.toVector dir1) to get a right-handed cross product |
I think either I think it's best for it to return Also thanks for the note about Edit: I'm having second thoughts about my preference to return Maybe, |
Maybe it makes sense to have both the pure mathematical version and the convenient version: Direction3d.cross :
Direction3d coordinates
-> Direction3d coordinates
-> Maybe (Direction3d coordinates)
Direction3d.perpendicularToBoth :
Direction3d coordinates
-> Direction3d coordinates
-> Direction3d coordinates |
The one other thing to think about is whether it also makes sense to have a version for vectors, e.g. Direction3d.perpendicularToTwoVectors :
Vector3d coordinates
-> Vector3d coordinates
-> Direction3d coordinates |
I think it’s best to just have the Direction3d.perpendicularToTwo for now. I’ve only had need for this once. While it is nice to have, I think having 3 versions of it might be too much (also I’ve changed my mind and think it should return Direction3d rather than Maybe) |
Yeah, I'm not sure I'd add a vector version right away, but it would be nice to have a function name that could be naturally extended to a vector version in the future. For example |
Actually yeah, maybe it's not worth worrying about a vector version - there's always |
I wasn't able to find a function with the following signature
Direction3d c -> Direction3d c -> Maybe (Direction3d c)
that finds a direction that's perpendicular to two other directions (aka the axis of rotation of those two directions).This could be implemented as:
This function is pretty simple but I think it's worth including because anyone who forgot what cross products do, will have trouble figuring out how to implement this (me included until @w0rm reminded me). Unfortunately, I'm not sure what's a good name for this function.
The text was updated successfully, but these errors were encountered: