EMAN2
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
EMAN::OrientationGenerator Class Referenceabstract

An orientation generator is a kind of class that will generate orientations for a given symmetry If one needs to generate orientations in the unit sphere, one simply uses the C1 symmetry. More...

#include <symmetry.h>

Inheritance diagram for EMAN::OrientationGenerator:
Inheritance graph
[legend]
Collaboration diagram for EMAN::OrientationGenerator:
Collaboration graph
[legend]

Public Member Functions

 OrientationGenerator ()
 
virtual ~OrientationGenerator ()
 
virtual vector< Transformgen_orientations (const Symmetry3D *const sym) const =0
 generate orientations given some symmetry type More...
 
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. More...
 
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). More...
 
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. More...
 
- Public Member Functions inherited from EMAN::FactoryBase
 FactoryBase ()
 
virtual ~FactoryBase ()
 
virtual string get_name () const =0
 Get the unique name of this class (especially for factory based instantiation access) More...
 
virtual string get_desc () const =0
 Get a clear, concise description of this class. More...
 
Dict get_params () const
 get a copy of the parameters of this class More...
 
void set_params (const Dict &new_params)
 Set new parameters. More...
 
void set_param (const string key, const EMObject val)
 
void insert_params (const Dict &new_params)
 Insert parameters. More...
 
Dict copy_relevant_params (const FactoryBase *const that) const
 

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. More...
 
OrientationGeneratoroperator= (const OrientationGenerator &)
 Disallow assignment. More...
 

Additional Inherited Members

- Protected Attributes inherited from EMAN::FactoryBase
Dict params
 This is the dictionary the stores the parameters of the object. More...
 

Detailed Description

An orientation generator is a kind of class that will generate orientations for a given symmetry If one needs to generate orientations in the unit sphere, one simply uses the C1 symmetry.

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

Author
David Woolford
Date
Feb 2008

Definition at line 999 of file symmetry.h.

Constructor & Destructor Documentation

◆ OrientationGenerator() [1/2]

EMAN::OrientationGenerator::OrientationGenerator ( )
inline

Definition at line 1002 of file symmetry.h.

1002{};

◆ ~OrientationGenerator()

virtual EMAN::OrientationGenerator::~OrientationGenerator ( )
inlinevirtual

Definition at line 1003 of file symmetry.h.

1003{};

◆ OrientationGenerator() [2/2]

EMAN::OrientationGenerator::OrientationGenerator ( const OrientationGenerator )
private

Disallow copy construction.

Member Function Documentation

◆ add_orientation()

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.

virtual TypeDict get_param_types() const
Definition: symmetry.h:1011

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.

Parameters
vthe vector to add Transform objects to
azthe azimuth to be used as a basis for generated Transform objects (in degrees)
altthe altitude to be used as a basis for generated Transform objects (in degrees)
Returns
and indication of success (true or false). False is only ever return if phitoo is less than 0.

Definition at line 273 of file symmetry.cpp.

274{
275 bool randphi = params.set_default("random_phi",false);
276 float phi = 0.0f;
277 if (randphi) phi = Util::get_frand(0.0f,359.99999f);
278 float phitoo = params.set_default("phitoo",0.0f);
279 if ( phitoo < 0 ) throw InvalidValueException(phitoo, "Error, if you specify phitoo is must be positive");
280 Dict d;
281 d["type"] = "eman";
282 d["az"] = az;
283 d["alt"] = alt;
284 d["phi"] = phi;
285 Transform t(d);
286 v.push_back(t);
287 if ( phitoo != 0 ) {
288 if (phitoo < 0) return false;
289 else {
290 for ( float p = phitoo; p <= 360.0f-phitoo; p+= phitoo )
291 {
292 d["phi"] = fmod(phi+p,360);
293 Transform t(d);
294 v.push_back(t);
295 }
296 }
297 }
298 return true;
299}
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
Dict params
This is the dictionary the stores the parameters of the object.
Definition: emobject.h:953
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
static float get_frand(int low, int high)
Get a float random number between low and high, [low, high)
Definition: util.cpp:725
#define InvalidValueException(val, desc)
Definition: exception.h:285

References EMAN::Util::get_frand(), InvalidValueException, EMAN::FactoryBase::params, and EMAN::Dict::set_default().

Referenced by EMAN::EmanOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::gen_orientations(), and EMAN::OptimumOrientationGenerator::gen_orientations().

◆ gen_orientations()

virtual vector< Transform > EMAN::OrientationGenerator::gen_orientations ( const Symmetry3D *const  sym) const
pure virtual

generate orientations given some symmetry type

Parameters
symthe symmetry which defines the interesting asymmetric unit
Returns
a vector of Transform objects containing the generated set of orientations

Implemented in EMAN::EmanOrientationGenerator, EMAN::SingleOrientationGenerator, EMAN::RandomOrientationGenerator, EMAN::EvenOrientationGenerator, EMAN::SaffOrientationGenerator, and EMAN::OptimumOrientationGenerator.

Referenced by EMAN::Symmetry3D::gen_orientations(), and EMAN::OptimumOrientationGenerator::gen_orientations().

◆ get_az_max()

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 187 of file symmetry.cpp.

