42#define M_PI 3.14159265358979323846
48#include <gsl/gsl_matrix.h>
49#include <gsl/gsl_blas.h>
50#include <gsl/gsl_linalg.h>
53using std::ostream_iterator;
57const float Transform::ERR_LIMIT = 0.000001f;
59vector<string> Transform::permissable_2d_not_rot;
60vector<string> Transform::permissable_3d_not_rot;
61map<string,vector<string> > Transform::permissable_rot_keys;
111 if (
this != &that ) {
120 if (memcmp(this->
matrix, rhs.
matrix, 3*4*
sizeof(
float)) == 0) {
139 memcpy(
matrix,array,12*
sizeof(
float));
151 for(
int i=0; i<3; ++i) {
152 for(
int j=0; j<4; ++j) {
161 for(
int i=0; i<3; ++i) {
162 for(
int j=0; j<4; ++j) {
163 array[idx] =
matrix[i][j];
170 if (precision<2||precision>9) precision=9;
173 sprintf(fmt,
"[%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg,%%1.%0dg]",
174 precision,precision,precision,precision,precision,precision,precision,precision,precision,precision,precision,precision);
175 sprintf(buf,fmt,
matrix[0][0],
matrix[0][1],
matrix[0][2],
matrix[0][3],
matrix[1][0],
matrix[1][1],
matrix[1][2],
matrix[1][3],
183 vector<float> ret(12);
184 for(
int i=0; i<3; ++i) {
185 for(
int j=0; j<4; ++j) {
186 ret[i*4+j] =
matrix[i][j];
194 vector<float> ret(16);
195 for(
int i=0; i<3; ++i) {
196 for(
int j=0; j<4; ++j) {
197 ret[i*4+j] =
matrix[i][j];
210 for(
int i=0; i<3; ++i) {
211 for(
int j=0; j<4; ++j) {
223 for(
int i=0; i<3; ++i) {
224 for(
int j=0; j<4; ++j) {
228 if (c != 1.0)
return false;
231 if (c != 0.0)
return false;
239 for(
int i=0; i<3; ++i) {
240 for(
int j=0; j<3; ++j) {
244 if (c != 1.0)
return false;
247 if (c != 0.0)
return false;
260 float scale =
static_cast<float>(d.
get_ci(
"scale"));
264 float dx=0,dy=0,dz=0;
270 if ( dx != 0.0 || dy != 0.0 || dz != 0.0 ) {
279 bool mirror =
static_cast<bool>(e);
302 tmp.push_back(
"alpha");
306 tmp.push_back(
"alt");
308 tmp.push_back(
"phi");
312 tmp.push_back(
"psi");
313 tmp.push_back(
"theta");
314 tmp.push_back(
"phi");
318 tmp.push_back(
"alpha");
319 tmp.push_back(
"beta");
320 tmp.push_back(
"gamma");
324 tmp.push_back(
"ztilt");
325 tmp.push_back(
"xtilt");
326 tmp.push_back(
"ytilt");
330 tmp.push_back(
"phi");
331 tmp.push_back(
"theta");
332 tmp.push_back(
"omega");
346 tmp.push_back(
"omega");
357 tmp.push_back(
"m11");
358 tmp.push_back(
"m12");
359 tmp.push_back(
"m13");
360 tmp.push_back(
"m21");
361 tmp.push_back(
"m22");
362 tmp.push_back(
"m23");
363 tmp.push_back(
"m31");
364 tmp.push_back(
"m32");
365 tmp.push_back(
"m33");
374 vector<string> verification;
375 vector<string> problem_keys;
379 bool problem =
false;
381 problem_keys.push_back(type);
386 std::copy(perm.begin(),perm.end(),back_inserter(verification));
388 if ( type ==
"2d" ) {
399 if ( std::find(verification.begin(),verification.end(), it->first) == verification.end() ) {
400 problem_keys.push_back(it->first);
404 if (problem_keys.size() != 0 ) {
406 if (problem_keys.size() == 1) {
407 error =
"Transform Error: The \"" +problem_keys[0]+
"\" key is unsupported";
409 error =
"Transform Error: The ";
410 for(vector<string>::const_iterator cit = problem_keys.begin(); cit != problem_keys.end(); ++cit ) {
411 if ( cit != problem_keys.begin() ) {
412 if (cit == (problem_keys.end() -1) ) error +=
" and ";
419 error +=
" keys are unsupported";
430 float dx=0,dy=0,dz=0;
435 if ( (dx != 0.0 || dy != 0.0 || dz != 0.0) && d.
has_key_ci(
"type") ) {
443 float scale =
static_cast<float>(d.
get_ci(
"scale"));
447 Transform solution_trans = tmp*pre_trans;
451 float scale =
static_cast<float>(d.
get_ci(
"scale"));
453 solution_trans = solution_trans*tmp;
458 solution_trans = solution_trans*tmp;
463 float scale =
static_cast<float>(d.
get_ci(
"scale"));
472 bool mirror =
static_cast<bool>(e);
483 params[
"tx"] = v[0]; params[
"ty"] = v[1];
486 if ( type !=
"2d") params[
"tz"] = v[2];
489 params[
"scale"] =
scale;
492 params[
"mirror"] = mirror;
504 params[
"tx"] = v[0]; params[
"ty"] = v[1];
507 if ( type !=
"2d") params[
"tz"] = v[2];
510 params[
"scale"] =
scale;
513 params[
"mirror"] = mirror;
528 euler_type =
static_cast<string>(rotation.
get_ci(
"type"));
531 double e0=0;
double e1=0;
double e2=0;
double e3=0;
542 bool is_quaternion = 0;
557 phi = (double)rotation[
"alpha"] ;
558 }
else if ( type ==
"eman" ) {
560 az = (double)rotation[
"az"] ;
561 alt = (double)rotation[
"alt"] ;
562 phi = (double)rotation[
"phi"] ;
563 }
else if ( type ==
"imagic" ) {
565 az = (double)rotation[
"alpha"] ;
566 alt = (double)rotation[
"beta"] ;
567 phi = (double)rotation[
"gamma"] ;
568 }
else if ( type ==
"spider" ) {
570 az = (double)rotation[
"phi"] + 90.0;
571 alt = (double)rotation[
"theta"] ;
572 phi = (double)rotation[
"psi"] - 90.0;
573 }
else if ( type ==
"xyz" ) {
582 }
else if ( type ==
"mrc" ) {
584 az = (double)rotation[
"phi"] + 90.0f ;
585 alt = (double)rotation[
"theta"] ;
586 phi = (double)rotation[
"omega"] - 90.0f ;
587 }
else if ( type ==
"quaternion" ) {
590 e0 = (double)rotation[
"e0"];
591 e1 = (double)rotation[
"e1"];
592 e2 = (double)rotation[
"e2"];
593 e3 = (double)rotation[
"e3"];
594 }
else if ( type ==
"spin" ) {
597 omega = (double)rotation[
"omega"];
598 double norm=
Util::hypot3((
double)rotation[
"n1"],(
double)rotation[
"n2"],(
double)rotation[
"n3"]);
608 }
else if ( type ==
"sgirot" ) {
611 omega = (double)rotation[
"q"] ;
616 }
else if ( type ==
"matrix" ) {
618 matrix[0][0] = (float)rotation[
"m11"];
619 matrix[0][1] = (float)rotation[
"m12"];
620 matrix[0][2] = (float)rotation[
"m13"];
621 matrix[1][0] = (float)rotation[
"m21"];
622 matrix[1][1] = (float)rotation[
"m22"];
623 matrix[1][2] = (float)rotation[
"m23"];
624 matrix[2][0] = (float)rotation[
"m31"];
625 matrix[2][1] = (float)rotation[
"m32"];
626 matrix[2][2] = (float)rotation[
"m33"];
636 if (!is_quaternion && !is_matrix && !is_xyz) {
637 matrix[0][0] = (float)(cos(phip)*cos(azp) - cos(altp)*sin(azp)*sin(phip));
638 matrix[0][1] = (float)(cos(phip)*sin(azp) + cos(altp)*cos(azp)*sin(phip));
639 matrix[0][2] = (float)(sin(altp)*sin(phip));
640 matrix[1][0] = (float)(-sin(phip)*cos(azp) - cos(altp)*sin(azp)*cos(phip));
641 matrix[1][1] = (float)(-sin(phip)*sin(azp) + cos(altp)*cos(azp)*cos(phip));
642 matrix[1][2] = (float)(sin(altp)*cos(phip));
643 matrix[2][0] = (float)(sin(altp)*sin(azp));
644 matrix[2][1] = (float)(-sin(altp)*cos(azp));
645 matrix[2][2] = (float)cos(altp);
648 matrix[0][0] = (float)(e0 * e0 + e1 * e1 - e2 * e2 - e3 * e3);
649 matrix[0][1] = (float)(2.0f * (e1 * e2 + e0 * e3));
650 matrix[0][2] = (float)(2.0f * (e1 * e3 - e0 * e2));
651 matrix[1][0] = (float)(2.0f * (e2 * e1 - e0 * e3));
652 matrix[1][1] = (float)(e0 * e0 - e1 * e1 + e2 * e2 - e3 * e3);
653 matrix[1][2] = (float)(2.0f * (e2 * e3 + e0 * e1));
654 matrix[2][0] = (float)(2.0f * (e3 * e1 + e0 * e2));
655 matrix[2][1] = (float)(2.0f * (e3 * e2 - e0 * e1));
656 matrix[2][2] = (float)(e0 * e0 - e1 * e1 - e2 * e2 + e3 * e3);
660 matrix[0][0] = (float)(cytilt*cztilt);
661 matrix[0][1] = (float)(cxtilt*sztilt+sxtilt*sytilt*cztilt);
662 matrix[0][2] = (float)(sxtilt*sztilt-cxtilt*sytilt*cztilt);
663 matrix[1][0] = (float)(-cytilt*sztilt);
664 matrix[1][1] = (float)(cxtilt*cztilt-sxtilt*sytilt*sztilt);
665 matrix[1][2] = (float)(sxtilt*cztilt+cxtilt*sytilt*sztilt);
666 matrix[2][0] = (float)(sytilt);
667 matrix[2][1] = (float)(-sxtilt*cytilt);
668 matrix[2][2] = (float)(cxtilt*cytilt);
673 for(
int i=0; i<3; ++i) {
674 for(
int j=0; j<3; ++j) {
682 for(
int j=0; j<3; ++j) {
700 if ( v[0] == 0 && v[1] == 0 && v[2] == 0 )
706 double theta = acos(v1[2]);
707 double psi = atan2(v1[1],-v1[0]);
712 d[
"phi"] = (double)0.0;
713 d[
"type"] =
"spider";
725 for (
int i=0; i<3; i++) {
726 for (
int j=0; j<3; j++) {
727 result[i][j] = multmatrix[i*4]*
matrix[0][j] + multmatrix[i*4+1]*
matrix[1][j] + multmatrix[i*4+2]*
matrix[2][j];
731 for (
int i=0; i<3; i++) {
732 for (
int j=0; j<3; j++) {
733 matrix[i][j] = result[i][j];
754 spinrot[
"type"] =
"spin";
755 spinrot[
"omega"] = omega;
756 spinrot[
"n1"] = cctrans[0];
757 spinrot[
"n2"] = cctrans[1];
758 spinrot[
"n3"] = cctrans[2];
768 for (
int i=0; i<3; i++) {
769 for (
int j=0; j<4; j++) {
770 result[i][j] = multmatrix[i*4]*
matrix[0][j] + multmatrix[i*4+1]*
matrix[1][j] + multmatrix[i*4+2]*
matrix[2][j];
774 for (
int i=0; i<3; i++) {
775 for (
int j=0; j<4; j++) {
776 matrix[i][j] = result[i][j];
784 for(
unsigned int i = 0; i < 3; ++i) {
785 for(
unsigned int j = 0; j < 4; ++j) {
786 t.
set(i,j,t[i][j]*-1);
795 rot[
"alt"] = 180.0f +
static_cast<float>(rot[
"alt"]);
796 rot[
"phi"] = 180.0f -
static_cast<float>(rot[
"phi"]);
803 trans[0] = -trans[0];
814 rot[
"alt"] = 180.0f +
static_cast<float>(rot[
"alt"]);
815 rot[
"phi"] = -
static_cast<float>(rot[
"phi"]);
823 trans[1] = -trans[1];
842 double x_mirror_scale = (x_mirror ? -1.0f : 1.0f);
843 double inv_scale = 1.0f/
scale;
857 }
else if (cosalt <= -1) {
884 }
else if (cosalt <= -1) {
892 phiS = phiS-360.0*floor(phiS/360.0);
893 psiS = psiS-360.0*floor(psiS/360.0);
903 result[
"type"] = type;
906 result[
"alpha"] = phi;
907 }
else if (type ==
"eman") {
912 }
else if (type ==
"imagic") {
914 result[
"alpha"] = az;
915 result[
"beta"] = alt;
916 result[
"gamma"] = phi;
917 }
else if (type ==
"spider") {
919 result[
"phi"] = phiS;
920 result[
"theta"] = alt;
921 result[
"psi"] = psiS;
922 }
else if (type ==
"mrc") {
924 result[
"phi"] = phiS;
925 result[
"theta"] = alt;
926 result[
"omega"] = psiS;
927 }
else if (type ==
"xyz") {
934 xtilt = xtilt-360*.0*floor((xtilt+180.0)/360.0);
935 ytilt = ytilt-360*.0*floor((ytilt+180.0)/360.0);
936 ztilt = ztilt-360*.0*floor((ztilt+180.0)/360.0);
938 result[
"xtilt"] = xtilt;
939 result[
"ytilt"] = ytilt;
940 result[
"ztilt"] = ztilt;
941 }
else if ((type ==
"quaternion") || (type ==
"spin") || (type ==
"sgirot")) {
948 double cosomega = (traceR-1.0)/2.0;
953 double sinomega =
sqrt(A0*A0+A1*A1+A2*A2);
955 if (cosomega> 1.0) cosomega= 1.0;
956 if (cosomega<-1.0) cosomega=-1.0;
960 double cosOover2=
sqrt((1.0 +cosomega)/2.0);
962 double sinOover2=
sqrt((1.0 -cosomega)/2.0);
965 double n1 = A0/sinomega;
966 double n2 = A1/sinomega;
967 double n3 = A2/sinomega;
995 if (type ==
"quaternion"){
996 result[
"e0"] = cosOover2 ;
997 result[
"e1"] = sinOover2 * n1 ;
998 result[
"e2"] = sinOover2 * n2;
999 result[
"e3"] = sinOover2 * n3;
1002 if (type ==
"spin"){
1004 if (cosomega< 0) { Omega = 180-Omega;}
1005 result[
"omega"] = Omega;
1011 if (type ==
"sgirot"){
1018 }
else if (type ==
"matrix") {
1020 result[
"m11"] = x_mirror_scale*
matrix[0][0]*inv_scale;
1021 result[
"m12"] = x_mirror_scale*
matrix[0][1]*inv_scale;
1022 result[
"m13"] = x_mirror_scale*
matrix[0][2]*inv_scale;
1023 result[
"m21"] =
matrix[1][0]*inv_scale;
1024 result[
"m22"] =
matrix[1][1]*inv_scale;
1025 result[
"m23"] =
matrix[1][2]*inv_scale;
1026 result[
"m31"] =
matrix[2][0]*inv_scale;
1027 result[
"m32"] =
matrix[2][1]*inv_scale;
1028 result[
"m33"] =
matrix[2][2]*inv_scale;
1040 if (x_mirror)
matrix[0][3] = -
x;
1051 if (x_mirror) v[0] = -
matrix[0][3];
1052 else v[0] =
matrix[0][3];
1092 if (x_mirror) v[0] = -
matrix[0][3];
1093 else v[0] =
matrix[0][3];
1124 if (new_scale <= 0) {
1125 throw InvalidValueException(new_scale,
"The scale factor in a Transform object must be positive and non zero");
1132 float n_scale = new_scale;
1135 float corrected_scale = n_scale/old_scale;
1136 if ( corrected_scale != 1.0 ) {
1137 for(
int i = 0; i < 3; ++i ) {
1138 for(
int j = 0; j < 3; ++j ) {
1139 matrix[i][j] *= corrected_scale;
1147 if (determinant < 0 ) determinant *= -1;
1149 float scale = std::pow(determinant,1.0f/3.0f);
1150 int int_scale =
static_cast<int>(
scale);
1151 float scale_residual =
scale-
static_cast<float>(int_scale);
1152 if ( scale_residual <
ERR_LIMIT ) {
scale =
static_cast<float>(int_scale); };
1162 if (determinant < 0) determinant *= -1.0f;
1163 float newscale = std::pow(determinant,1.0f/3.0f) +
scale;
1164 if(newscale > 0.0001)
set_scale(newscale);
1167void print_matrix(gsl_matrix* M,
unsigned int r,
unsigned int c,
const string& message ) {
1168 cout <<
"Message is " << message << endl;
1169 for (
unsigned int i = 0; i < r; ++i )
1171 for (
unsigned int j = 0; j < c; ++j )
1173 cout << gsl_matrix_get(M,i,j) <<
" ";
1185 double inv_scale = 1.0/
static_cast<double>(
scale);
1186 double mirror_scale = (x_mirror ==
true ? -1.0:1.0);
1188 gsl_matrix * R = gsl_matrix_calloc(3,3);
1189 for (
unsigned int i = 0; i < 3; ++i )
1191 for (
unsigned int j = 0; j < 3; ++j )
1193 if (i == 0 && mirror_scale != 1.0 ) {
1194 gsl_matrix_set( R, i, j,
static_cast<double>(
matrix[i][j])*mirror_scale*inv_scale );
1197 gsl_matrix_set( R, i, j,
static_cast<double>(
matrix[i][j])*inv_scale );
1202 gsl_matrix *
V = gsl_matrix_calloc(3,3);
1203 gsl_vector * S = gsl_vector_calloc(3);
1204 gsl_vector * work = gsl_vector_calloc(3);
1205 gsl_linalg_SV_decomp (R,
V, S, work);
1207 gsl_matrix * Soln = gsl_matrix_calloc(3,3);
1208 gsl_blas_dgemm (CblasNoTrans, CblasTrans, 1.0, R,
V, 0.0, Soln);
1210 for (
unsigned int i = 0; i < 3; ++i )
1212 for (
unsigned int j = 0; j < 3; ++j )
1214 matrix[i][j] =
static_cast<float>( gsl_matrix_get(Soln,i,j) );
1219 if (
scale != 1.0f) {
1220 for(
int i=0; i<3; ++i) {
1221 for(
int j=0; j<3; ++j) {
1229 for(
int j=0; j<3; ++j) {
1234 gsl_matrix_free(
V); gsl_matrix_free(R); gsl_matrix_free(Soln);
1235 gsl_vector_free(S); gsl_vector_free(work);
1241 if (old_x_mirror == x_mirror)
return;
1244 for (
int j = 0; j < 4; ++j ) {
1253 bool x_mirror =
false;
1254 if ( determinant < 0 ) x_mirror =
true;
1264 if ( determinant < 0 ) {
1268 if (determinant != 1 ) {
1269 scale = std::pow(determinant,1.0f/3.0f);
1270 int int_scale =
static_cast<int>(
scale);
1271 float scale_residual =
scale-
static_cast<float>(int_scale);
1272 if ( scale_residual <
ERR_LIMIT ) {
scale =
static_cast<float>(int_scale); };
1300 double cof00 = m11*m22-m12*m21;
1301 double cof11 = m22*m00-m20*m02;
1302 double cof22 = m00*m11-m01*m10;
1303 double cof01 = m10*m22-m20*m12;
1304 double cof02 = m10*m21-m20*m11;
1305 double cof12 = m00*m21-m01*m20;
1306 double cof10 = m01*m22-m02*m21;
1307 double cof20 = m01*m12-m02*m11;
1308 double cof21 = m00*m12-m10*m02;
1310 double det = m00* cof00 + m02* cof02 -m01*cof01;
1312 matrix[0][0] = (float)(cof00/det);
1313 matrix[0][1] = - (float)(cof10/det);
1314 matrix[0][2] = (float)(cof20/det);
1315 matrix[1][0] = - (float)(cof01/det);
1316 matrix[1][1] = (float)(cof11/det);
1317 matrix[1][2] = - (float)(cof21/det);
1318 matrix[2][0] = (float)(cof02/det);
1319 matrix[2][1] = - (float)(cof12/det);
1320 matrix[2][2] = (float)(cof22/det);
1322 matrix[0][3] = (float)((- cof00*
v0 + cof10*v1 - cof20*v2)/det);
1323 matrix[1][3] = (float)(( cof01*
v0 - cof11*v1 + cof21*v2)/det);
1324 matrix[2][3] = (float)((- cof02*
v0 + cof12*v1 - cof22*v2)/det);
1335 for (
int i = 0; i < 3; i++) {
1336 for (
int j = 0; j < i; j++) {
1356 for (
int i=0; i<3; i++) {
1357 for (
int j=0; j<4; j++) {
1358 result[i][j] = M2[i][0] * M1[0][j] + M2[i][1] * M1[1][j] + M2[i][2] * M1[2][j];
1360 result[i][3] += M2[i][3];
1367 int rotation_error = 0;
1368 int translation_error = 0;
1375 if (
matrix[2][2] <=0) rotation_error++;
1376 if ( translation_error && rotation_error ) {
1377 throw UnexpectedBehaviorException(
"Error, the internal matrix contains 3D rotations and 3D translations. This object can not be considered 2D");
1378 }
else if ( translation_error ) {
1379 throw UnexpectedBehaviorException(
"Error, the internal matrix contains a non zero z component for a 3D translation. This object can not be considered 2D");
1381 else if ( rotation_error ) {
1393 ret = (*this) * sym->
get_sym(n);
1401 vector<Transform> tut;
1403 ret = (*this) * tut[n];
1409 vector<Transform> ret;
1412 if( lstr ==
"tet" ) {
1414 static float TET[108] = {
1415 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
1416 -0.5f, 0.86602540378f, 0.0f, -0.86602540378f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f,
1417 -0.5f, -0.86602540378f, 0.0f, 0.86602540378f, -0.5f, -0.0f, 0.0f, 0.0f, 1.0f,
1418 -0.16666666667f, 0.86602540378f, -0.47140452079f, 0.28867513459f, 0.5f, 0.81649658093f, 0.94280904158f, 0.0f, -0.33333333333f,
1419 0.33333333333f, 0.0f, 0.94280904158f, 0.0f, -1.0f, 0.0f, 0.94280904158f, 0.0f, -0.33333333333f,
1420 -0.16666666667f, -0.86602540378f, -0.47140452079f, -0.28867513459f, 0.5f, -0.81649658093f, 0.94280904158f, 0.0f, -0.33333333333f,
1421 -0.66666666667f, -0.57735026919f, -0.47140452079f, -0.57735026919f, 0.0f, 0.81649658093f, -0.47140452079f, 0.81649658093f, -0.33333333333f,
1422 -0.16666666667f, 0.28867513459f, 0.94280904158f, 0.86602540378f, 0.5f, 0.0f, -0.47140452079f, 0.81649658093f, -0.33333333333f,
1423 0.83333333333f, 0.28867513459f, -0.47140452079f, -0.28867513459f, -0.5f, -0.81649658093f, -0.47140452079f, 0.81649658093f, -0.33333333333f,
1424 0.83333333333f, -0.28867513459f, -0.47140452079f, 0.28867513459f, -0.5f, 0.81649658093f, -0.47140452079f, -0.81649658093f, -0.33333333333f,
1425 -0.16666666667f, -0.28867513459f, 0.94280904158f, -0.86602540378f, 0.5f, 0.0f, -0.47140452079f, -0.81649658093f, -0.33333333333f,
1426 -0.66666666667f, 0.57735026919f, -0.47140452079f, 0.57735026919f, -0.0f, -0.81649658093f, -0.47140452079f, -0.81649658093f, -0.33333333333f
1429 for (
int k=0;k<nsym;k++) {
1431 for (
int i=0; i<3; i++) {
1432 for (
int j=0; j<3; j++) {
1433 t.
matrix[i][j] = TET[9*k + i*3 +j];
1438 ret.push_back( (*
this) * t );
1440 }
else if( lstr ==
"oct" ) {
1442 static float TET[216] = {
1443 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
1444 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
1445 -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
1446 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
1447 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f,
1448 0.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
1449 0.0f, 0.0f, -1.0f, 0.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f,
1450 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f,
1451 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f,
1452 -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
1453 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f,
1454 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f,
1455 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f,
1456 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
1457 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f,
1458 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f,
1459 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f,
1460 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
1461 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f,
1462 -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, -1.0f, 0.0f,
1463 -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f,
1464 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
1465 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f,
1466 0.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f
1469 for (
int k=0;k<nsym;k++) {
1471 for (
int i=0; i<3; i++) {
1472 for (
int j=0; j<3; j++) {
1473 t.
matrix[i][j] = TET[9*k + i*3 +j];
1478 ret.push_back( (*
this) * t );
1480 }
else if( lstr ==
"icos" ) {
1482 static float TET[540] = {
1483 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
1484 0.30901699437f, 0.9510565163f, 0.0f, -0.9510565163f, 0.30901699437f, 0.0f, 0.0f, 0.0f, 1.0f,
1485 -0.80901699437f, 0.58778525229f, 0.0f, -0.58778525229f, -0.80901699437f, 0.0f, 0.0f, 0.0f, 1.0f,
1486 -0.80901699437f, -0.58778525229f, 0.0f, 0.58778525229f, -0.80901699437f, 0.0f, 0.0f, 0.0f, 1.0f,
1487 0.30901699437f, -0.9510565163f, 0.0f, 0.9510565163f, 0.30901699437f, 0.0f, 0.0f, 0.0f, 1.0f,
1488 0.36180339887f, 0.58778525229f, -0.72360679775f, -0.26286555606f, 0.80901699437f, 0.52573111212f, 0.894427191f, 0.0f, 0.4472135955f,
1489 -0.13819660113f, 0.9510565163f, 0.27639320225f, -0.42532540418f, -0.30901699437f, 0.85065080835f, 0.894427191f, 0.0f, 0.4472135955f,
1490 -0.4472135955f, 0.0f, 0.894427191f, 0.0f, -1.0f, 0.0f, 0.894427191f, 0.0f, 0.4472135955f,
1491 -0.13819660113f, -0.9510565163f, 0.27639320225f, 0.42532540418f, -0.30901699437f, -0.85065080835f, 0.894427191f, 0.0f, 0.4472135955f,
1492 0.36180339887f, -0.58778525229f, -0.72360679775f, 0.26286555606f, 0.80901699437f, -0.52573111212f, 0.894427191f, 0.0f, 0.4472135955f,
1493 -0.4472135955f, 0.52573111212f, -0.72360679775f, -0.85065080835f, 0.0f, 0.52573111212f, 0.27639320225f, 0.85065080835f, 0.4472135955f,
1494 -0.9472135955f, 0.16245984812f, 0.27639320225f, 0.16245984812f, -0.5f, 0.85065080835f, 0.27639320225f, 0.85065080835f, 0.4472135955f,
1495 -0.13819660113f, -0.42532540418f, 0.894427191f, 0.9510565163f, -0.30901699437f, 0.0f, 0.27639320225f, 0.85065080835f, 0.4472135955f,
1496 0.86180339887f, -0.42532540418f, 0.27639320225f, 0.42532540418f, 0.30901699437f, -0.85065080835f, 0.27639320225f, 0.85065080835f, 0.4472135955f,
1497 0.67082039325f, 0.16245984812f, -0.72360679775f, -0.68819096024f, 0.5f, -0.52573111212f, 0.27639320225f, 0.85065080835f, 0.4472135955f,
1498 -0.63819660113f, -0.26286555606f, -0.72360679775f, -0.26286555606f, -0.80901699437f, 0.52573111212f, -0.72360679775f, 0.52573111212f, 0.4472135955f,
1499 -0.4472135955f, -0.85065080835f, 0.27639320225f, 0.52573111212f, 0.0f, 0.85065080835f, -0.72360679775f, 0.52573111212f, 0.4472135955f,
1500 0.36180339887f, -0.26286555606f, 0.894427191f, 0.58778525229f, 0.80901699437f, 0.0f, -0.72360679775f, 0.52573111212f, 0.4472135955f,
1501 0.67082039325f, 0.68819096024f, 0.27639320225f, -0.16245984812f, 0.5f, -0.85065080835f, -0.72360679775f, 0.52573111212f, 0.4472135955f,
1502 0.0527864045f, 0.68819096024f, -0.72360679775f, -0.68819096024f, -0.5f, -0.52573111212f, -0.72360679775f, 0.52573111212f, 0.4472135955f,
1503 0.0527864045f, -0.68819096024f, -0.72360679775f, 0.68819096024f, -0.5f, 0.52573111212f, -0.72360679775f, -0.52573111212f, 0.4472135955f,
1504 0.67082039325f, -0.68819096024f, 0.27639320225f, 0.16245984812f, 0.5f, 0.85065080835f, -0.72360679775f, -0.52573111212f, 0.4472135955f,
1505 0.36180339887f, 0.26286555606f, 0.894427191f, -0.58778525229f, 0.80901699437f, 0.0f, -0.72360679775f, -0.52573111212f, 0.4472135955f,
1506 -0.4472135955f, 0.85065080835f, 0.27639320225f, -0.52573111212f, 0.0f, -0.85065080835f, -0.72360679775f, -0.52573111212f, 0.4472135955f,
1507 -0.63819660113f, 0.26286555606f, -0.72360679775f, 0.26286555606f, -0.80901699437f, -0.52573111212f, -0.72360679775f, -0.52573111212f, 0.4472135955f,
1508 0.67082039325f, -0.16245984812f, -0.72360679775f, 0.68819096024f, 0.5f, 0.52573111212f, 0.27639320225f, -0.85065080835f, 0.4472135955f,
1509 0.86180339887f, 0.42532540418f, 0.27639320225f, -0.42532540418f, 0.30901699437f, 0.85065080835f, 0.27639320225f, -0.85065080835f, 0.4472135955f,
1510 -0.13819660113f, 0.42532540418f, 0.894427191f, -0.9510565163f, -0.30901699437f, 0.0f, 0.27639320225f, -0.85065080835f, 0.4472135955f,
1511 -0.9472135955f, -0.16245984812f, 0.27639320225f, -0.16245984812f, -0.5f, -0.85065080835f, 0.27639320225f, -0.85065080835f, 0.4472135955f,
1512 -0.4472135955f, -0.52573111212f, -0.72360679775f, 0.85065080835f, 0.0f, -0.52573111212f, 0.27639320225f, -0.85065080835f, 0.4472135955f,
1513 -0.36180339887f, -0.26286555606f, -0.894427191f, -0.58778525229f, 0.80901699437f, 0.0f, 0.72360679775f, 0.52573111212f, -0.4472135955f,
1514 -0.67082039325f, 0.68819096024f, -0.27639320225f, 0.16245984812f, 0.5f, 0.85065080835f, 0.72360679775f, 0.52573111212f, -0.4472135955f,
1515 -0.0527864045f, 0.68819096024f, 0.72360679775f, 0.68819096024f, -0.5f, 0.52573111212f, 0.72360679775f, 0.52573111212f, -0.4472135955f,
1516 0.63819660113f, -0.26286555606f, 0.72360679775f, 0.26286555606f, -0.80901699437f, -0.52573111212f, 0.72360679775f, 0.52573111212f, -0.4472135955f,
1517 0.4472135955f, -0.85065080835f, -0.27639320225f, -0.52573111212f, 0.0f, -0.85065080835f, 0.72360679775f, 0.52573111212f, -0.4472135955f,
1518 0.13819660113f, -0.42532540418f, -0.894427191f, -0.9510565163f, -0.30901699437f, 0.0f, -0.27639320225f, 0.85065080835f, -0.4472135955f,
1519 -0.86180339887f, -0.42532540418f, -0.27639320225f, -0.42532540418f, 0.30901699437f, 0.85065080835f, -0.27639320225f, 0.85065080835f, -0.4472135955f,
1520 -0.67082039325f, 0.16245984812f, 0.72360679775f, 0.68819096024f, 0.5f, 0.52573111212f, -0.27639320225f, 0.85065080835f, -0.4472135955f,
1521 0.4472135955f, 0.52573111212f, 0.72360679775f, 0.85065080835f, 0.0f, -0.52573111212f, -0.27639320225f, 0.85065080835f, -0.4472135955f,
1522 0.9472135955f, 0.16245984812f, -0.27639320225f, -0.16245984812f, -0.5f, -0.85065080835f, -0.27639320225f, 0.85065080835f, -0.4472135955f,
1523 0.4472135955f, 0.0f, -0.894427191f, 0.0f, -1.0f, 0.0f, -0.894427191f, 0.0f, -0.4472135955f,
1524 0.13819660113f, -0.9510565163f, -0.27639320225f, -0.42532540418f, -0.30901699437f, 0.85065080835f, -0.894427191f, 0.0f, -0.4472135955f,
1525 -0.36180339887f, -0.58778525229f, 0.72360679775f, -0.26286555606f, 0.80901699437f, 0.52573111212f, -0.894427191f, 0.0f, -0.4472135955f,
1526 -0.36180339887f, 0.58778525229f, 0.72360679775f, 0.26286555606f, 0.80901699437f, -0.52573111212f, -0.894427191f, 0.0f, -0.4472135955f,
1527 0.13819660113f, 0.9510565163f, -0.27639320225f, 0.42532540418f, -0.30901699437f, -0.85065080835f, -0.894427191f, 0.0f, -0.4472135955f,
1528 0.13819660113f, 0.42532540418f, -0.894427191f, 0.9510565163f, -0.30901699437f, 0.0f, -0.27639320225f, -0.85065080835f, -0.4472135955f,
1529 0.9472135955f, -0.16245984812f, -0.27639320225f, 0.16245984812f, -0.5f, 0.85065080835f, -0.27639320225f, -0.85065080835f, -0.4472135955f,
1530 0.4472135955f, -0.52573111212f, 0.72360679775f, -0.85065080835f, 0.0f, 0.52573111212f, -0.27639320225f, -0.85065080835f, -0.4472135955f,
1531 -0.67082039325f, -0.16245984812f, 0.72360679775f, -0.68819096024f, 0.5f, -0.52573111212f, -0.27639320225f, -0.85065080835f, -0.4472135955f,
1532 -0.86180339887f, 0.42532540418f, -0.27639320225f, 0.42532540418f, 0.30901699437f, -0.85065080835f, -0.27639320225f, -0.85065080835f, -0.4472135955f,
1533 -0.36180339887f, 0.26286555606f, -0.894427191f, 0.58778525229f, 0.80901699437f, 0.0f, 0.72360679775f, -0.52573111212f, -0.4472135955f,
1534 0.4472135955f, 0.85065080835f, -0.27639320225f, 0.52573111212f, 0.0f, 0.85065080835f, 0.72360679775f, -0.52573111212f, -0.4472135955f,
1535 0.63819660113f, 0.26286555606f, 0.72360679775f, -0.26286555606f, -0.80901699437f, 0.52573111212f, 0.72360679775f, -0.52573111212f, -0.4472135955f,
1536 -0.0527864045f, -0.68819096024f, 0.72360679775f, -0.68819096024f, -0.5f, -0.52573111212f, 0.72360679775f, -0.52573111212f, -0.4472135955f,
1537 -0.67082039325f, -0.68819096024f, -0.27639320225f, -0.16245984812f, 0.5f, -0.85065080835f, 0.72360679775f, -0.52573111212f, -0.4472135955f,
1538 -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f,
1539 -0.30901699437f, 0.9510565163f, 0.0f, 0.9510565163f, 0.30901699437f, 0.0f, 0.0f, 0.0f, -1.0f,
1540 0.80901699437f, 0.58778525229f, 0.0f, 0.58778525229f, -0.80901699437f, 0.0f, 0.0f, 0.0f, -1.0f,
1541 0.80901699437f, -0.58778525229f, 0.0f, -0.58778525229f, -0.80901699437f, 0.0f, 0.0f, 0.0f, -1.0f,
1542 -0.30901699437f, -0.9510565163f, 0.0f, -0.9510565163f, 0.30901699437f, 0.0f, 0.0f, 0.0f, -1.0f
1545 for (
int k=0;k<nsym;k++) {
1547 for (
int i=0; i<3; i++) {
1548 for (
int j=0; j<3; j++) {
1549 t.
matrix[i][j] = TET[9*k + i*3 +j];
1554 ret.push_back( (*
this) * t );
1559 for (
int k=0;k<nsym;k++) {
1562 ret.push_back( (*
this) * t );
Const iterator support for the Dict object This is just a wrapper, everything is inherited from the m...
Dict is a dictionary to store <string, EMObject> pair.
bool has_key_ci(const string &key) const
Ask the Dictionary if it as a particular key in a case insensitive way.
EMObject get_ci(const string &key) const
Get the EMObject corresponding to the particular key using case insensitivity.
static const double rad2deg
static const double deg2rad
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
ObjectType get_type() const
Get the ObjectType This is an enumerated type first declared in the class EMObjectTypes.
static T * get(const string &instance_name)
Symmetry3D - A base class for 3D Symmetry objects.
virtual int get_nsym() const =0
The total number of unique symmetry operations that will be return by this object when a calling prog...
virtual Transform get_sym(const int n) const =0
Every Symmetry3D object must provide access to the full set of its symmetry operators via this functi...
static string str_to_lower(const string &s)
Return a lower case version of the argument string.
static float hypot3(int x, int y, int z)
Euclidean distance function in 3D: f(x,y,z) = sqrt(x*x + y*y + z*z);.
static void apply_precision(float &value, const float &precision)
The Vec2 is precisely the same as Vec3 except it works exclusively in 2D Note there are convenient ty...
float normalize()
Normalize the vector and return its length before the normalization.
EMData * copy() const
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....
EMData * sqrt() const
return square root of current image
#define InvalidParameterException(desc)
#define InvalidValueException(val, desc)
#define InvalidStringException(str, desc)
#define UnexpectedBehaviorException(desc)
EMData * operator*(const EMData &em, float n)