# Trig in 3D Rotations?

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

## Recommended Posts

Say I was going to rotate a 3D field...like a fighting arena, on its y axis. I know that the matrix for y rotations involves trigonomic functions...but for that to happen, you need a right triangle and a reference angle. My question is: if it's not clearly a triangle...and it's something like a character, or an entire level....how you do determine its reference angle, and the size and location of the triangle?

##### Share on other sites
Define everything by points, say the midpoint of a character, the middle of a level etc. Once you have everything as a point, you can find the angles between them (3 points defines a triangle). I usually use the origin (0,0) as the reference point, so the other 2 are just the objects:
A(-6,1)          O(0,0)     B(-3,3)Need A-O-B. Law of Cosines:AB2 = AO2 + BO2 - 2 * AO * BO * cos(A-O-B)Where AO = sqr(62 + 12)      BO = sqr(32 + 32)      AB = sqr(32 + 22)(distance formula to find distance between points)(don't forget this still works with 3 dimensions: dist=sqr(x2+y2+z2)!Therefore,cos(A-O-B) = AB2 -AO2 - BO2/-2 * AO * BOAnd voila! You have your angle!...I hate trig.

If I got that wrong, someone please correct me. It's been awhile! [lol]

##### Share on other sites
The relation to a right triangle can be seen by rotating the coordinate axes, i.e. (1,0,0), (0,1,0) and (0,0,1). What happens to (1,0,0) tells you what the first column should be assuming it is a matrix times a vector. So a rotation by t around the z axis take (1,0,0) to (cos(t),sin(t)) and (0,1,0) to (-sin(t),cos(t)).

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631778
• Total Posts
3002310
×