[quote name='SingularOne' timestamp='1313485221' post='4849759']
bMat *= oMat;
bMat += oMat2;
Why are you adding? All matrix chaining transformations should be multiplications...
[/quote]
[font="arial, verdana, tahoma, sans-serif"]Please let me clarify what
[color="#1C2837"]
M[sub]T[/sub] :=
R[sub]R[/sub] *
T[sub]T[/sub](-
c) +
T[sub]T[/sub](
c)[/font]
actually means. As mentioned my post above, [color="#1C2837"]
R[sub]R[/sub] is a 3x3 matrix and [color="#1C2837"]
T[sub]T[/sub] is a 1x3 matrix (a.k.a. column vector). Multiplying a 3x3 matrix on the left and a 1x3 matrix on the right gives you a 1x3 matrix. Adding a 1x3 matrix onto a 1x3 matrix gives you a 1x3 matrix.
So notice that the result [color="#1C2837"]
M[sub]T[/sub] is a 1x3 matrix (and that [color="#1C2837"]
M[sub]R[/sub] is a 3x3 matrix), while
M itself is a usual homogeneous 4x4 matrix. The correct assembly then looks like
bMat.make_identity();
// MR
bMat.element(0, 0) = cos(rx) * cos(ry);
bMat.element(1, 0) = -cos(rz) * sin(rx) - cos(rx)*sin(ry)*sin(rz);
bMat.element(2, 0) = cos(rx) * cos(rz) * sin(ry) + sin(rx) * sin(rz);;
bMat.element(0, 1) = cos(ry) * sin(rx);
bMat.element(1, 1) = cos(rx) * cos(rz) - sin(rx)*sin(ry)*sin(rz);
bMat.element(2, 1) = cos(rz) * sin(rx) * sin(ry) - cos(rx) * sin(rz);
bMat.element(0, 2) = -sin(ry);
bMat.element(1, 2) = cos(ry) * sin(rz);
bMat.element(2, 2) = cos(ry) * cos(rz);
// MT = MR * TT(-c) + TT(c)
bMat.element(0, 3) = bMat.element(0, 0) * (-ox) + bMat.element(0, 1) * (-oy) + bMat.element(0, 2) * (-oz) + ox;
bMat.element(1, 3) = bMat.element(1, 0) * (-ox) + bMat.element(1, 1) * (-oy) + bMat.element(1, 2) * (-oz) + oy;
bMat.element(2, 3) = bMat.element(2, 0) * (-ox) + bMat.element(2, 1) * (-oy) + bMat.element(2, 2) * (-oz) + oz;
if I have interpreted the indexing scheme correctly.
EDIT: It is for sure possible to compose the desired rotation simply by computing [color="#1C2837"]
T(
c) *
R *
T(-
c). The above way just shows (as mentioned) the minimal computational effort to do; it avoids all that nasty scalar products with 0 and 1. However, this kind of optimization will probably not be noticeable.