|
|
>...
> The original lines where easier for math people, because they were
> simply the traditionnal matrix.
> Your lines are more difficult to recognize as a rotation (at least for me).
>...
Ok, then I'll try to explain how to see that my lines
represent such a rotation...
Please see my post to povray.advanced-users 30. Nov;
"Rotation around an arbitrary axis":
news://news.povray.org/3C06D0B8.9DE747A0%40hotmail.com
http://news.povray.org/povray.advanced-users/20370/
- and my explanation below.
Tor Olav
Here's is a matrix expression that shows how one can
build a general rotation matrix R, that will represent
a rotation around a given unit vector v = <a, b, c>
in a left handed coordinate system:
R = -Sin*S + (1 - Cos)*S*S + I
(Sin means sin(Angle) and Cos means cos(Angle).)
S is this skew symmetric matrix:
0 -c b
S = c 0 -a
-b a 0
(I have seen this written like this S = skew(v))
And I is an identity matrix:
1 0 0
I = 0 1 0
0 0 1
Rewriting the first expression:
0 -c b -Sin*0 Sin*c -Sin*b
-Sin*S = -Sin * c 0 -a = -Sin*c -Sin*0 Sin*a
-b a 0 Sin*b -Sin*a -Sin*0
0 c*Sin -b*Sin
= -c*Sin 0 a*Sin
b*Sin -a*Sin 0
Then we'll work with the rest of the expression.
Multiplying matrix S by itself:
0 -c b 0 -c b 0*0-c*c-b*b -0*c+c*0+b*a -0*b+c*a-b*0
S*S = c 0 -a * c 0 -a = -c*0-0*c+a*b -c*c+0*0-a*a c*b+0*a+a*0
-b a 0 -b a 0 b*0+a*c+0*b b*c-a*0-0*a -b*b-a*a+0*0
-(b^2+c^2) b*a c*a
= a*b -(a^2+c^2) c*b
a*c b*c -(a^2+b^2)
Since v is a vector with unit length:
sqrt(a^2 + b^2 + c^2) = 1
or simply:
a^2 + b^2 + c^2 = 1
Here's three ways to rearrange that:
-(b^2 + c^2) = a^2 - 1
-(a^2 + c^2) = b^2 - 1
-(a^2 + b^2) = c^2 - 1
Substitution:
a*a-1 b*a c*a a*a b*a c*a 1 0 0
S*S = a*b b*b-1 c*b = a*b b*b c*b - 0 1 0
a*c b*c c*c-1 a*c b*c c*c 0 0 1
Scaling with (1 - Cos):
(1-Cos)*S*S
a*a b*a c*a 1 0 0
= (1-Cos) * a*b b*b c*b - (1-Cos) * 0 1 0
a*c b*c c*c 0 0 1
a*a b*a c*a Cos 0 0 1 0 0
= (1-Cos) * a*b b*b c*b + 0 Cos 0 - 0 1 0
a*c b*c c*c 0 0 Cos 0 0 1
Adding an identity matrix:
(1-Cos)*S*S + I
a*a b*a c*a Cos 0 0
= (1-Cos) * a*b b*b c*b + 0 Cos 0
a*c b*c c*c 0 0 Cos
Now we can tell that:
R = -Sin*S + (1-Cos)*S*S + I
0 c*Sin -b*Sin a*a b*a c*a Cos 0 0
= -c*Sin 0 a*Sin + (1-Cos) * a*b b*b c*b + 0 Cos 0
b*Sin -a*Sin 0 a*c b*c c*c 0 0 Cos
Cos c*Sin -b*Sin a*a b*a c*a
= -c*Sin Cos a*Sin + (1-Cos) * a*b b*b c*b
b*Sin -a*Sin Cos a*c b*c c*c
Cos c*Sin -b*Sin a*a*(1-Cos) b*a*(1-Cos) c*a*(1-Cos)
= -c*Sin Cos a*Sin + a*b*(1-Cos) b*b*(1-Cos) c*b*(1-Cos)
b*Sin -a*Sin Cos a*c*(1-Cos) b*c*(1-Cos) c*c*(1-Cos)
Finally we'll do another matrix addition to get one single matrix:
a*a*(1-Cos)+Cos b*a*(1-Cos)+c*Sin c*a*(1-Cos)-b*Sin
R = a*b*(1-Cos)-c*Sin b*b*(1-Cos)+Cos c*b*(1-Cos)+a*Sin
a*c*(1-Cos)+b*Sin b*c*(1-Cos)-a*Sin c*c*(1-Cos)+Cos
And from this we see that:
R[0][0] = a*a*(1 - Cos) + Cos
R[0][1] = b*a*(1 - Cos) + c*Sin
R[0][2] = c*a*(1 - Cos) - b*Sin
R[1][0] = a*b*(1 - Cos) - c*Sin
R[1][1] = b*b*(1 - Cos) + Cos
R[1][2] = c*b*(1 -Cos) + a*Sin
R[2][0] = a*c*(1 - Cos) + b*Sin
R[2][1] = b*c*(1 - Cos) - a*Sin
R[2][2] = c*c*(1 - Cos) + Cos
Now if:
v = V1 (a = V1[X], b = V1[Y], c = V1[Z])
cosx = Cos
sinx = Sin
omc = 1-Cos
Then it's easy to see that:
transform->matrix = R
> > transform->matrix[0][0] = V1[X] * V1[X] * omc + cosx;
> > transform->matrix[0][1] = V1[X] * V1[Y] * omc + V1[Z] * sinx;
> > transform->matrix[0][2] = V1[X] * V1[Z] * omc - V1[Y] * sinx;
> >
> > transform->matrix[1][0] = V1[X] * V1[Y] * omc - V1[Z] * sinx;
> > transform->matrix[1][1] = V1[Y] * V1[Y] * omc + cosx;
> > transform->matrix[1][2] = V1[Y] * V1[Z] * omc + V1[X] * sinx;
> >
> > transform->matrix[2][0] = V1[X] * V1[Z] * omc + V1[Y] * sinx;
> > transform->matrix[2][1] = V1[Y] * V1[Z] * omc - V1[X] * sinx;
> > transform->matrix[2][2] = V1[Z] * V1[Z] * omc + cosx;
Post a reply to this message
|
|