PDA

Click to See Complete Forum and Search --> : 3D Rotation trouble


sql_lall
Dec 29th, 2003, 03:02 AM
Hey, i thought this was best suited to maths... cos 3D graphics is always maths...
anyway

I have a camera in a 3D world. I don't use quaternions to represent it (i know, bad...) but instead have its position (one point in space) and its rotation (another point, {x,y,z} representing the x-, y-, and z- rotation.

Now, moving in direction facing, and strafing is easy, as it involves movement of the position point. However, how would it be possible to rotate the camera say {l,m,n} degrees WITH RESPECT to the current viewing angle of {a,b,c} degrees? This is for doing things such as turning left, looking up, and then doing both at the same time.

Unfortunately you can't just put new rotation to be {a+l,b+m,c+n}, not to use a simple matrix multiplication, as the point is really a rotation, not a point as such.

Just wondering, is it possible say to make a mock unit vector pointing in the default direction (up = +ve y axis, forwards = +ve z axis) then rotate that and use its new position to help find the rotation needed??

kedaman
Dec 29th, 2003, 03:34 AM
its similar to the case where you rotate about an arbitrary point, then you would have T1 R T2 where you translate to origo, then rotate and translate back to the point. If the object coordinate system is rotated as well, then you just add it up the pile T1 R1 R R2 T2 where R2 is the rotation in respect to world coordinates and R1 is the negative rotation.

kedaman
Dec 29th, 2003, 03:41 AM
and if you want to move on to quaternions, heres a tutorial:
http://www.gamedev.net/reference/programming/features/qpowers/default.asp

sql_lall
Dec 30th, 2003, 02:46 AM
yeah, i have some stuff about Quat. anyway (useful, cos its in book form), just that i was using a certain way to handle meshes, and implemented the same sort of idea with a camera.

Anyway...

Is it really possible to just transform a set of 3 rotations like that, and get what you need??

for instance, say you wanted to turn left and look up, the rotation wanted would be approx {-45,45,0}. However, if the camera's rotation is at {12,-56,120}, then u can use this to transform the {-45,45,0} point, then add the X/Y/Z values? Ok. Just that it seemed wrong, as i would have thought multiplying the matrices in a different order would have changed the result, even though it should be possible to choose any order....