Advertisement

maths question

Started by February 08, 2001 04:48 PM
0 comments, last by zaphod 23 years, 11 months ago
Say you want to represent a square in 3d space as a coloured area on the screen. Imagine the square lies horizontal so its faces point directly up and down and that you are viewing it from a slightly elevated angle (which does not change). Imagine rotating the square about the z-axis through its centre, at certain points the angle made by a given corner of the square on the screen is 90degrees, but it varies above and below that value. My question is, what is the reationship between the angle by which the square is rotated and the angle of a given corner? square viewed at ... and at 45 degrees. 0 degrees roataaion ....... . .o . . o . ....... . . . . . Relationship between angle marked o and rotation angle? Cheers for any help. -felix.
I just started writing a 3D rendering engine and let me tell you 3D rotations are the hardest thing Ive done so far. Here''s some advice: When you want to rotate a 3D object all you need to keep track of are it''s vertices. A cube has 8, for example, and a pyramid would have 5. if your rotating through the center around the y-axis it means those vertices would only be changing on the x and z coordinates, so you''d only need two equations. Since looking them up for yourself would be a waste of your time, here they are:

new_x=(z*sin(yaw))+(x*cos(yaw))
new_z=(z*cos(yaw))-(x*sin(yaw))

The yaw is the number of degrees (in radians) that you want the point to be placed at. Radian measurements go from 0 to 2PI

ex. 0/360 degrees = 0/2PI radians
90 degrees = .5PI radians
180 degrees = PI radians
270 degrees = 1.5PI radians

Thats basicaly all you need to know for a cube because each vertice is 90 degrees (or .5PI radians) away from each other.
Hope this helped, E-Mail me if you have any questions.

Oh, also, here''s some 3D lingo:
Pitch = rotation around the x-axis
Roll = rotation around the z-axis
Yaw = rotation around the y-axis

codeXtremeif(you->intelligence < radish->intelligence) you->STFU();

This topic is closed to new replies.

Advertisement