188{
189
190 if ( sym->is_d_sym() && alt_iterator == altmax && ( (sym->get_nsym())/2 % 2 == 1 )) {
191 if (inc_mirror) {
192 azmax_adjusted /= 4.0f;
193 d_odd_mirror_flag = true;
194 }
195 else azmax_adjusted /= 2.0f;
196 }
197 else if (sym->is_d_sym() && alt_iterator == altmax && ( (sym->get_nsym())/2 % 2 == 0 ) && inc_mirror) {
198 azmax_adjusted /= 2.0f;
199 }
200 // if this is odd c symmetry, and we're at the equator, and we're excluding the mirror then
201 // half the equator is redundant (it is the mirror of the other half)
202 else if (sym->is_c_sym() && !inc_mirror && alt_iterator == altmax && (sym->get_nsym() % 2 == 1 ) ){
203 azmax_adjusted /= 2.0f;
204 }
205 // at the azimuthal boundary in c symmetry and tetrahedral symmetry we have come
206 // full circle, we must not include it
207 else if (sym->is_c_sym() || sym->is_tet_sym() ) {
208 azmax_adjusted -= h/4.0f;
209 }
210 // If we're including the mirror then in d and icos and oct symmetry the azimuthal
211 // boundary represents coming full circle, so must be careful to exclude it
212 else if (inc_mirror && ( sym->is_d_sym() || sym->is_platonic_sym() ) ) {
213 azmax_adjusted -= h/4.0f;
214 }
215 // else do nothing - this means that we're including the great arc traversing
216 // the full range of permissable altitude angles at azmax.
217 // This happens in d symmetry, and in the icos and oct symmetries, when the mirror
218 // portion of the asymmetric unit is being excluded
219
220}
virtual bool is_c_sym() const
A function that is used to determine if this is a c symmetry object This function is only virtually o...
Definition: symmetry.h:106
virtual bool is_tet_sym() const
A function that is used to determine if this is the tetrahedral symmetry object This function is only...
Definition: symmetry.h:118
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 bool is_platonic_sym() const
A function that is used to determine if this is a platonic symmetry object This function is only virt...
Definition: symmetry.h:94
virtual bool is_d_sym() const
A function that is used to determine if this is a d symmetry object This function is only virtually o...
Definition: symmetry.h:112

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().

◆ get_optimal_delta()

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.

Parameters
symthe symmetry which defines the interesting asymmetric unit
nthe desired number of orientations
Returns
the optimal value of delta to ensure as near to the desired number of orientations is generated

Definition at line 236 of file symmetry.cpp.

237{
238
239// float delta_soln = 360.0f/sym->get_max_csym();
240 float delta_soln = 180.0f;
241 float delta_upper_bound = delta_soln;
242 float delta_lower_bound = 0.0f;
243
244 int prev_tally = -1;
245 // This is an example of a divide and conquer approach, the possible values of delta are searched
246 // like a binary tree
247
248 bool soln_found = false;
249
250 while ( soln_found == false ) {
251 int tally = get_orientations_tally(sym,delta_soln);
252 if ( tally == n ) soln_found = true;
253 else if ( (delta_upper_bound - delta_lower_bound) < 0.0001 ) {
254 // If this is the case, the requested number of projections is practically infeasible
255 // in which case just return the nearest guess
256 soln_found = true;
257 delta_soln = (delta_upper_bound+delta_lower_bound)/2.0f;
258 }
259 else if (tally < n) {
260 delta_upper_bound = delta_soln;
261 delta_soln = delta_soln - (delta_soln-delta_lower_bound)/2.0f;
262 }
263 else /* tally > n*/{
264 delta_lower_bound = delta_soln;
265 delta_soln = delta_soln + (delta_upper_bound-delta_soln)/2.0f;
266 }
267 prev_tally = tally;
268 }
269
270 return delta_soln;
271}
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 ...

References get_orientations_tally().

Referenced by EMAN::EmanOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::gen_orientations(), and EMAN::OptimumOrientationGenerator::gen_orientations().

◆ get_orientations_tally()

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.

Parameters
symthe symmetry which defines the interesting asymmetric unit
deltathe desired angular spacing of the orientations
Returns
the number of orientations that will be generated using these parameters

Implemented in EMAN::EmanOrientationGenerator, EMAN::SingleOrientationGenerator, EMAN::RandomOrientationGenerator, EMAN::EvenOrientationGenerator, EMAN::SaffOrientationGenerator, and EMAN::OptimumOrientationGenerator.

Referenced by get_optimal_delta(), and EMAN::OptimumOrientationGenerator::get_orientations_tally().

◆ get_param_types()

virtual TypeDict EMAN::OrientationGenerator::get_param_types ( ) const
inlinevirtual
Returns
a TypeDict defining and describing the feasible parameters of this class

Implements EMAN::FactoryBase.

Reimplemented in EMAN::EmanOrientationGenerator, EMAN::SingleOrientationGenerator, EMAN::RandomOrientationGenerator, EMAN::EvenOrientationGenerator, EMAN::SaffOrientationGenerator, and EMAN::OptimumOrientationGenerator.

Definition at line 1011 of file symmetry.h.

1012 {
1013 TypeDict d;
1014 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.");
1015 d.put("random_phi", EMObject::BOOL, "Causes the orientations to have a random phi. This occurs before the phitoo parameter is considered.");
1016 return d;
1017 }

References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().

Referenced by EMAN::EmanOrientationGenerator::get_param_types(), EMAN::SingleOrientationGenerator::get_param_types(), EMAN::EvenOrientationGenerator::get_param_types(), EMAN::SaffOrientationGenerator::get_param_types(), and EMAN::OptimumOrientationGenerator::get_param_types().

◆ operator=()

OrientationGenerator & EMAN::OrientationGenerator::operator= ( const OrientationGenerator )
private

Disallow assignment.


The documentation for this class was generated from the following files: