60 using namespace NEWMAT;
64 ReturnMatrix
trans(
const ColumnVector & a)
67 Matrix translation(4,4);
73 translation(1,4) = a(1);
74 translation(2,4) = a(2);
75 translation(3,4) = a(3);
78 cerr <<
"trans: wrong size in input vector." << endl;
80 translation.Release();
return translation;
83 ReturnMatrix
rotx(
const Real alpha)
99 rot.Release();
return rot;
103 ReturnMatrix
roty(
const Real beta)
119 rot.Release();
return rot;
123 ReturnMatrix
rotz(
const Real gamma)
139 rot.Release();
return rot;
145 ReturnMatrix
rotk(
const Real theta,
const ColumnVector & k)
149 Real c, s, vers, kx, ky, kz;
153 vers = SumSquare(k.SubMatrix(1,3,1,1));
163 rot(1,1) = kx*kx*vers+c;
164 rot(1,2) = kx*ky*vers-kz*s;
165 rot(1,3) = kx*kz*vers+ky*s;
166 rot(2,1) = kx*ky*vers+kz*s;
167 rot(2,2) = ky*ky*vers+c;
168 rot(2,3) = ky*kz*vers-kx*s;
169 rot(3,1) = kx*kz*vers-ky*s;
170 rot(3,2) = ky*kz*vers+kx*s;
171 rot(3,3) = kz*kz*vers+c;
174 rot.Release();
return rot;
178 ReturnMatrix
rpy(
const ColumnVector & a)
182 Real ca, sa, cb, sb, cc, sc;
194 rot(1,2) = sa*sb*cc-ca*sc;
195 rot(1,3) = ca*sb*cc+sa*sc;
197 rot(2,2) = sa*sb*sc+ca*cc;
198 rot(2,3) = ca*sb*sc-sa*cc;
203 rot.Release();
return rot;
207 ReturnMatrix
eulzxz(
const ColumnVector & a)
211 Real c1, s1, ca, sa, c2, s2;
222 rot(1,1) = c1*c2-s1*ca*s2;
223 rot(1,2) = -c1*s2-s1*ca*c2;
225 rot(2,1) = s1*c2+c1*ca*s2;
226 rot(2,2) = -s1*s2+c1*ca*c2;
232 rot.Release();
return rot;
236 ReturnMatrix
rotd(
const Real theta,
const ColumnVector & k1,
237 const ColumnVector & k2)
244 rot.Release();
return rot;
249 ReturnMatrix
irotk(
const Matrix & R)
258 k(4) = atan2(sqrt(a*a + b*b + c*c),(R(1,1) + R(2,2) + R(3,3)-1));
259 k(1) = (R(3,2)-R(2,3))/(2*sin(k(4)));
260 k(2) = (R(1,3)-R(3,1))/(2*sin(k(4)));
261 k(3) = (R(2,1)-R(1,2))/(2*sin(k(4)));
263 k.Release();
return k;
267 ReturnMatrix
irpy(
const Matrix & R)
273 k(1) = atan2(-R(1,2),-R(1,3));
276 }
else if (R(3,1)==-1) {
277 k(1) = atan2(R(1,2),R(1,3));
281 k(1) = atan2(R(3,2), R(3,3));
282 k(2) = atan2(-R(3,1), sqrt(R(1,1)*R(1,1) + R(2,1)*R(2,1)));
283 k(3) = atan2(R(2,1), R(1,1));
286 k.Release();
return k;
295 if ((R(3,3)==1) || (R(3,3)==-1)) {
297 a(2) = ((R(3,3) == 1) ? 0.0 : M_PI);
298 a(3) = atan2(R(2,1),R(1,1));
300 a(1) = atan2(R(1,3), -R(2,3));
301 a(2) = atan2(sqrt(R(1,3)*R(1,3) + R(2,3)*R(2,3)), R(3,3));
302 a(3) = atan2(R(3,1), R(3,2));
305 a.Release();
return a;