#include <symmetry.h>
Inheritance diagram for EMAN::OrientationGenerator:
Public Member Functions | |
OrientationGenerator () | |
virtual | ~OrientationGenerator () |
virtual vector< Transform > | gen_orientations (const Symmetry3D *const sym) const =0 |
generate orientations given some symmetry type | |
virtual TypeDict | get_param_types () const |
bool | add_orientation (vector< Transform > &v, const float &az, const float &alt) const |
This functions adds one or more Transform objects to the vector v, depending on the parameters stored in the dictionary (which the inheriting class may include by initializing the typedict in get_param_types by calling. | |
float | get_optimal_delta (const Symmetry3D *const sym, const int &n) const |
This function gets the optimal value of the delta (or angular spacing) of the orientations based on a desired total number of orientations (n). | |
virtual int | get_orientations_tally (const Symmetry3D *const sym, const float &delta) const =0 |
This function returns how many orientations will be generated for a given delta (angular spacing) It should general do this by simulating the function gen_orientations. | |
Protected Member Functions | |
void | get_az_max (const Symmetry3D *const sym, const float &altmax, const bool inc_mirror, const float &alt_iterator, const float &h, bool &d_odd_mirror_flag, float &azmax_adjusted) const |
Private Member Functions | |
OrientationGenerator (const OrientationGenerator &) | |
Disallow copy construction. | |
OrientationGenerator & | operator= (const OrientationGenerator &) |
Disallow assignment. |
It inherits from a factory base, making it amenable to incorporation in EMAN2 style factories. Objects that inherit from this class must write a gen_orientations function, in addition to fulfilling the responsibilities of the FactoryBase class
Definition at line 936 of file symmetry.h.
EMAN::OrientationGenerator::OrientationGenerator | ( | ) | [inline] |
virtual EMAN::OrientationGenerator::~OrientationGenerator | ( | ) | [inline, virtual] |
EMAN::OrientationGenerator::OrientationGenerator | ( | const OrientationGenerator & | ) | [private] |
Disallow copy construction.
bool OrientationGenerator::add_orientation | ( | vector< Transform > & | v, | |
const float & | az, | |||
const float & | alt | |||
) | const |
This functions adds one or more Transform objects to the vector v, depending on the parameters stored in the dictionary (which the inheriting class may include by initializing the typedict in get_param_types by calling.
TypeDict d = OrientationGenerator::get_param_types();
to initialize. If phitoo is no zero, this cause extra orientations to be included in phi (in steps of phitoo). If random_phi is true, the phi of the Transform object is randomized. This function is for internal convenience of child classes.
v | the vector to add Transform objects to | |
az | the azimuth to be used as a basis for generated Transform objects (in degrees) | |
alt | the altitude to be used as a basis for generated Transform objects (in degrees) |
Definition at line 252 of file symmetry.cpp.
References EMAN::Util::get_frand(), InvalidValueException, EMAN::FactoryBase::params, phi, EMAN::Dict::set_default(), and t.
Referenced by EMAN::OptimumOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), and EMAN::EmanOrientationGenerator::gen_orientations().
00253 { 00254 bool randphi = params.set_default("random_phi",false); 00255 float phi = 0.0f; 00256 if (randphi) phi = Util::get_frand(0.0f,359.99999f); 00257 float phitoo = params.set_default("phitoo",0.0f); 00258 if ( phitoo < 0 ) throw InvalidValueException(phitoo, "Error, if you specify phitoo is must be positive"); 00259 Dict d; 00260 d["type"] = "eman"; 00261 d["az"] = az; 00262 d["alt"] = alt; 00263 d["phi"] = phi; 00264 Transform t(d); 00265 v.push_back(t); 00266 if ( phitoo != 0 ) { 00267 if (phitoo < 0) return false; 00268 else { 00269 for ( float p = phitoo; p <= 360.0f-phitoo; p+= phitoo ) 00270 { 00271 d["phi"] = fmod(phi+p,360); 00272 Transform t(d); 00273 v.push_back(t); 00274 } 00275 } 00276 } 00277 return true; 00278 }
virtual vector<Transform> EMAN::OrientationGenerator::gen_orientations | ( | const Symmetry3D *const | sym | ) | const [pure virtual] |
generate orientations given some symmetry type
sym | the symmetry which defines the interesting asymmetric unit |
Implemented in EMAN::EmanOrientationGenerator, EMAN::RandomOrientationGenerator, EMAN::EvenOrientationGenerator, EMAN::SaffOrientationGenerator, and EMAN::OptimumOrientationGenerator.
Referenced by EMAN::OptimumOrientationGenerator::gen_orientations(), and EMAN::Symmetry3D::gen_orientations().
void OrientationGenerator::get_az_max | ( | const Symmetry3D *const | sym, | |
const float & | altmax, | |||
const bool | inc_mirror, | |||
const float & | alt_iterator, | |||
const float & | h, | |||
bool & | d_odd_mirror_flag, | |||
float & | azmax_adjusted | |||
) | const [protected] |
Definition at line 166 of file symmetry.cpp.
References EMAN::Symmetry3D::get_nsym(), EMAN::Symmetry3D::is_c_sym(), EMAN::Symmetry3D::is_d_sym(), EMAN::Symmetry3D::is_platonic_sym(), and EMAN::Symmetry3D::is_tet_sym().
Referenced by EMAN::EmanOrientationGenerator::gen_orientations(), and EMAN::EmanOrientationGenerator::get_orientations_tally().
00167 { 00168 00169 if ( sym->is_d_sym() && alt_iterator == altmax && ( (sym->get_nsym())/2 % 2 == 1 )) { 00170 if (inc_mirror) { 00171 azmax_adjusted /= 4.0f; 00172 d_odd_mirror_flag = true; 00173 } 00174 else azmax_adjusted /= 2.0f; 00175 } 00176 else if (sym->is_d_sym() && alt_iterator == altmax && ( (sym->get_nsym())/2 % 2 == 0 ) && inc_mirror) { 00177 azmax_adjusted /= 2.0f; 00178 } 00179 // if this is odd c symmetry, and we're at the equator, and we're excluding the mirror then 00180 // half the equator is redundant (it is the mirror of the other half) 00181 else if (sym->is_c_sym() && !inc_mirror && alt_iterator == altmax && (sym->get_nsym() % 2 == 1 ) ){ 00182 azmax_adjusted /= 2.0f; 00183 } 00184 // at the azimuthal boundary in c symmetry and tetrahedral symmetry we have come 00185 // full circle, we must not include it 00186 else if (sym->is_c_sym() || sym->is_tet_sym() ) { 00187 azmax_adjusted -= h/4.0f; 00188 } 00189 // If we're including the mirror then in d and icos and oct symmetry the azimuthal 00190 // boundary represents coming full circle, so must be careful to exclude it 00191 else if (inc_mirror && ( sym->is_d_sym() || sym->is_platonic_sym() ) ) { 00192 azmax_adjusted -= h/4.0f; 00193 } 00194 // else do nothing - this means that we're including the great arc traversing 00195 // the full range of permissable altitude angles at azmax. 00196 // This happens in d symmetry, and in the icos and oct symmetries, when the mirror 00197 // portion of the asymmetric unit is being excluded 00198 00199 }
float OrientationGenerator::get_optimal_delta | ( | const Symmetry3D *const | sym, | |
const int & | n | |||
) | const |
This function gets the optimal value of the delta (or angular spacing) of the orientations based on a desired total number of orientations (n).
It does this using a bifurcation strategy, calling get_orientations_tally (which must be supplied by the child class) using the next best guess etc. The solution may not exist (simply because the orientation generation strategy does not contain it), so a best guess may be returned.
The inheriting class must supply the get_orientations_tally function, which returns the number of orientations generated (an int), for a given delta.
sym | the symmetry which defines the interesting asymmetric unit | |
n | the desired number of orientations |
Definition at line 215 of file symmetry.cpp.
References get_orientations_tally().
Referenced by EMAN::OptimumOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), and EMAN::EmanOrientationGenerator::gen_orientations().
00216 { 00217 00218 // float delta_soln = 360.0f/sym->get_max_csym(); 00219 float delta_soln = 180.0f; 00220 float delta_upper_bound = delta_soln; 00221 float delta_lower_bound = 0.0f; 00222 00223 int prev_tally = -1; 00224 // This is an example of a divide and conquer approach, the possible values of delta are searched 00225 // like a binary tree 00226 00227 bool soln_found = false; 00228 00229 while ( soln_found == false ) { 00230 int tally = get_orientations_tally(sym,delta_soln); 00231 if ( tally == n ) soln_found = true; 00232 else if ( (delta_upper_bound - delta_lower_bound) < 0.0001 ) { 00233 // If this is the case, the requested number of projections is practically infeasible 00234 // in which case just return the nearest guess 00235 soln_found = true; 00236 delta_soln = (delta_upper_bound+delta_lower_bound)/2.0f; 00237 } 00238 else if (tally < n) { 00239 delta_upper_bound = delta_soln; 00240 delta_soln = delta_soln - (delta_soln-delta_lower_bound)/2.0f; 00241 } 00242 else /* tally > n*/{ 00243 delta_lower_bound = delta_soln; 00244 delta_soln = delta_soln + (delta_upper_bound-delta_soln)/2.0f; 00245 } 00246 prev_tally = tally; 00247 } 00248 00249 return delta_soln; 00250 }
virtual int EMAN::OrientationGenerator::get_orientations_tally | ( | const Symmetry3D *const | sym, | |
const float & | delta | |||
) | const [pure virtual] |
This function returns how many orientations will be generated for a given delta (angular spacing) It should general do this by simulating the function gen_orientations.
sym | the symmetry which defines the interesting asymmetric unit | |
delta | the desired angular spacing of the orientations |
Implemented in EMAN::EmanOrientationGenerator, EMAN::RandomOrientationGenerator, EMAN::EvenOrientationGenerator, EMAN::SaffOrientationGenerator, and EMAN::OptimumOrientationGenerator.
Referenced by get_optimal_delta(), and EMAN::OptimumOrientationGenerator::get_orientations_tally().
virtual TypeDict EMAN::OrientationGenerator::get_param_types | ( | ) | const [inline, virtual] |
Implements EMAN::FactoryBase.
Reimplemented in EMAN::EmanOrientationGenerator, EMAN::RandomOrientationGenerator, EMAN::EvenOrientationGenerator, EMAN::SaffOrientationGenerator, and EMAN::OptimumOrientationGenerator.
Definition at line 948 of file symmetry.h.
References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
Referenced by EMAN::OptimumOrientationGenerator::get_param_types(), EMAN::SaffOrientationGenerator::get_param_types(), EMAN::EvenOrientationGenerator::get_param_types(), and EMAN::EmanOrientationGenerator::get_param_types().
00949 { 00950 TypeDict d; 00951 d.put("phitoo", EMObject::FLOAT, "Specifying a non zero value for this argument will cause phi rotations to be included. The value specified is the angular spacing of the phi rotations in degrees. The default for this value is 0, causing no extra phi rotations to be included."); 00952 d.put("random_phi", EMObject::BOOL, "Causes the orientations to have a random phi. This occurs before the phitoo parameter is considered."); 00953 return d; 00954 }
OrientationGenerator& EMAN::OrientationGenerator::operator= | ( | const OrientationGenerator & | ) | [private] |
Disallow assignment.