40 entry[0][0]=a.
x; entry[0][1]=b.
x; entry[0][2]=c.
x;
41 entry[1][0]=a.
y; entry[1][1]=b.
y; entry[1][2]=c.
y;
42 entry[2][0]=a.
z; entry[2][1]=b.
z; entry[2][2]=c.
z;
47 entry[0][0] = entry[1][1] = entry[2][2] = 1.;
48 entry[0][1] = entry[1][0] = entry[0][2] =
49 entry[2][0] = entry[1][2] = entry[2][1] = 0.;
54 for (
int m=0; m<3; ++m)
55 entry[m][0] = entry[m][1] = entry[m][2] = 0;
60 swap(entry[0][1], entry[1][0]);
61 swap(entry[0][2], entry[2][0]);
62 swap(entry[1][2], entry[2][1]);
67 double c2 = entry[0][0] + entry[1][1] + entry[2][2] - 1;
68 axis.
x = entry[2][1] - entry[1][2];
69 axis.
y = entry[0][2] - entry[2][0];
70 axis.
z = entry[1][0] - entry[0][1];
91 if ((entry[1][1]>entry[0][0]) && (entry[1][1]>entry[2][2])) choice=1;
92 if ((entry[2][2]>entry[0][0]) && (entry[2][2]>entry[1][1])) choice=2;
96 axis.
x = 0.5*sqrt(entry[0][0]-entry[1][1]-entry[2][2]+1);
97 double half_inv = 0.5/axis.
x;
98 axis.
y = half_inv*entry[0][1];
99 axis.
z = half_inv*entry[0][2];
104 axis.
y = 0.5*sqrt(entry[1][1]-entry[0][0]-entry[2][2]+1);
105 double half_inv = 0.5/axis.
y;
106 axis.
x = half_inv*entry[0][1];
107 axis.
z = half_inv*entry[1][2];
111 axis.
z = 0.5*sqrt(entry[2][2]-entry[0][0]-entry[1][1]+1);
112 double half_inv = 0.5/axis.
z;
113 axis.
x = half_inv*entry[0][2];
114 axis.
y = half_inv*entry[1][2];
119 double sa=sin(angle), ca=cos(angle);
121 entry[0][0] = axis.
x*axis.
x*ica + ca;
122 entry[1][1] = axis.
y*axis.
y*ica + ca;
123 entry[2][2] = axis.
z*axis.
z*ica + ca;
124 double t1 = axis.
x*axis.
y*ica, t2 = axis.
z*sa;
125 entry[1][0] = t1 + t2;
126 entry[0][1] = t1 - t2;
127 t1 = axis.
x*axis.
z*ica; t2 = axis.
y*sa;
128 entry[2][0] = t1 - t2;
129 entry[0][2] = t1 + t2;
130 t1 = axis.
y*axis.
z*ica; t2 = axis.
x*sa;
131 entry[1][2] = t1 - t2;
132 entry[2][1] = t1 + t2;
136 (
double alpha,
double beta,
double gamma)
138 double ca=cos(alpha), cb=cos(beta), cg=cos(gamma);
139 double sa=sin(alpha), sb=sin(beta), sg=sin(gamma);
141 entry[0][0]= ca*cb*cg-sa*sg; entry[0][1]=-ca*cb*sg-sa*cg; entry[0][2]= ca*sb;
142 entry[1][0]= sa*cb*cg+ca*sg; entry[1][1]=-sa*cb*sg+ca*cg; entry[1][2]= sa*sb;
143 entry[2][0]=-sb*cg; entry[2][1]= sb*sg; entry[2][2]= cb;
147 (
double &alpha,
double &beta,
double &gamma)
const 149 double cb = entry[2][2];
150 double sb = sqrt(entry[0][2]*entry[0][2] + entry[1][2]*entry[1][2]);
156 gamma=atan2(entry[1][0],entry[0][0]);
158 gamma=atan2(entry[0][1],-entry[0][0]);
162 alpha=atan2(entry[1][2],entry[0][2]);
163 gamma=atan2(entry[2][1],-entry[2][0]);
170 for (
int i=0; i<3; ++i)
171 for (
int j=0; j<3; ++j)
172 res.entry[i][j] = a.entry[i][0] * b.entry[0][j]
173 + a.entry[i][1] * b.entry[1][j]
174 + a.entry[i][2] * b.entry[2][j];
180 for (
int i=0; i<3; ++i)
181 for (
int j=0; j<3; ++j)
182 res.entry[i][j] = a.entry[i][0] * b.entry[0][j]
183 + a.entry[i][1] * b.entry[1][j]
184 + a.entry[i][2] * b.entry[2][j];
189 for (
int i=0; i<3; ++i)
190 for (
int j=0; j<3; ++j)
191 res.entry[i][j] = a.entry[0][i] * b.entry[0][j]
192 + a.entry[1][i] * b.entry[1][j]
193 + a.entry[2][i] * b.entry[2][j];
196 ostream &operator<< (ostream &os,
const rotmatrix &mat)
198 for (
int i=0;i<3;++i)
199 os << mat.entry[i][0] <<
' ' 200 << mat.entry[i][1] <<
' ' 201 << mat.entry[i][2] << endl;
void Extract_CPAC_Euler_Angles(double &alpha, double &beta, double &gamma) const
void Make_CPAC_Euler_Matrix(double alpha, double beta, double gamma)
void toAxisAngle(vec3 &axis, double &angle) const
void Make_Axis_Rotation_Transform(const vec3 &axis, double angle)