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 |

’ | 0 cos© sin© |

’ | 0 -sin© cos© |

’

'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