25 double ca = cos(ea.
m1), sa = sin(ea.
m1);
26 double cb = cos(ea.
m2), sb = sin(ea.
m2);
27 double cc = cos(ea.
m3), sc = sin(ea.
m3);
29 m12 = sa*sb*cc - ca*sc;
30 m13 = ca*sb*cc + sa*sc;
32 m22 = sa*sb*sc + ca*cc;
33 m23 = ca*sb*sc - sa*cc;
42 m2 = atan2(-mat.
m31, cb);
45 m1 = atan2(mat.
m12, mat.
m22);
50 m1 = atan2(mat.
m32/cb, mat.
m33/cb);
51 m3 = atan2(mat.
m21/cb, mat.
m11/cb);
58 double c1 = cos(ea.
m1),
s1 = sin(ea.
m1);
59 double c2 = cos(ea.
m2),
s2 = sin(ea.
m2);
60 double c3 = cos(ea.
m3), s3 = sin(ea.
m3);
75 m2 = atan2(mat.
m21, c2);
78 m1 = atan2(mat.
m32, mat.
m33);
83 m1 = atan2(-mat.
m23, mat.
m22);
84 m3 = atan2(-mat.
m31, mat.
m11);
91 double c1 = cos(ea.
m1),
s1 = sin(ea.
m1);
92 double c2 = cos(ea.
m2),
s2 = sin(ea.
m2);
93 double c3 = cos(ea.
m3), s3 = sin(ea.
m3);
108 m2 = atan2(mat.
m13, c2);
111 m1 = atan2(mat.
m21, mat.
m22);
116 m1 = atan2(-mat.
m12, mat.
m11);
117 m3 = atan2(-mat.
m23, mat.
m33);
124 double c1 = cos(ea.
m1),
s1 = sin(ea.
m1);
125 double c2 = cos(ea.
m2),
s2 = sin(ea.
m2);
126 double c3 = cos(ea.
m3), s3 = sin(ea.
m3);
141 m2 = atan2(-mat.
m12, c2);
144 m1 = atan2(mat.
m23, mat.
m33);
149 m1 = atan2(mat.
m13, mat.
m11);
150 m3 = atan2(mat.
m32, mat.
m22);
157 if(fabs(m1-ea_ref(0)) >
PI)
159 if(m1 < -
PI*0.5 || ea_ref(0) >
PI*0.5)
163 else if(m1 >
PI*0.5 || ea_ref(0) < -
PI*0.5)
168 if(fabs(m3-ea_ref(2)) >
PI)
171 if(m3 < -
PI*0.5 || ea_ref(2) >
PI*0.5)
177 else if(m3 >
PI*0.5 || ea_ref(2) < -
PI*0.5)
190 fMat33 mat(epara(3), epara(2), -epara(1), -epara(2), epara(3), epara(0), epara(1), -epara(0), epara(3));
192 temp.
mul(-edot(3), epara.
Vec());
201 fMat33 mat1(e(3), e(2), -e(1), -e(2), e(3), e(0), e(1), -e(0), e(3));
202 fMat33 mat2(de(3), de(2), -de(1), -de(2), de(3), de(0), de(1), -de(0), de(3));
207 tmp.
mul(-de(3), de.Vec());
209 tmp.
mul(-dde(3), e.
Vec());
248 if(x < 0.0)
return -1.0;
249 else if(x > 0.0)
return 1.0;
255 double e = ((*this)(2,1) - (*
this)(1,2)) * ((*this)(2,1) - (*
this)(1,2)) +
256 ((*this)(0,2) - (*
this)(2,0)) * ((*this)(0,2) - (*
this)(2,0)) +
257 ((*this)(1,0) - (*
this)(0,1)) * ((*this)(1,0) - (*
this)(0,1));
258 double c = 0.5 * ((*this)(0,0) + (*
this)(1,1) + (*
this)(2,2) - 1.0);
270 double s = 0.5 * sqrt(e);
284 axis(0) = 0.5 * ((*this)(2,1) - (*
this)(1,2)) / s;
285 axis(1) = 0.5 * ((*this)(0,2) - (*
this)(2,0)) / s;
286 axis(2) = 0.5 * ((*this)(1,0) - (*
this)(0,1)) / s;
292 double rx = (*this)(0,0) - c;
293 double ry = (*this)(1,1) - c;
294 double rz = (*this)(2,2) - c;
303 axis(0) = sqrt(rx / v);
307 axis(0) =
sgn((*
this)(2,1) - (*
this)(1,2)) * sqrt(rx / v);
309 axis(1) = ((*this)(1,0) + (*
this)(0,1)) / (2 * axis(0) * v);
310 axis(2) = ((*this)(0,2) + (*
this)(2,0)) / (2 * axis(0) * v);
317 axis(2) = sqrt(rz / v);
321 axis(2) =
sgn((*
this)(1,0) - (*
this)(0,1)) * sqrt(rz / v);
323 axis(0) = ((*this)(0,2) + (*
this)(2,0)) / (2 * axis(2) * v);
324 axis(1) = ((*this)(1,2) + (*
this)(2,1)) / (2 * axis(2) * v);
334 axis(1) = sqrt(ry / v);
338 axis(1) =
sgn((*
this)(0,2) - (*
this)(2,0)) * sqrt(ry / v);
340 axis(0) = ((*this)(0,1) + (*
this)(1,0)) / (2 * axis(1) * v);
341 axis(2) = ((*this)(1,2) + (*
this)(2,1)) / (2 * axis(1) * v);
348 axis(2) = sqrt(rz / v);
352 axis(2) =
sgn((*
this)(1,0) - (*
this)(0,1)) * sqrt(rz / v);
354 axis(0) = ((*this)(0,2) + (*
this)(2,0)) / (2 * axis(2) * v);
355 axis(1) = ((*this)(1,2) + (*
this)(2,1)) / (2 * axis(2) * v);
364 double x = axis.
m1,
y = axis.
m2, z = axis.
m3;
365 double sa = sin(angle), ca = cos(angle);
366 (*this)(0,0) = ca + (1-ca)*x*
x;
367 (*this)(0,1) = (1-ca)*x*
y - sa*z;
368 (*this)(0,2) = (1-ca)*x*z + sa*
y;
369 (*this)(1,0) = (1-ca)*y*x + sa*z;
370 (*this)(1,1) = ca + (1-ca)*y*
y;
371 (*this)(1,2) = (1-ca)*y*z - sa*
x;
372 (*this)(2,0) = (1-ca)*z*x - sa*
y;
373 (*this)(2,1) = (1-ca)*z*y + sa*
x;
374 (*this)(2,2) = ca + (1-ca)*z*z;
520 if(i<0 || i>=3 || j<0 || j>=3)
522 cerr <<
"matrix size error at operator ()" << endl;
526 return *(&
m11 + i + j*3);
532 if(i<0 || i>=3 || j<0 || j>=3)
534 cerr <<
"matrix size error at operator ()" << endl;
538 return *(&
m11 + i + j*3);
546 cerr <<
"vector size error at operator ()" << endl;
558 cerr <<
"vector size error at operator ()" << endl;
633 double ex = epara(0), ey = epara(1), ez = epara(2), e = epara(3);
634 double ee = e * e, exx = ex * ex, eyy = ey * ey, ezz = ez * ez;
635 double exy = ex * ey, eyz = ey * ez, ezx = ez * ex;
636 double eex = e * ex, eey = e * ey, eez = e * ez;
637 m11 = exx - eyy - ezz + ee;
638 m22 = - exx + eyy - ezz + ee;
639 m33 = - exx - eyy + ezz + ee;
640 m12 = 2.0 * (exy - eez);
641 m21 = 2.0 * (exy + eez);
642 m13 = 2.0 * (ezx + eey);
643 m31 = 2.0 * (ezx - eey);
644 m23 = 2.0 * (eyz - eex);
645 m32 = 2.0 * (eyz + eex);
769 m1 = vec.
m1; m2 = vec.
m2; m3 = vec.
m3;
822 ret.
m1 = vec1.
m1 - vec2.
m1;
823 ret.
m2 = vec1.
m2 - vec2.
m2;
824 ret.
m3 = vec1.
m3 - vec2.
m3;
831 ret.
m1 = vec1.
m1 + vec2.
m1;
832 ret.
m2 = vec1.
m2 + vec2.
m2;
833 ret.
m3 = vec1.
m3 + vec2.
m3;
849 ret = vec1.
m1*vec2.
m1 + vec1.
m2*vec2.
m2 + vec1.
m3*vec2.
m3;
856 ret.
m1 = vec1.
m1 * d;
857 ret.
m2 = vec1.
m2 * d;
858 ret.
m3 = vec1.
m3 * d;
865 ret.
m1 = vec1.
m1 * d;
866 ret.
m2 = vec1.
m2 * d;
867 ret.
m3 = vec1.
m3 * d;
890 m1 = vec1.
m1 + vec2.
m1;
891 m2 = vec1.
m2 + vec2.
m2;
892 m3 = vec1.
m3 + vec2.
m3;
904 m1 = vec1.
m1 - vec2.
m1;
905 m2 = vec1.
m2 - vec2.
m2;
906 m3 = vec1.
m3 - vec2.
m3;
946 m1 = vec1.
m2*vec2.
m3 - vec1.
m3*vec2.
m2;
947 m2 = vec1.
m3*vec2.
m1 - vec1.
m1*vec2.
m3;
948 m3 = vec1.
m1*vec2.
m2 - vec1.
m2*vec2.
m1;
970 ost <<
"(" << v.
m1 <<
", " << v.
m2 <<
", " << v.
m3 <<
")" << flush;
976 ost <<
"(" << m.
m11 <<
", " << m.
m12 <<
", " << m.
m13 <<
"," << endl
977 <<
" " << m.
m21 <<
", " << m.
m22 <<
", " << m.
m23 <<
"," << endl
978 <<
" " << m.
m31 <<
", " << m.
m32 <<
", " << m.
m33 <<
")" << flush;
void rotation(const fMat33 &ref, const fMat33 &tgt)
Computes the rotation from tgt to ref.
void operator/=(double d)
friend fMat33 operator-(const fMat33 &mat)
void operator-=(const fMat33 &mat)
void add(const fVec3 &vec1, const fVec3 &vec2)
double & operator()(int i, int j)
The reference to the (i, j)-th element.
void ea2mat_xyz(const fVec3 &ea)
Converts from Euler angles.
void mat2ea_xyz(const fMat33 &mat)
Orientation matrix to Euler angles.
void epdot2angvel(const fEulerPara &epara, const fEulerPara &edot)
Computes the angular velocity from the velocity of Euler parameters.
void ea2mat_yzx(const fVec3 &ea)
Euler angles to matrix.
void operator*=(double d)
void div(const fMat33 &mat, double d)
void set(const fMat33 &mat)
Copies a matrix.
void mul(const fMat33 &mat1, const fMat33 &mat2)
friend fMat33 tran(const fMat33 &m)
Returns the transpose.
void operator/=(double d)
void cross(const fVec3 &vec1, const fVec3 &vec2)
Cross product.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
void diag(double, double, double)
Diagonal matrix.
Euler parameter representation of orientation.
void identity()
Identity matrix.
void set(double *v)
Set element values from array or three values.
friend fMat33 operator*(double d, const fMat33 &mat)
double & operator()(int i)
Access the i-th element.
void operator*=(double d)
void neg(const fMat33 &mat)
Functions for basic operations.
void rot2mat(const fVec3 &, double)
Converts from/to equivalent rotation axis and angle.
void ea2mat_xzy(const fVec3 &ea)
Euler angles to matrix.
void mat2ea_yzx(const fMat33 &mat)
friend fMat33 operator+(const fMat33 &mat1, const fMat33 &mat2)
void epddot2angacc(const fEulerPara &_e, const fEulerPara &_de, const fEulerPara &_dde)
Computes angular acceleration from the acceleration of Euler parameters.
void operator-=(const fVec3 &vec)
friend fMat33 operator/(const fMat33 &mat, double d)
void div(const fVec3 &vec, double d)
void operator=(double d)
Assignment operators.
void mat2ea_zyx(const fMat33 &mat)
void cross(const fVec3 &p)
Sets spectial matrices.
void neg(const fVec3 &vec)
void mat2ea_xzy(const fMat33 &mat)
void operator+=(const fMat33 &mat)
3x3 matrix and 3-element vector classes.
void mat2rot(fVec3 &, double &) const
void sub(const fMat33 &mat1, const fMat33 &mat2)
void sub(const fVec3 &vec1, const fVec3 &vec2)
fVec3 operator&(const fVec3 &vec1, const fVec3 &vec2)
void add(const fMat33 &mat1, const fMat33 &mat2)
fMat33 operator=(const fMat33 &mat)
Assignment operator.
double * data()
Pointer to the first element.
void mul(const fVec3 &vec, double d)
void operator+=(const fVec3 &vec)
void ea2mat_zyx(const fVec3 &ea)
Euler angles to matrix.
friend HRPBASE_EXPORT ostream & operator<<(ostream &ost, const fMat33 &mat)
Outputs the elements to a stream.