41 int i, theorder, helix_dyad = 1;
42 double helix_rise = 1, helix_angle =
M_PI;
43 Matrix3 mat(0,-1,0,1,0,0,0,0,1);
51 cout << endl <<
"Getting symmetry operators for " << sym->
label << endl;
53 if ( sym->
label[0] ==
'C' ) {
54 if ( sym->
label ==
"Cs" ) theorder = 1;
57 sym->
point = 100 + theorder;
62 }
else if ( sym->
label[0] ==
'D' ) {
65 sym->
point = 200 + theorder;
73 }
else if ( sym->
label[0] ==
'T' ) {
93 }
else if ( sym->
label[0] ==
'O' ) {
124 }
else if ( sym->
label[0] ==
'I' ) {
164 for ( i=0; i<sym->
n; i++ )
166 }
else if ( sym->
label[0] ==
'H' ) {
167 sscanf(sym->
label.
c_str(),
"H%lf,%lf,%d", &helix_rise, &helix_angle, &helix_dyad);
169 if ( helix_dyad == 2 ) sym->
n = 2;
175 if ( helix_dyad == 2 ) {
181 error_show(
"Error in init_point_group_symmetry", __FILE__, __LINE__);
182 cerr <<
"This is not a valid symmetry designation: " << sym->
label << endl;
187 for ( i=0; i<sym->
n; i++ )
191 cout <<
"DEBUG init_point_group_symmetry: label=" << sym->
label << endl;
209 if ( !sym )
return 0;
211 if ( sym->
n > 0 && sym->
op )
delete[] sym->
op;
233 cout <<
"DEBUG symmetry_clean_pointgroup: symmetry_string=" << symmetry_string << endl;
235 if ( symmetry_string.
length() < 1 )
return clean_sym_str;
238 clean_sym_str = symmetry_string.
no_space();
241 if ( isdigit(clean_sym_str[0]) ) {
244 clean_sym_str =
"I90";
245 else if ( clean_sym_str.
contains(
"532") )
247 else if ( clean_sym_str.
contains(
"432") )
249 else if ( clean_sym_str.
contains(
"23") )
251 else if ( j > 1 && clean_sym_str[1] == 2 )
252 clean_sym_str =
Bstring(j,
"D%d");
254 clean_sym_str =
Bstring(j,
"C%d");
256 clean_sym_str =
"C1";
259 clean_sym_str[0] = toupper(clean_sym_str[0]);
262 cout <<
"DEBUG symmetry_clean_pointgroup: clean_sym_str=" << clean_sym_str << endl;
264 return clean_sym_str;
281 int dyad_axis,
int cyclic,
double seam_shift)
283 string label =
"H" + to_string(helix_rise);
284 label +=
"," + to_string(helix_angle*180.0/
M_PI);
285 label +=
"," + to_string(dyad_axis);
286 label +=
"," + to_string(cyclic);
287 label +=
"," + to_string(seam_shift);
305 for ( i=0; i<sym->
n; i++ ) order *= sym->
op[i].
order;
319 if ( sym->
point < 200 ) {
322 }
else if ( sym->
point < 300 ) {
323 ref[0] = sin(
M_PI/4);
324 ref[2] = cos(
M_PI/4);
325 }
else if ( sym->
point == 320 ) {
326 ref[0] = sin(
M_PI/4);
327 ref[2] = cos(
M_PI/4);
328 }
else if ( sym->
point == 432 ) {
329 ref[0] = sin(
M_PI/8);
330 ref[2] = cos(
M_PI/8);
331 }
else if ( sym->
point == 532 ) {
332 ref[0] = sin(
M_PI/18);
333 ref[2] = cos(
M_PI/18);
334 }
else if ( sym->
point == 600 ) {
349 double sqrt2(sqrt(2));
354 if ( sym->
point < 200 ) {
355 }
else if ( sym->
point < 300 ) {
358 }
else if ( sym->
point < 400 ) {
360 }
else if ( sym->
point < 500 ) {
385 cout <<
"DEBUG symmetry_get_axes: label=" << sym->
label << endl;
387 if ( sym->
point < 300 ) {
389 }
else if ( sym->
point < 400 ) {
390 axis1[0] = axis1[1] = axis1[2] = 1/sqrt(3.0);
391 }
else if ( sym->
point < 500 ) {
395 axis1[0] = axis1[1] = axis1[2] = 1/sqrt(3.0);
397 cerr <<
"Error: The symmetry designation must be either O-3 or O-4!" << endl;
400 }
else if ( sym->
point < 600 ) {
402 axis1[1] = 1/sqrt(2+
GOLDEN);
403 axis1[2] = 1/sqrt(3-
GOLDEN);
405 axis1[0] = axis1[1] = axis1[2] = 1/sqrt(3.0);
407 cerr <<
"Error: The symmetry designation must be either I-3 or I-5!" << endl;
412 vector<Vector3<double>> axis;
414 axis.push_back(axis1);
416 for ( i=0, k=1, ns=1; i<sym->
n; i++ ) {
417 for ( j=1; j<sym->
op[i].
order; j++ ) {
419 for ( m=0; m<ns; m++, k++ ) axis.push_back(mat * axis[m]);
425 for ( i=0; i<axis.size(); i++ )
426 cout <<
"Axis[" << i+1 <<
"]: " << axis[i] << endl;
456 cout <<
"Getting all the symmetric views:" << endl;
457 cout <<
"Symmetry: " << sym->
label << endl;
458 cout <<
"View: " << asu_view << endl;
462 for ( i=0; i<sym->
n; i++ ) {
463 for ( j=1; j<sym->
op[i].
order; j++ ) {
466 for ( k=0, v=view; k<nview; k++, v=v->
next ) {
467 qv = v->quaternion();
473 cout <<
"DEBUG symmetry_get_all_views: " << vn << endl;
480 for ( i=1, v=view; v; v=v->
next, i++ )
481 cout <<
"View " << i <<
": " <<
tab << *v << endl;
493 for ( v=views; v; v=v->
next ) {
495 if ( vc ) vc->
next = vt;
520 for ( i=0, ns=1; i<sym->
n; i++ ) ns *= sym->
op[i].
order;
522 for ( i=0; i<ns; i++ ) mat[i] =
Matrix3(1);
525 cout <<
"Getting all the symmetric matrices:" << endl;
526 cout <<
"Symmetry: " << sym->
label << endl;
529 for ( i=0, n=ns=1; i<sym->
n; i++ ) {
530 for ( j=1; j<sym->
op[i].
order; j++ ) {
533 for ( k=0; k<ns; k++ )
534 mat[n++] = mt*mat[k];
540 for ( i=0; i<ns; i++ ) {
541 cout <<
"Matrix " << i+1 <<
":" << endl;
566 if ( theta_step <
M_PI/1800 ) theta_step =
M_PI/180;
567 if ( phi_step <
M_PI/1800 ) phi_step =
M_PI/180;
575 char full = flag & 1;
576 char inplanerot = !(flag & 2);
577 int i, j, n = 0, ntheta, nphi, nrphi, istart;
578 double theta, phi, max_theta, theta_start, phi_start, phi_end;
581 cout <<
"DEBUG asymmetric_unit_views: flag=" << flag <<
" full=" << full << endl;
583 max_theta =
M_PI_2 + 1e-6;
584 ntheta = (int) (max_theta/theta_step + 0.5);
585 nphi = (int) (
M_PI*2.0/(sym->
op[0].
order*phi_step) + 0.5);
587 if ( sym->
point < 200 ) {
589 max_theta =
M_PI + 1e-6;
592 }
else if ( sym->
point == 432 ) {
593 max_theta =
M_PI_4 + 1e-6;
594 ntheta = (int) (max_theta/theta_step + 0.5);
595 }
else if ( sym->
point == 532 ) {
596 max_theta = atan(1/(
GOLDEN+1)) + 1e-6;
597 ntheta = (int) (max_theta/theta_step + 2.5);
598 nphi = (int) (atan(1/
GOLDEN)/phi_step + 1.5);
599 }
else if ( sym->
point == 600 ) {
601 nphi = (int) (
M_PI*2.0/phi_step + 1);
604 if ( ntheta < 1 ) ntheta = 1;
605 if ( nphi < 1 ) nphi = 1;
609 cout <<
"Getting all the asymmetric unit views for symmetry " << sym->
label << endl;
611 cout <<
"Getting half the asymmetric unit views for symmetry " << sym->
label << endl;
612 cout <<
"Theta and phi step sizes: " <<
613 theta_step*180/
M_PI <<
" " << phi_step*180/
M_PI <<
" degrees" << endl;
614 cout <<
"Theta and phi steps: " << ntheta <<
" " << nphi << endl;
618 cout <<
"DEBUG asymmetric_unit_views: Views allocated = " << 2*ntheta*nphi << endl;
623 if ( sym->
point < 500 ) {
628 cout <<
"DEBUG asymmetric_unit_views: Adding the top view" << endl;
632 for ( theta=theta_step; theta<=max_theta; theta+=theta_step ) {
633 nrphi = (int) (nphi*sin(theta)/2 + 0.5);
638 if ( sym->
point < 102 ) nrphi -= 1;
640 for ( j=istart; j<=nrphi; j++ ) {
642 *v =
View(sin(theta)*cos(j*phi), sin(theta)*sin(j*phi), cos(theta), 0);
643 if ( inplanerot ) (*v)[3] = j*phi;
647 if ( full && v->
z() > -0.999999 ) {
652 }
else if ( sym->
point > 200 && sym->
point < 300 ) {
653 for ( theta=theta_step; theta<=max_theta; theta+=theta_step ) {
654 nrphi = (int) (nphi*sin(theta)/2 + 0.5);
656 if ( nrphi ) phi =
M_PI*1.0/(sym->
op[0].
order*nrphi);
658 if ( full ) istart = -nrphi;
659 for ( j=istart; j<=nrphi; j++ ) {
661 *v =
View(sin(theta)*cos(j*phi), sin(theta)*sin(j*phi), cos(theta), 0);
662 if ( inplanerot ) (*v)[3] = j*phi;
666 }
else if ( sym->
point == 320 ) {
667 for ( theta=theta_step; theta<=max_theta; theta+=theta_step ) {
671 if ( full ) phi_start = -theta;
672 if ( full && theta >
M_PI_4 ) phi_start = theta -
M_PI_2;
673 for ( phi=phi_start; phi<=phi_end; phi+=phi_step ) {
675 *v =
View(sin(theta), sin(phi), cos(theta), 0);
679 }
else if ( sym->
point == 432 ) {
680 for ( theta=theta_step; theta<=max_theta; theta+=theta_step ) {
682 if ( full ) phi_start = -theta;
683 for ( phi=phi_start; phi<=theta; phi+=phi_step ) {
685 *v =
View(sin(theta), sin(phi), cos(theta), 0);
689 }
else if ( sym->
point == 532 ) {
692 if ( full ) theta_start = -ntheta*theta_step;
693 for ( theta=theta_start; theta<=max_theta; theta+=theta_step ) {
694 for ( phi=0; phi<=
GOLDEN*(max_theta - fabs(theta)); phi+=phi_step ) {
696 *v =
View(tan(phi), tan(theta), cos(theta), 0);
701 for ( theta=0; theta<=max_theta; theta+=theta_step ) {
702 nrphi = (int) (
GOLDEN*(max_theta - theta)/phi_step);
704 if ( full ) phi_start = -nrphi*phi_step;
705 for ( phi=phi_start; phi<=
GOLDEN*(max_theta - theta); phi+=phi_step ) {
707 *v =
View(tan(theta), tan(phi), cos(theta), 0);
712 }
else if ( sym->
point == 600 ) {
713 for ( phi = 0; phi <
TWOPI-0.001; phi += phi_step ) {
715 *v =
View(cos(phi), sin(phi), 0, 0);
716 if ( inplanerot ) (*v)[3] = phi;
720 cerr <<
"Warning: Symmetry type " << sym->
point <<
" not supported!" << endl;
724 cout <<
"Views generated: " << n << endl << endl;
729 cout <<
"View\tx\ty\tz\ta" << endl;
730 for ( v=view, i=1; v; v = v->
next, i++ )
731 cout << i <<
tab << *v << endl;
765 if ( side_ang < 0 ) side_ang = -side_ang;
766 if ( theta_step <= 0 ) {
768 theta_step =
M_PI/180;
770 side_ang = theta_step*floor(side_ang/theta_step);
772 if ( phi_step <= 0 ) phi_step =
M_PI_2;
775 if ( order < 1 ) order = 1;
784 cout <<
"Getting all the asymmetric unit side views for symmetry " << sym->
label << endl;
785 cout <<
"Step size around equator: " << phi_step*180.0/
M_PI <<
" degrees" << endl;
787 cout <<
"Deviation from equator: " << side_ang*180.0/
M_PI <<
" degrees" << endl;
788 cout <<
"Step size from equator: " << theta_step*180.0/
M_PI <<
" degrees" << endl;
792 for ( n = 0, phi = -
M_PI*1.0L/order; phi <
M_PI*1.0L/order; phi += phi_step ) {
793 for ( theta =
M_PI_2 - side_ang; theta <=
M_PI_2 + side_ang; theta += theta_step ) {
795 euler =
Euler(0, theta, phi);
803 cout <<
"Number of views: " << n << endl << endl;
830 if ( sym->
point < 102 )
return 0;
834 for ( v=view; v; v=v->
next )
852 if ( sym->
point < 102 )
return theview;
853 if ( sym->
point >= 600 )
return theview;
855 View* v, bv(theview), tv;
862 for ( v=view; v && !found; v=v->
next )
863 if ( ( v->
x() - tol >= 0 ) || ( v->
x() + tol >= 0 && v->
y() >= 0 ) ) {
864 tv.
x(0); tv.
y(0); tv.
z(0);
865 if ( sym->
point < 200 ) {
869 if ( fabs(v->
y()) <= v->
x()*lim + tol )
872 }
else if ( sym->
point > 200 && sym->
point < 300 ) {
873 if ( v->
z() + tol >= 0 ) {
877 if ( fabs(v->
y()) <= v->
x()*lim + tol ) tv = *v;
880 }
else if ( sym->
point == 320 ) {
881 if ( fabs(v->
y()) <= v->
x() + tol && fabs(v->
y()) <= v->
z() + tol )
883 }
else if ( sym->
point == 432 ) {
884 if ( fabs(v->
y()) <= v->
x() + tol && v->
x() <= v->
z() + tol )
886 }
else if ( sym->
point == 532 ) {
888 if ( v->
z() + tol >= 0 && fabs(v->
y()) <= (v->
z()/
GOLDEN - v->
x())/
GOLDEN + tol )
891 if ( v->
z() + tol >= 0 && fabs(v->
y()) <= v->
z()/
GOLDEN - v->
x()*
GOLDEN + tol )
894 }
else if ( sym->
point >= 600 ) {
904 cerr <<
"ASU view not found: " << theview << endl;
909 cout <<
"Old view:\t" << theview << endl;
910 cout <<
"New view:\t" << bv << endl;
916 bv.next = theview.
next;
935 if ( sym->
point < 102 )
return view;
936 if ( sym->
point >= 600 )
return view;
939 cout <<
"DEBUG find_closest_symmetric_view: " << sym->
label << endl;
945 for ( v=viewsym; v; v=v->
next ) {
947 r = v->
angle(view_ref);
970 if ( sym->
point < 200 ) {
973 }
else if ( sym->
point < 300 ) {
975 }
else if ( sym->
point == 320 ) {
976 ref[0] = ref[1] = cos(
M_PI/8.0);
977 ref[2] = sin(
M_PI/8.0);
978 }
else if ( sym->
point == 432 ) {
979 ref[0] = cos(
M_PI/3.0);
980 ref[2] = sin(
M_PI/3.0);
981 }
else if ( sym->
point == 532 ) {
989 }
else if ( sym->
point == 600 ) {
1014 for ( j=0, v=view; v && j<i; v=v->
next, j++ ) ;
1032 double a, amin =
TWOPI;
1037 for ( i=0, v=rv; v; v=v->
next, i++ ) {
1038 a = theview.
angle(*v);
1067 float* mat =
new float[nsym*12];
1068 for ( i=0; i<nsym*12; i++ ) mat[i] = 0;
1071 for ( i=0; i<nsym; i++ ) {
1073 cout <<
"DEBUG sym_matrices_from_text_list: Symmetry operator " << i+1 <<
":" << endl;
1075 for ( j=0; j<3; j++ ) {
1077 memset(op, 0, line_len);
1078 while ( k<line_len && symop[i*line_len+k] !=
',' ) {
1079 op[l] = tolower(symop[i*line_len+k]);
1084 if ( strstr(op,
"-x") ) mat[i*12+4*j] = -1;
1085 else if ( strstr(op,
"x") ) mat[i*12+4*j] = 1;
1086 if ( strstr(op,
"-y") ) mat[i*12+4*j+1] = -1;
1087 else if ( strstr(op,
"y") ) mat[i*12+4*j+1] = 1;
1088 if ( strstr(op,
"-z") ) mat[i*12+4*j+2] = -1;
1089 else if ( strstr(op,
"z") ) mat[i*12+4*j+2] = 1;
1090 if ( strstr(op,
"1/2") ) mat[i*12+4*j+3] = 0.5;
1091 if ( strstr(op,
"1/4") ) mat[i*12+4*j+3] = 0.25;
1092 if ( strstr(op,
"3/4") ) mat[i*12+4*j+3] = 0.75;
1093 if ( strstr(op,
"1/3") ) mat[i*12+4*j+3] = 1.0/3.0;
1094 if ( strstr(op,
"2/3") ) mat[i*12+4*j+3] = 2.0/3.0;
1095 if ( strstr(op,
"1/6") ) mat[i*12+4*j+3] = 1.0/6.0;
1096 if ( strstr(op,
"5/6") ) mat[i*12+4*j+3] = 5.0/6.0;
1099 cout <<
"|" << mat[i*12+4*j] <<
" " << mat[i*12+4*j+1]
1100 <<
" " << mat[i*12+4*j+2] <<
"| |" << mat[i*12+4*j+3] <<
"|" << endl;
1115 for ( i=0; i<sym->
n; i++ ) nview *= sym->
op[i].
order;
1122 cout <<
"\nSymmetry matrices (" << nview <<
"):" << endl;
1123 for ( i=1, v=view; v; i++, v=v->
next ) {
1125 cout <<
"Matrix " << i <<
":" << endl;
1145 for ( i=0; i<sym->
n; i++ ) {
1147 cout <<
"Operation " << i <<
":" << endl;
1148 cout <<
"Axis and angle: " << sym->
op[i].
axis <<
" " << 360.0/sym->
op[i].
order << endl;
1149 cout << mat << endl;
1169 for ( i=0; i<nsym; i++ ) {
1170 for ( j=0; j<3; j++ ) {
1171 cout <<
"BIOMT" << j+1 << setw(4) << i+1 << setprecision(6);
1172 for ( k=0; k<3; k++ )
1173 cout << setw(10) << mat[i][j][k];
1174 cout << setprecision(6) << setw(15) << t << endl;