hello there, i have a lil prblem with multiple rotations.
Ok, let start.
I have a rotation matrix for Y-axis rotation, a translation matrix,
a point P and a point M.
I wnat to rotate point P around Point M.
The first rotation works.
I do
P (1,0,1) M(3,0,1)
moving point P at -M coordinates
|1 |
|0 |
|1 |
________|1 |
1 0 0 -3|-2|
0 1 0 0| 0| Point P has been translated at -M coordinates,
0 0 1 -1| 0| M is now "at 0,0,0".
0 0 0 1| 1|
rotating at 15 degrees around y-axis
|-2|
| 0|
| 0|
___________________| 1|____
0.966 0 -0.2588 0|-1.9319|
0 1 0 0| 0 |
-0.2588 0 0.966 0|0.5176 | P has been rotated
0 0 0 1|1 |
moving P at +M koordinates
|-1.9319 |
| 0 |
|0.5176 |
_______| 1 |
1 0 0 3|1.0681|
0 1 0 0| 0 | Point P has been translated at -M koordinates,
0 0 1 1|1.5176| M is now "at 0,0,0".
0 0 0 1| 1 |
P (1.0681,0,1.5176)
So far so good. Now my problem is...
If i want to rotate the rotatet point P again around M I get
wrogn values for P.
-------------------------------
rotate again with P(1.0681,0,1.5176)
M is still 3,0,1
moving point P at -M coordinates
|1.0681 |
|0 |
|1.5176 |
________|1 |
1 0 0 -3|-1.9319|
0 1 0 0| 0 | Point P has been translated at -M coordinates,
0 0 1 -1|0.5176 | M is now "at 0,0,0".
0 0 0 1| 1 |
rotating at 15 degrees around y-axis
|-1.9319|
| 0 |
| 0 |
___________________|0.5176 |
0.966 0 -0.2588 0|-2.000 |
0 1 0 0| 0 |
-0.2588 0 0.966 0|1.000 | P has been rotated
0 0 0 1|1 |
moving P at +M koordinates
|-2.000 |
| 0 |
| 1.000 |
_______| 1 |
1 0 0 3| 1 |
0 1 0 0| 0 | Point P has been translated at -M koordinates,
0 0 1 1| 2 | M is now "at 0,0,0".
0 0 0 1| 1 |
P (1,0,2)
but this is wrong. can anyone explain to me why the second rotations does not work ?
For the 2nd rotation P should be 1.2679, 0, 2.
I get the correct P if i rotate once at 30 degrees. But 2 times 15 degrees
doesnt work. can an one help me ?
I know, OpenGl computes backwards.
OpenGl wants it like that T(+)*R*T(-)
but on computing it on the paper is this order
T(-)*R*T(+)
greetings,
xiaowei