# Interpolating between two vectors

This topic is 3411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I was thinking about the problem of interpolating between two orientations which are described as normalized direction vectors (x,y,z). Assuming a Left-Handed coordinate system. Lets say you want to stick with the vectors in this form and do not want to use Euler angles or quats. Thinking along these lines... Two vectors Dir and GoalDir. You can find an axis of rotation by taking a cross product between them. AxisOfRotation = Dir X GoalDir; I know the math to rotate Dir by Theta around this Axis of Rotation. But, which direction do I rotate in? I can find the amount to rotate with the dot product, but its not going to give me the sign of the rotation. I know the cross product should tell me if the rotation is a clockwise or counterclockwise rotation, and If I look at the problem visually (geometrically) I understand how to see it, but im not sure how when looking at the cross product result numerically how to get that info when rotating about an arbitrary axis. Also is this a valid way to do the interpolation between these vectors? What kind of disadvantages does it have when compared to converting the vectors to quats and doing a spherical linear interpolation?

##### Share on other sites
Quote:
 Original post by ilianI was thinking about the problem of interpolating between two orientations which are described as normalized direction vectors (x,y,z). Assuming a Left-Handed coordinate system.Lets say you want to stick with the vectors in this form and do not want to use Euler angles or quats.Thinking along these lines...Two vectors Dir and GoalDir.You can find an axis of rotation by taking a cross product between them.AxisOfRotation = Dir X GoalDir;I know the math to rotate Dir by Theta around this Axis of Rotation.But, which direction do I rotate in? I can find the amount to rotate with the dot product, but its not going to give me the sign of the rotation.I know the cross product should tell me if the rotation is a clockwise or counterclockwise rotation, and If I look at the problem visually (geometrically) I understand how to see it, but im not sure how when looking at the cross product result numerically how to get that info when rotating about an arbitrary axis.Also is this a valid way to do the interpolation between these vectors? What kind of disadvantages does it have when compared to converting the vectors to quats and doing a spherical linear interpolation?
First of all, you can't fully describe an orientation in 3-d using a single direction vector, so we're not really interpolating between two orientations here.

As for the problem of interpolating from one unit-length vector to another, the axis-angle method you mention should work fine (the direction of rotation is 'encoded' in the direction of the cross product, so it's not a problem that the computed angle will always be positive).

Other options for interpolating between two unit-length vectors are SLERP and NLERP.

If I may ask, what are you actually trying to do here?

##### Share on other sites
Quote:
 Original post by jykFirst of all, you can't fully describe an orientation in 3-d using a single direction vector, so we're not really interpolating between two orientations here.

Yes of course, a bad word choice there, thanks for pointing it out! I apologize for the confusion.

Quote:
 (the direction of rotation is 'encoded' in the direction of the cross product, so it's not a problem that the computed angle will always be positive).

Great! This is exactly what I was missing here, for some reason I wasnt putting this part together. Thank you for the clarification.

Quote:
 Other options for interpolating between two unit-length vectors are SLERP and NLERP.

Good suggestions! I was just curious about a solution that did not involve quaternions.

Quote:
 If I may ask, what are you actually trying to do here?

Just been brushing up on my game math and going over various scenarios and this is one that showed there was a gap in my understanding somewhere.

##### Share on other sites
Quote:
Quote:
 Other options for interpolating between two unit-length vectors are SLERP and NLERP.
Good suggestions! I was just curious about a solution that did not involve quaternions.
To clarify, I wasn't actually referring to quaternion SLERP/NLERP, but rather SLERP or NLERP as applied to 3-d vectors.

The SLERP and NLERP algorithms can be applied to vectors of any dimension. What we think of as quaternion SLERP and NLERP are actually just the 4-d versions of these algorithms (more or less - sometimes an extra step is added to work around the fact that q and -q represent the same orientation).

What I was actually suggestion was using the 3-d versions of vector SLERP or NLERP directly to interpolate between the two vectors.

##### Share on other sites

This topic is 3411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628676
• Total Posts
2984175

• 13
• 12
• 9
• 10
• 10
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}