My good friend Weetbix gave me some stellar advice tonight on quaternions. I can feel the heat coming from my ears now. I'll let steam do the talking:
Black_Stormy: so I'm trying to code a new camera mode into UDK
Black_Stormy: and I'm using vectors and rotators
Black_Stormy: and doing math between them with variables that I have no idea what they are doing
Black_Stormy: in over my head or what
Black_Stormy: quote from a forum: Conceptually, I'm trying to rotate a stacticMesh actor so that it's orientation matches to a vector tangent to a spherical surface.
Black_Stormy: I know what thet means!
Weetbix: it means it will be sitting on the sphere like a man stands on earth
Black_Stormy: yup
Weetbix: sounds like you are becoming a programmer ;)
Weetbix: doing a lot of programming lately ;) ;)
Black_Stormy: then the next post was like "you have to take the tangent of the vector normal and pass it to the vector rotation function which recreates a rotator from three given tangetnaaefq-ew0ihq 0OUBWEGU9QBWEGIOUBwwegb" and then I took an arrow in the knee
Weetbix: lol
Black_Stormy: couldn't shed a bit of light though could you?
Weetbix: sure about what
Black_Stormy: a vector is a point in 3d space, right?
Weetbix: no
Weetbix: a point is a point
Weetbix: a vector is a directin
Black_Stormy: oh yeah
Weetbix: and a length
Black_Stormy: ok
Black_Stormy: so a point doesn't relate to a vector
Black_Stormy: unless it is moving
Weetbix: its represented by 3 numbers like a point though
Black_Stormy: yeah
Black_Stormy: what is generally considered the normal of a vector, the Z axis?
Black_Stormy: or just the direction that the numbers say it is pointing
Black_Stormy: duh nvm
Weetbix: theres no such thing as the normal of a vector
Black_Stormy: oh
Weetbix: a normal vector is one that has a length of 1
Black_Stormy: but isn't the direction of the vector kindof like a normal?
Black_Stormy: or does a normal have a vector?
Weetbix: a normal of a surface is a vector
Black_Stormy: *click*
Black_Stormy: ok what about rotators
Weetbix: rotators sounds like something UDK made up
Black_Stormy: ghry
Weetbix: to avoid quaternions maybe or rotation matrices
Weetbix: so im not sure
Black_Stormy: how do you usually define a rotation in 3d space? 2 vectors and the angle between them in a third vector?
Black_Stormy: like starting vector, ending vector and direction of rotation vector
Weetbix: no if you had the two vecotrs you woudlnt need the third one because you could work it out from the first two
Black_Stormy: true
Weetbix: but usually its done using something called a quaternion
Weetbix: which is SORT OF like a vector which represents the axis of rotation, and an amount to rotate
Weetbix: its 4 numbers
Black_Stormy: hm
Black_Stormy: TO WIKIPEDIA
Black_Stormy: seems like it should have more numbers to me
Weetbix: wiki is terrible for maths haha
Weetbix: nah brew
Black_Stormy: like wouldn't it need a start vector, an end vector, amount of degrees to rotate between the two?
Black_Stormy: that's 7 numbers
Weetbix: no
Weetbix: you are pretty close
Weetbix: but
Weetbix: you dont need that second vector
Weetbix: because a quaternion is just a single rotation right,
Black_Stormy: plus a point for the location and speed and time but I guess you'd work that out externally
Weetbix: you can set that quaternion to be the rotation between two vectors
Weetbix: but that will still be an axis and a rotational amount
Black_Stormy: ok so the two vectors are an external variable
Weetbix: yes
Black_Stormy: what do each of the four numbers mean? one of them must be degrees or radians to rotate
Black_Stormy: like in vectors it's x,y,z
Weetbix: the first 3 are the axis of rotation and the fourth is the rotation
Black_Stormy: so it's essentially a vector of rotation
Black_Stormy: like x,y,z,r
Weetbix: not sure what you mean by vector of rotation
Black_Stormy: it's a direction of rotation
Black_Stormy: in local 3d space
Black_Stormy: it's saying "point this way and rotate this many degrees"
Weetbix: yeh well the vector specifics the axis to rotate about and the number is how many degrees to rtoate
Weetbix: not really point this way and rotate
Weetbix: more like rotate around this axis, this much
Weetbix: also i think its a bit more black magic than that
Black_Stormy: so it's kind of like converting a Z axis in local space, from global space
Black_Stormy: dammit, it's a vector of rotation
Black_Stormy: BAM I am ready to camera
Weetbix: its a mesh of texture
Black_Stormy: I see what you did ther
Weetbix: haha
Black_Stormy: so the direction of the vector given in the quaternion is the axis of rotation
Weetbix: i think thats basically it but it also might be a bit trickier than that. But you dont really need to know what the numbers exactly represent because usually you just do something like htis
Black_Stormy: so if I was to say a quaternion of 0,0,1,45, that would be rotating 45degrees around the global Z axis
Weetbix: Quaternion q = Quaternion.AroundAxis( 0,1,0, 45 );
Black_Stormy: and then you'd go "on press a rotate(q)"
Weetbix: you cant really plug the numbers in yourself
Weetbix: yeh
Weetbix: well it would be more like
Weetbix: nwm
Black_Stormy: yeah I don;t actually know any languages
Black_Stormy: so nvm
Black_Stormy: haha
Weetbix: haha
Black_Stormy: I CAN CAMERA HERE I COME NP++
Incientally, a rotator is defined with pitch yaw roll. Makes sense really.
No comments:
Post a Comment