Skip to main content
gamedev.net
🔒 Locked

slerping

Started by Shakiwa May 20, 2003 at 5:03 PM 3 replies 400+ views
Original Post
Shakiwa
Shakiwa
ok, this is 1 of 2 things: me being stupid, or me not understanding a concept properly. NOW...atm I''m getting into dx, and 1 of my classes takes a mesh, and uses various methods to setup a few little aspects for it anyway, I''ve been writing a method to do smooth rotation and I thought, ooooh so quaternions are actually useful? that looks interesting. so, i coded the straight rotation part using quaternions for rotating and set about working out slerping :S now like I said above, I''m either stupid (going to have a very good look at my code after posting this), or have no clue about how slerping works. I guessed that if I put in the 1st quaternion and the 2nd one and a float <1.0 then it would calculate the rotation to a part, instead, much crazy distortion of image to infinity. i''m using timeGetTime() to get an initial time, then dividing the time at any instant - initial time, by the total time to be taken - initial time, and using that as my step in the slerp func. Then, turn that into a world matrix using the d3dx affine transformation func (including position as the transform part) and setting it as the world matrix b4 rendering the mesh. NOW, WHY THE HELL DOES IT RENDER WRONG??!!?? Is it something really dumb? help? I''m just scared that I''m missing the idea of the slerp func altogether, and getting it totally wrong, cos the rotation funcs work fine :S will post code when I copy it off the other computer, now I''m off for a smoke bleh, get me a hamster :o
bleh, get me a hamster :o
Namethatnobodyelsetook
Namethatnobodyelsetook
Yes, that is how Slerp works. It creates a quaternion that is ''ratio'' percentage between the two quaternions. The ratio is specified between 0 and 1 as you said.

Something else must be wrong with your code.
Osc
Osc
> instead, much crazy distortion of image to infinity

This suggests that the quat you turn into a matrix is not normalized (a unit quat represents a rotation, any other length is not valid in this context) so you''re seeing shearing.

AFAIK, the D3DX library slerp will spit out a unit quat given two unit quats and a factor between 0 and 1. This suggests that one or both of your input quats is not unit length.
Shakiwa
Shakiwa
thing is im using D3DXQuaternionRotateYawPitchRoll to get the rotation quats, it''s not too difficult to do manually, just neatens things up, and would probably be a bit better optimised than my efforts usually are ill stick some code up in a minute
bleh, get me a hamster :o
Shakiwa
Shakiwa
thanks Osc and name, it just blew over my head. Did quaternions in maths a while ago and wasnt listening then instead of testing it by initialising the quat to 0,0,0 (duh) initialised it using yaw pitch and roll of 0 yay
bleh, get me a hamster :o

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.