1

How can I rotate the point (x, y, z) by angles (rx, ry, rz) about their respective axes?

That is, how do I determine the point (x1, y1, z1) resulting from the rotation of (x, y, z) by rotation angles (rx, ry, rz)?

Are there any DirectX routines which accomplish this?

andand
  • 17,134
  • 11
  • 53
  • 79
PolGraphic
  • 3,233
  • 11
  • 51
  • 108
  • 2
    You need to find the formula. What does this question have to do with programming and this cite? – klm123 Aug 14 '12 at 13:10
  • 4
    What do those angles refer to? Are they Euler angles? In general, you should get from those angles to a rotation matrix (the way depends from what those angles represent, see e.g. [here](http://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Conversion_formulae_between_formalisms)) and apply it to the position vector. – Matteo Italia Aug 14 '12 at 13:11
  • 3
    read this http://en.wikipedia.org/wiki/Rotation_matrix – mathematician1975 Aug 14 '12 at 13:16
  • 1
    There is no such thing as rotation from the point `(0,0,0)`. You can rotate around an axis but not a point. Please clarify this in your question. – Ali Aug 14 '12 at 13:53
  • @Ali: It looks like English is probably not the poster's primary language. I believe he is stating that the rotations are all centered at the origin. – andand Aug 14 '12 at 16:11
  • @klm123, the question specifically asks for a solution relevant to DirectX - that makes it a programming question to me. – Mark Ransom Aug 14 '12 at 16:27
  • @andand OK, thanks for the clarification, I failed to understand that. – Ali Aug 14 '12 at 19:36

2 Answers2

3

What you are asking about is how to use Euler Angles for performing rotations. There are several conventions you can choose from, but it looks to me like you are interested in applying rotation about the Z axis, followed by rotation about Y and then rotation about X. For this you would post multiply by the matrix

enter image description here

where

c1 = cos(rx)    s1 = sin(rx)
c2 = cos(ry)    s2 = sin(ry)
cs = cos(rz)    s3 = sin(rz)

There are several problems with this approach, one of the more common being gimbal lock. The preferred approach is to use one of the angle-axis formulations. The two most common of those are Unit Quaternion Rotations and Euler-Rodreigues Rotation Matrices. These can be composed to generate any of the 12 Euler Rotation matrices by explicitly defining three rotation axes and their associated rotation angles and then multiplying the resulting rotation representation in the reverse order they are to be applied to the vectors to be rotated.

DirectX uses Quaternions for performing rotations.

andand
  • 17,134
  • 11
  • 53
  • 79
  • +1 for understanding the question (I couldn't) and for the clear and detailed answer! – Ali Aug 14 '12 at 19:37
1

During my electronics(EM) classes I learnt converting cartesian to polar cordinates using the formula

x = r sinq cosf, y = r sinq sinf, z = r cosq

More Info Here

q is theta, f is phi.

perilbrain
  • 7,961
  • 2
  • 27
  • 35
  • I don't think this is what the poster is asking. You're converting between polar and Cartesian coordinates. The OP is asking about rotating a point from one location to another using Euler angles. – andand Aug 14 '12 at 16:18