30 if ((x == 0) && (y == 0)) result = 0;
31 else result = atan2 (y, x);
42 for (
int j = 0; j<3; j++) v[j] = c.v[j];
48 v[0]=x; v[1]=y; v[2]=z;
53 return (index < 3) ? * (v + index) : *v;
58 for (
int j = 0; j<3; j++) v[j] = c.v[j];
64 for (
int j = 0; j<3; j++) v[j] = v[j] + c.v[j];
70 for (
int j = 0; j<3; j++) v[j] = v[j] - c.v[j];
77 result.v[0] = v[1] * c.v[2] - v[2] * c.v[1];
78 result.v[1] = v[2] * c.v[0] - v[0] * c.v[2];
79 result.v[2] = v[0] * c.v[1] - v[1] * c.v[0];
80 for (
int j = 0; j<3; j++) v[j] = result.v[j];
86 for (
int j = 0; j<3; j++) v[j] = r * v[j];
94 if (r < 1E-100) q = 0.0;
96 for (
int j = 0; j<3; j++) v[j] = q * v[j];
104 for (
int j=0; j<3; j++) result += c.v[j]*c.v[j];
112 for (
int j = 0; j<3; j++) result += c1.v[j]*c2.v[j];
120 for (
int j = 0; j<3; j++) result.v[j] = c1.v[j] + c2.v[j];
128 for (
int j = 0; j<3; j++) result.v[j] = c1.v[j] - c2.v[j];
137 for (
int j = 0; j<3; j++) result.v[j] = r * c1.v[j];
145 for (
int j = 0; j<3; j++) result.v[j] = c1.v[j] * r;
153 result.v[0] = c1.v[1] * c2.v[2] - c1.v[2] * c2.v[1];
154 result.v[1] = c1.v[2] * c2.v[0] - c1.v[0] * c2.v[2];
155 result.v[2] = c1.v[0] * c2.v[1] - c1.v[1] * c2.v[0];
164 if (r < 1E-100) q = 0.0;
166 for (
int j = 0; j<3; j++) result.v[j] = q * c1.v[j];
176 for (j=0; j<3; j++) q += c.v[j]*c.v[j];
178 if (q < 1E-100) q = 0.0;
180 for (j=0; j<3; j++) result.v[j] = c.v[j]*q;
198 result.v[0] = sqrt (r + z*z);
199 result.v[1] =
atan20 (y, x);
200 if (result.v[1] < 0) result.v[1] += 2.0*
M_PI;
202 result.v[2] =
atan20 (z, r);
217 r = c.v[0] * cos(c.v[2]);
218 result.v[0] = r * cos(c.v[1]);
219 result.v[1] = r * sin(c.v[1]);
220 result.v[2] = c.v[0] * sin(c.v[2]);
227 os <<
"[" << c.v[0] <<
"," << c.v[1] <<
"," << c.v[2] <<
"]";
238 for (j=0; j<3; j++) m[i][j] = x;
246 for (j=0; j<3; j++) m[i][j] = c.
m[i][j];
250 double x21,
double x22,
double x23,
251 double x31,
double x32,
double x33)
269 for (j=0; j<3; j++) m[i][j] = x[i][j];
274 if ((i>0) && (i<4) && (j>0) && (j<4)) m[i-1][j-1] = x;
281 if ((i>0) && (i<4) && (j>0) && (j<4)) result = m[i-1][j-1];
292 for (j=0; j<3; j++) m[i][j] = c.
m[i][j];
302 for (j=0; j<3; j++) m[i][j] = m[i][j] + c.
m[i][j];
311 for (j=0; j<3; j++) m[i][j] = m[i][j] - c.
m[i][j];
325 for (k=0; k<3; k++) r = r + c.
m[i][k] * m[k][j];
330 for (j=0; j<3; j++) m[i][j] = b.
m[i][j];
340 for (j=0; j<3; j++) m[i][j] = r*m[i][j];
349 if (r < 1E-100) q = 0.0;
353 for (j=0; j<3; j++) m[i][j] = m[i][j] * q;
363 for (j=0; j<3; j++) result.
m[i][j] = r;
374 for (i=0; i<3; i++) result.
m[i][i] = 1.0;
385 for (j=0; j<3; j++) result.
m[i][j] = m1.
m[j][i];
394 result = c.
m[0][0]*c.
m[1][1]*c.
m[2][2] + c.
m[0][1]*c.
m[1][2]*c.
m[2][0]
395 + c.
m[0][2]*c.
m[1][0]*c.
m[2][1] - c.
m[0][2]*c.
m[1][1]*c.
m[2][0]
396 - c.
m[0][0]*c.
m[1][2]*c.
m[2][1] - c.
m[0][1]*c.
m[1][0]*c.
m[2][2];
407 for (j=0; j<3; j++) result.
m[i][j] = c1.
m[i][j] + c2.
m[i][j];
417 for (j=0; j<3; j++) result.
m[i][j] = c1.
m[i][j] - c2.
m[i][j];
427 for (j=0; j<3; j++) result.
m[i][j] = c1.
m[i][j] * r;
438 for (j=0; j<3; j++) result.
m[i][j] = c1.
m[i][j] * r;
452 for (k=0; k<3; k++) r = r + c1.
m[i][k] * c2.
m[k][j];
465 if (r < 1E-100) q = 0.0;
469 for (j=0; j<3; j++) result.
m[i][j] = c1.
m[i][j] * q;
482 for (j=0; j<3; j++) r = r + m1.
m[i][j] * v1[j];
557 Mat3 pitch, yaw, roll, result;
562 result = yaw * pitch;
568 void gpyr (
const Mat3& m1,
double& p,
double& y,
double& r)
573 y = asin (m1.
m[0][1]);
574 r =
atan20 (-m1.
m[2][1], m1.
m[1][1]);
575 p =
atan20 (-m1.
m[0][2], m1.
m[0][0]);
584 y =
atan20 (v[1], sqrt (v[0]*v[0] + v[2]*v[2]));
593 p =
M_PI / 2.0 -
atan20 (v[0], sqrt (v[1]*v[1] + v[2]*v[2]));
601 double ri, rj, rk, q1, q2, q3, q4;
605 ri =
atan20 (m.
m[2][0], -m.
m[2][1]);
606 rj = 0.5 * acos (m.
m[2][2]);
611 q1 = q4 * cos (0.5 * (ri - rk));
612 q2 = q4 * sin (0.5 * (ri - rk));
614 q3 = q4 * sin (0.5 * (ri + rk));
615 q4 = q4 * cos (0.5 * (ri + rk));
624 q4 = 0.5 * sqrt (1.0 + m.
m[0][0] + m.
m[1][1] + m.
m[2][2]);
636 double q1, q2, q3, q4, q12, q22, q32, q42;
651 result.
assign ((q12 - q22 - q32 + q42), (2.0 * (q1*q2 + q3*q4)),
652 (2.0 * (q1*q3 - q2*q4)), (2.0 * (q1*q2 - q3*q4)),
653 (-q12 + q22 - q32 + q42),(2.0 * (q2*q3 + q1*q4)),
654 (2.0 * (q1*q3 + q2*q4)), (2.0 * (q2*q3 - q1*q4)),
655 (-q12 - q22 + q32 + q42));
663 os <<
"[" << c.
m[0][0] <<
"," << c.
m[0][1] <<
"," << c.
m[0][2] <<
"]" << endl
664 <<
"[" << c.
m[1][0] <<
"," << c.
m[1][1] <<
"," << c.
m[1][2] <<
"]" << endl
665 <<
"[" << c.
m[2][0] <<
"," << c.
m[2][1] <<
"," << c.
m[2][2] <<
"]" << endl;
double & operator[](unsigned index)
Mat3 & operator-=(const Mat3 &c)
void vcpy(Vec3 &v, double &p, double &y)
double atan20(double y, double x)
Vec3 operator/(const Vec3 &c1, double r)
Vec3 operator-(const Vec3 &c1, const Vec3 &c2)
Mat3 & operator+=(const Mat3 &c)
void gpyr(const Mat3 &m1, double &p, double &y, double &r)
Vec3 carpol(const Vec3 &c)
Vec3 vnorm(const Vec3 &c)
Vec3 operator+(const Vec3 &c1, const Vec3 &c2)
void assign(double x11, double x12, double x13, double x21, double x22, double x23, double x31, double x32, double x33)
Mat3 & operator=(const Mat3 &c)
void vcrp(Vec3 &v, double &p, double &r)
double abs(const Vec3 &c)
Vec3 & operator*=(const Vec3 &c)
Mat3 & operator*=(const Mat3 &c)
Mat3 mxrox(double &a, Vec3 &v)
void mxevc(const Mat3 &m, double &a, Vec3 &v)
double mxdet(const Mat3 &c)
Mat3 mxtrn(const Mat3 &m1)
Mat3 csmx(double p, double y, double r)
ostream & operator<<(ostream &os, const Vec3 &c)
Vec3 & operator/=(double r)
Vec3 operator*(double r, const Vec3 &c1)
Mat3 & operator/=(double r)
Vec3 & operator-=(const Vec3 &c)
double GetMij(int i, int j) const
void assign(double x=0, double y=0, double z=0)
Vec3 & operator+=(const Vec3 &c)
Vec3 & operator=(const Vec3 &c)
double dot(const Vec3 &c1, const Vec3 &c2)
Vec3 polcar(const Vec3 &c)
Vec3 mxvct(const Mat3 &m1, Vec3 &v1)
Vec3(double x=0, double y=0, double z=0)
void PutMij(double x, int i, int j)