-
Notifications
You must be signed in to change notification settings - Fork 162
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
slerp
for vectors (feature request)
#377
Comments
You can create a Quat rotation between two vectors with https://docs.rs/glam/latest/glam/f32/struct.Quat.html#method.from_rotation_arc. For slerp you need a start and end orientation to slerp between though, you can probably get that via: let q0 = Quat::from_rotation_arc(FORWARD_DIR, from);
let q1 = Quat::from_rotation_arc(FORWARD_DIR, to);
let qa = q0.slerp(q1, alpha); Where Whether that achieves what you want I am not sure. I would need to see some wider code context of how you are using this to determine if it makes sense to add a helper. The Bevy 2D rotation example might help, it's in 2D but they're using quaternions for all rotations so the same thing should work in 3D - https://github.com/bevyengine/bevy/blob/main/examples/2d/rotation.rs. |
I was iterating on a dual contouring implementation, and I was interpolating normals between two points, so it really was just taking two unit I could kind of guess how to implement this in terms of quaternions, although it wasn't an instantly obvious solution as I'm not really familiar with quaternions. I did something along these lines: Quat::IDENTITY.slerp(Quat::from_rotation_vec(from, to), alpha).mul_vec3(from) I don't have the exact code I used because it turned out that normal interpolation was not the cause of my issues, and I quickly scrapped the code. I just thought that a proper Of course, it's up to you whether it's worth it to include this functionality. As a precedent, Unity provides a |
I have slerp implementations for Vector2 and Vector3 based on Godots implementations, but I'm not sure how to convert the to tera. https://gist.github.com/gkhk0/210fbe80657b6d494215f5251dfd9ac4 |
I've contributed to glam before, so I can make the PR :) |
I'm in a situation where I would like to
slerp
twoVec3
s, something like the following pseudocode:I think this can be implemented in terms of quaternions, but it is not directly obvious to me and I'm not sure if it is the most performant way either.
Does this fit in the scope of the library?
The text was updated successfully, but these errors were encountered: