#include <symmetry.h>
Inheritance diagram for EMAN::OptimumOrientationGenerator:


Public Member Functions | |
| OptimumOrientationGenerator () | |
| virtual | ~OptimumOrientationGenerator () |
| virtual string | get_name () const |
| Return "opt". | |
| virtual string | get_desc () const |
| Get a description. | |
| virtual TypeDict | get_param_types () const |
| Get a dictionary containing the permissable parameters of this class. | |
| virtual vector< Transform > | gen_orientations (const Symmetry3D *const sym) const |
| Generate Saff orientations in the asymmetric unit of the symmetry. | |
Static Public Member Functions | |
| OrientationGenerator * | NEW () |
| Factory support function NEW. | |
Static Public Attributes | |
| const string | NAME = "opt" |
| The name of this class - used to access it from factories etc. Should be "icos". | |
Private Member Functions | |
| OptimumOrientationGenerator (const OptimumOrientationGenerator &) | |
| Disallow copy construction. | |
| OptimumOrientationGenerator & | operator= (const OptimumOrientationGenerator &) |
| Disallow assignment. | |
| virtual int | get_orientations_tally (const Symmetry3D *const sym, const float &delta) const |
| This function returns how many orientations will be generated for a given delta (angular spacing) It does this by simulated gen_orientations. | |
| vector< Vec3f > | optimize_distances (const vector< Transform > &v) const |
| Optimize the distances in separating points on the unit sphere, as described by the the rotations in Transform objects. | |
Optimally distributes points on a unit sphere, then slices out a correctly sized asymmetric unit, depending on the symmetry type. The approach relies on an initial distribution of points on the unit sphere, which may be generated using any of the other orientation generators. By default, the Saff orientation generator is used.
Definition at line 1306 of file symmetry.h.
|
|
Definition at line 1309 of file symmetry.h. 01309 {}
|
|
|
Definition at line 1310 of file symmetry.h. 01310 {}
|
|
|
Disallow copy construction.
|
|
|
Generate Saff orientations in the asymmetric unit of the symmetry.
Implements EMAN::OrientationGenerator. Definition at line 731 of file symmetry.cpp. References EMAN::OrientationGenerator::add_orientation(), angles, EMAN::FactoryBase::copy_relevant_params(), EMAN::OrientationGenerator::gen_orientations(), EMAN::OrientationGenerator::get_optimal_delta(), InvalidParameterException, EMAN::Symmetry3D::is_in_asym_unit(), optimize_distances(), EMAN::Dict::set_default(), and EMAN::FactoryBase::set_params(). 00732 {
00733 float delta = params.set_default("delta", 0.0f);
00734 int n = params.set_default("n", 0);
00735
00736 bool inc_mirror = params.set_default("inc_mirror",false);
00737
00738 if ( delta <= 0 && n <= 0 ) throw InvalidParameterException("Error, you must specify a positive non-zero delta or n");
00739 if ( delta > 0 && n > 0 ) throw InvalidParameterException("Error, the delta and the n arguments are mutually exclusive");
00740
00741 string generatorname = params.set_default("use","saff");
00742
00743 if ( n > 0 && generatorname != RandomOrientationGenerator::NAME ) {
00744 params["delta"] = get_optimal_delta(sym,n);
00745 params["n"] = (int)0;
00746 }
00747
00748 // Force the orientation generator to include the mirror - this is because
00749 // We will enventually use it to generate orientations over the intire sphere
00750 // which is C1 symmetry, with the inc_mirror flag set to true
00751 params["inc_mirror"] = true;
00752 OrientationGenerator* g = Factory < OrientationGenerator >::get(generatorname);
00753 g->set_params(copy_relevant_params(g));
00754
00755
00756 // get the starting orientation distribution
00757 CSym* unit_sphere = new CSym();
00758 Dict nsym; nsym["nsym"] = 1; unit_sphere->set_params(nsym);
00759
00760 vector<Transform> unitsphereorientations = g->gen_orientations(unit_sphere);
00761 delete g; g = 0;
00762 delete unit_sphere; unit_sphere = 0;
00763
00764 vector<Vec3f> angles = optimize_distances(unitsphereorientations);
00765
00766 vector<Transform> ret;
00767 for (vector<Vec3f>::const_iterator it = angles.begin(); it != angles.end(); ++it ) {
00768 if ( sym->is_in_asym_unit((*it)[1],(*it)[0],inc_mirror) ) {
00769 add_orientation(ret,(*it)[0],(*it)[1]);
00770 }
00771 }
00772
00773 // reset the params to what they were before they were acted upon by this class
00774 params["inc_mirror"] = inc_mirror;
00775 params["delta"] = delta;
00776 params["n"] = n;
00777
00778 return ret;
00779 }
|
|
|
Get a description.
Implements EMAN::FactoryBase. Definition at line 1328 of file symmetry.h. 01328 { return "Generate optimally distributed orientations within an asymmetric using a basic optimization technique"; }
|
|
|
Return "opt".
Implements EMAN::FactoryBase. Definition at line 1323 of file symmetry.h. 01323 { return NAME; }
|
|
||||||||||||
|
This function returns how many orientations will be generated for a given delta (angular spacing) It does this by simulated gen_orientations.
Implements EMAN::OrientationGenerator. Definition at line 716 of file symmetry.cpp. References EMAN::OrientationGenerator::get_orientations_tally(), and EMAN::Dict::set_default(). 00717 {
00718 string deltaoptname = params.set_default("use","saff");
00719 Dict a;
00720 a["inc_mirror"] = (bool)params.set_default("inc_mirror",false);
00721 OrientationGenerator *g = Factory < OrientationGenerator >::get(deltaoptname,a);
00722 if (g) {
00723 int tally = g->get_orientations_tally(sym,delta);
00724 delete g;
00725 g = 0;
00726 return tally;
00727 }
00728 else throw;
00729 }
|
|
|
Get a dictionary containing the permissable parameters of this class.
Reimplemented from EMAN::OrientationGenerator. Definition at line 1334 of file symmetry.h. References EMAN::TypeDict::put(). 01335 {
01336 TypeDict d = OrientationGenerator::get_param_types();
01337 d.put("n", EMObject::INT, "The number of orientations to generate. This option is mutually exclusively of the delta argument.Will attempt to get as close to the number specified as possible.");
01338 d.put("inc_mirror", EMObject::BOOL, "Indicates whether or not to include the mirror portion of the asymmetric unit. Default is false.");
01339 d.put("delta", EMObject::FLOAT, "The angular separation of orientations in degrees. This option is mutually exclusively of the n argument.");
01340 d.put("use", EMObject::STRING, "The orientation generation technique used to generate the initial distribution on the unit sphere.");
01341 return d;
01342 }
|
|
|
Factory support function NEW.
Definition at line 1315 of file symmetry.h. 01316 {
01317 return new OptimumOrientationGenerator();
01318 }
|
|
|
Disallow assignment.
|
|
|
Optimize the distances in separating points on the unit sphere, as described by the the rotations in Transform objects.
Definition at line 781 of file symmetry.cpp. References EMAN::Vec3< Type >::end(), EMAN::Dict::end(), EMAN::Vec3< Type >::normalize(), v, and EMAN::Vec3f. Referenced by gen_orientations(). 00782 {
00783 vector<Vec3f> points;
00784
00785 for (vector<Transform>::const_iterator it = v.begin(); it != v.end(); ++it ) {
00786 points.push_back(Vec3f(0,0,1)*(*it));
00787 }
00788
00789 if ( points.size() >= 2 ) {
00790 int max_it = 100;
00791 float percentage = 0.01f;
00792
00793 for ( int i = 0; i < max_it; ++i ){
00794 unsigned int p1 = 0;
00795 unsigned int p2 = 1;
00796
00797 float distsquared = (points[p1]-points[p2]).squared_length();
00798
00799 // Find the nearest points
00800 for(unsigned int j = 0; j < points.size(); ++j) {
00801 for(unsigned int k = j+1; k < points.size(); ++k) {
00802 float d = (points[j]-points[k]).squared_length();
00803 if ( d < distsquared ) {
00804 distsquared = d;
00805 p1 = j;
00806 p2 = k;
00807 }
00808 }
00809 }
00810
00811 // Move them apart by a small fraction
00812 Vec3f delta = percentage*(points[p2]-points[p1]);
00813
00814 points[p2] += delta;
00815 points[p2].normalize();
00816 points[p1] -= delta;
00817 points[p1].normalize();
00818 }
00819 }
00820
00821 vector<Vec3f> ret;
00822 for (vector<Vec3f>::const_iterator it = points.begin(); it != points.end(); ++it ) {
00823 float altitude = (float)(EMConsts::rad2deg*acos((*it)[2]));
00824 float azimuth = (float)(EMConsts::rad2deg*atan2((*it)[1],(*it)[0]));
00825 ret.push_back(Vec3f(90.0f+azimuth,altitude,0));
00826 }
00827
00828 return ret;
00829 }
|
|
|
The name of this class - used to access it from factories etc. Should be "icos".
Definition at line 50 of file symmetry.cpp. |
1.3.9.1