 # Matrix question

Hello people, I’m here again ,

I’m sorry but I don’t know how to multiply a point (X, Y, Z) to a matrix (may be a rotating matrix) can someone give me some help, I also don’t know the rotating matrix, if I’m not making a mistake, there is a special one for each axis(I mean one for the X axis, one for the Y axis and another one for the Z axis), please can some one help me ?

Thank you for the moment

Best regards

Kurt

Hi,

maybe this function in pseudocode will help. In this function point b is rotated around point a using matrix calcs. Here you can only specify xangle and yangle. Mail me for any questions: fredo@studenten.net

Public Function rotatePoint(a As PointType, b As PointType, xangle As GLfloat, yangle As GLfloat) As PointType

Dim X As GLfloat, Y As GLfloat, z As GLfloat
'These are the matrices for rotating any point in R3 around the axes
'R(y) = | cos(a) 0 -sin(a) |
’ | 0 1 0 |
’ | sin(a) 0 cos(a) |

'R(z) = | cos(b) sin(b) 0 |
’ | -sin(b) cos(b) 0 |
’ | 0 0 1 |

'R(x) = | 1 0 0 |

'In this sub I multiply (R(y) with b=yangle) with (R(x) with a=xangle)…
'The matrix that is created is multiplied with x,y,z to create a point

X = a.X - b.X 'substracting b to rotate around origin, otherwise matrix won’t
Y = a.Y - b.Y 'work
z = a.z - b.z

a.X = Cos(yangle) * X + Sin(yangle) * Sin(xangle) * Y - Sin(yangle) * Cos(xangle) * z
a.Y = 0 + Cos(xangle) * Y + Sin(xangle) * z
a.z = Sin(yangle) * X + Cos(yangle) * -Sin(xangle) * Y + Cos(yangle) * Cos(xangle) * z

a.X = a.X + b.X 'adding b again to achieve original rotated point
a.Y = a.Y + b.Y
a.z = a.z + b.z

rotatePoint = a

End Function