Archived

This topic is now archived and is closed to further replies.

blending vectors.

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

Recommended Posts

suppose i have a 3d model of an elephant. it has a forward, right, and an up vector. is there a way, im sure there is, to blend his forward vector to a copy of his right vector so that the elephant will smoothly rotate 90 degrees to the right? i say "copy of his right vector" because using his actual right might make his rotate forever. if such a method exists, it is common?

Share on other sites
Most 3D APIs have some method of rotating a model relative to an arbitrary origin, why don''t you use that instead?

Share on other sites
Vectors won''t blend cleanly for rotations, but quaternions will. What you''re talking about is called SLERP, or spherical linear interpolation. Read up on quaternions; they''re what you want.

How appropriate. You fight like a cow.

Share on other sites
GekkoCube, what Sneftel says is true, although you can interpolate vectors: if their problems are not a problem for you, then go for it.

outvec = (1-t)startvector + (t)endvector

Will give you an interpolation from startvector to endvector (where t is the parametric percentage from startvector to endvector) If this is a direction vector and must be normal, normalize outvec afterwards.

Note however:
*if startvector and endvector are facing exact opposite directions that at some point in your interpolation you will get an outvec of exactly (0,0,0) which isn''t useful. In fact, if you''re building an orthonormal matrix from the output of this vector you may be cross-producting with (0,0,0) which we all know achieves another (0,0,0) vector.
* Also, the vectors startvector and endvector have to be of virtually the same magnitude otherwise one will influence the rotation alot more than another.
* Vector interpolation won''t interpolate the angle linearly: it will start off rotating slow, then speed up and slow down again (kind of like a bell curve) depending on the angles between your startvector and endvector.

If you''re prepared to accept and deal with these problems, then go for it and use vector interpolation. I''ve used this exact method for homing missiles: calculating it''s next direction every frame so it does have it''s uses.

Quaternions solve most of the above problems, except that slerping always takes the shortest path interpolation between 2 orientations. An example of where this may be a problem is: if you have 2 cameras and are blending them, but one camera is watching a moving object - you will get jumps when the angle between the 2 orientations is approximately 180 degrees simply because SLERPING takes the shortest path around the sphere

Just be advised, in certain cases, both methods have their problems, you just have to work around them.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• Forum Statistics

• Total Topics
633678
• Total Posts
3013292
×