#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 937 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 262 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().
00263 { 00264 bool randphi = params.set_default("random_phi",false); 00265 float phi = 0.0f; 00266 if (randphi) phi = Util::get_frand(0.0f,359.99999f); 00267 float phitoo = params.set_default("phitoo",0.0f); 00268 if ( phitoo < 0 ) throw InvalidValueException(phitoo, "Error, if you specify phitoo is must be positive"); 00269 Dict d; 00270 d["type"] = "eman"; 00271 d["az"] = az; 00272 d["alt"] = alt; 00273 d["phi"] = phi; 00274 Transform t(d); 00275 v.push_back(t); 00276 if ( phitoo != 0 ) { 00277 if (phitoo < 0) return false; 00278 else { 00279 for ( float p = phitoo; p <= 360.0f-phitoo; p+= phitoo ) 00280 { 00281 d["phi"] = fmod(phi+p,360); 00282 Transform t(d); 00283 v.push_back(t); 00284 } 00285 } 00286 } 00287 return true; 00288 }
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 176 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().
00177 { 00178 00179 if ( sym->is_d_sym() && alt_iterator == altmax && ( (sym->get_nsym())/2 % 2 == 1 )) { 00180 if (inc_mirror) { 00181 azmax_adjusted /= 4.0f; 00182 d_odd_mirror_flag = true; 00183 } 00184 else azmax_adjusted /= 2.0f; 00185 } 00186 else if (sym->is_d_sym() && alt_iterator == altmax && ( (sym->get_nsym())/2 % 2 == 0 ) && inc_mirror) { 00187 azmax_adjusted /= 2.0f; 00188 } 00189 // if this is odd c symmetry, and we're at the equator, and we're excluding the mirror then 00190 // half the equator is redundant (it is the mirror of the other half) 00191 else if (sym->is_c_sym() && !inc_mirror && alt_iterator == altmax && (sym->get_nsym() % 2 == 1 ) ){ 00192 azmax_adjusted /= 2.0f; 00193 } 00194 // at the azimuthal boundary in c symmetry and tetrahedral symmetry we have come 00195 // full circle, we must not include it 00196 else if (sym->is_c_sym() || sym->is_tet_sym() ) { 00197 azmax_adjusted -= h/4.0f; 00198 } 00199 // If we're including the mirror then in d and icos and oct symmetry the azimuthal 00200 // boundary represents coming full circle, so must be careful to exclude it 00201 else if (inc_mirror && ( sym->is_d_sym() || sym->is_platonic_sym() ) ) { 00202 azmax_adjusted -= h/4.0f; 00203 } 00204 // else do nothing - this means that we're including the great arc traversing 00205 // the full range of permissable altitude angles at azmax. 00206 // This happens in d symmetry, and in the icos and oct symmetries, when the mirror 00207 // portion of the asymmetric unit is being excluded 00208 00209 }
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 225 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().
00226 { 00227 00228 // float delta_soln = 360.0f/sym->get_max_csym(); 00229 float delta_soln = 180.0f; 00230 float delta_upper_bound = delta_soln; 00231 float delta_lower_bound = 0.0f; 00232 00233 int prev_tally = -1; 00234 // This is an example of a divide and conquer approach, the possible values of delta are searched 00235 // like a binary tree 00236 00237 bool soln_found = false; 00238 00239 while ( soln_found == false ) { 00240 int tally = get_orientations_tally(sym,delta_soln); 00241 if ( tally == n ) soln_found = true; 00242 else if ( (delta_upper_bound - delta_lower_bound) < 0.0001 ) { 00243 // If this is the case, the requested number of projections is practically infeasible 00244 // in which case just return the nearest guess 00245 soln_found = true; 00246 delta_soln = (delta_upper_bound+delta_lower_bound)/2.0f; 00247 } 00248 else if (tally < n) { 00249 delta_upper_bound = delta_soln; 00250 delta_soln = delta_soln - (delta_soln-delta_lower_bound)/2.0f; 00251 } 00252 else /* tally > n*/{ 00253 delta_lower_bound = delta_soln; 00254 delta_soln = delta_soln + (delta_upper_bound-delta_soln)/2.0f; 00255 } 00256 prev_tally = tally; 00257 } 00258 00259 return delta_soln; 00260 }
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 949 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().
00950 { 00951 TypeDict d; 00952 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."); 00953 d.put("random_phi", EMObject::BOOL, "Causes the orientations to have a random phi. This occurs before the phitoo parameter is considered."); 00954 return d; 00955 }
OrientationGenerator& EMAN::OrientationGenerator::operator= | ( | const OrientationGenerator & | ) | [private] |
Disallow assignment.