#### Archived

This topic is now archived and is closed to further replies.

# Getting a vector having dimension rotations.

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

## Recommended Posts

Well, I want to make a vector out of rotations, for example, if I have RotX = 0 RotY = 90 RotZ = 0 the unit vector that would come out would be(i think) v.x = 0 v.y = 0 v.z = 1 How could I come on accomplishing this? I figured how to do it in 2D angles, since the hypothenus is always a length of 1, then we can get side A and side B with: sin(angle) = A cos(angle) = B this way, i could create a vector like so v.x = cos(angle) v.y = sin(angle) but, when it comes to 3 dimensions, how could i go on accomplishing my objectives?

##### Share on other sites
And so the sticking point starts...
There are different ways to play with things in 3d.
The 3rd dimension adds lots of complexity.

There are a few methods: euler rotation, axis-angle, and quaternions.

You can compose a complete 4x4 matrix for rotation, translation, and scaling based on euler rotation I believe.

The code here assumes rotation around a given axis(kind of)
theta is the YZ plane rotation or around the Z axis.
phi is XZ plane rotation or around Y.
phi is YZ plane rotation or around X.
x'' = y * sin(theta) + x * cos(theta)y'' = y * cos(theta) - x * sin(theta)z'' = zx'''' = x'' * sin(phi) + x'' * cos(phi)y'''' = y''z'''' = z'' * cos(phi) - z'' * sin(phi)x'''''' = x''''y'''''' = y'''' * sin(chi) + y'''' * cos(chi)z'''''' = z'''' * cos(chi) - z'''' * sin(chi)

This is the easiest method to derive.
It also is somewhat like the OpenGL glRotate() call.

For high-quality code, quaternions are the method of choice for rotations.(Last I checked- its kind of a debate thing)

Hope that helped...

~V''lion

Bugle4d

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009377
• ### Who's Online (See full list)

There are no registered users currently online

×