EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
EMAN::RandomOrientationGenerator Class Reference

Random Orientation Generator - carefully generates uniformly random orientations in any asymmetric unit. More...

#include <symmetry.h>

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

Public Member Functions

 RandomOrientationGenerator ()
 
virtual ~RandomOrientationGenerator ()
 
virtual string get_name () const
 Return "random". More...
 
virtual string get_desc () const
 Get a description. More...
 
virtual TypeDict get_param_types () const
 Get a dictionary containing the permissable parameters of this class. More...
 
virtual vector< Transformgen_orientations (const Symmetry3D *const sym) const
 Generate random orientations in the asymmetric unit of the symmetry. More...
 
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 should general do this by simulating the function gen_orientations. More...
 
- Public Member Functions inherited from EMAN::OrientationGenerator
 OrientationGenerator ()
 
virtual ~OrientationGenerator ()
 
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...
 
- Public Member Functions inherited from EMAN::FactoryBase
 FactoryBase ()
 
virtual ~FactoryBase ()
 
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
 

Static Public Member Functions

static OrientationGeneratorNEW ()
 Factory support function NEW. More...
 

Static Public Attributes

static const string NAME = "rand"
 The name of this class - used to access it from factories etc. More...
 

Private Member Functions

 RandomOrientationGenerator (const RandomOrientationGenerator &)
 Disallow copy construction. More...
 
RandomOrientationGeneratoroperator= (const RandomOrientationGenerator &)
 Disallow assignment. More...
 

Additional Inherited Members

- Protected Member Functions inherited from EMAN::OrientationGenerator
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
 
- Protected Attributes inherited from EMAN::FactoryBase
Dict params
 This is the dictionary the stores the parameters of the object. More...
 

Detailed Description

Random Orientation Generator - carefully generates uniformly random orientations in any asymmetric unit.

For points distributed in the unit sphere, just use the CSym type with nysm = 1. (i.e. c1 symmetry)

Author
David Woolford
Date
March 2008

Definition at line 1234 of file symmetry.h.

Constructor & Destructor Documentation

◆ RandomOrientationGenerator() [1/2]

EMAN::RandomOrientationGenerator::RandomOrientationGenerator ( )
inline

Definition at line 1237 of file symmetry.h.

1237{}

Referenced by NEW().

◆ ~RandomOrientationGenerator()

virtual EMAN::RandomOrientationGenerator::~RandomOrientationGenerator ( )
inlinevirtual

Definition at line 1238 of file symmetry.h.

1238{}

◆ RandomOrientationGenerator() [2/2]

EMAN::RandomOrientationGenerator::RandomOrientationGenerator ( const RandomOrientationGenerator )
private

Disallow copy construction.

Member Function Documentation

◆ gen_orientations()

vector< Transform > RandomOrientationGenerator::gen_orientations ( const Symmetry3D *const  sym) const
virtual

Generate random orientations in the asymmetric unit of the symmetry.

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

Implements EMAN::OrientationGenerator.

Definition at line 546 of file symmetry.cpp.

547{
548 int n = params.set_default("n", 0);
549
550 if ( n <= 0 ) throw InvalidParameterException("You must specify a positive, non zero n for the Random Orientation Generator");
551
552 bool phitoo = params.set_default("phitoo", false);
553 bool inc_mirror = params.set_default("inc_mirror", false);
554
555 vector<Transform> ret;
556
557 int i = 0;
558 Dict d("type","eman");
559 while ( i < n ){
560 float u1 = Util::get_frand(-1.0f,1.0f);
561 float u2 = Util::get_frand(-1.0f,1.0f);
562 float s = u1*u1 + u2*u2;
563 if ( s > 1.0f ) continue;
564 float alpha = 2.0f*sqrtf(1.0f-s);
565 float x = alpha * u1;
566 float y = alpha * u2;
567 float z = 2.0f*s-1.0f;
568
569 float altitude = (float)EMConsts::rad2deg*acos(z);
570 float azimuth = (float)EMConsts::rad2deg*atan2(y,x);
571
572 float phi = 0.0f;
573 if ( phitoo ) phi = Util::get_frand(0.0f,359.9999f);
574
575 d["az"] = azimuth; d["phi"] = phi; d["alt"] = altitude;
576 Transform t(d);
577
578 if ( !(sym->is_c_sym() && sym->get_nsym() == 1)) t = sym->reduce(t); //reduce doesn't make sense for C1 symmetry
579
580 if ( !sym->is_in_asym_unit(altitude,azimuth,inc_mirror) ){
581 // is_in_asym_unit has returned the wrong value!
582 // FIXME
583// cout << "warning, there is an unresolved issue - email D Woolford" << endl;
584 }
585 ret.push_back(t);
586 i++;
587 }
588 return ret;
589}
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
static const double rad2deg
Definition: emobject.h:77
Dict params
This is the dictionary the stores the parameters of the object.
Definition: emobject.h:953
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 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_in_asym_unit(const float &altitude, const float &azimuth, const bool inc_mirror) const =0
A function to be used when generating orientations over portion of the unit sphere defined by paramet...
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 InvalidParameterException(desc)
Definition: exception.h:361
virtual Transform reduce(const Transform &t3d, int n=0) const
A function that will reduce an orientation, as characterized by Euler anges, into a specific asymmetr...
Definition: symmetry.cpp:974
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::Util::get_frand(), EMAN::Symmetry3D::get_nsym(), InvalidParameterException, EMAN::Symmetry3D::is_c_sym(), EMAN::Symmetry3D::is_in_asym_unit(), EMAN::FactoryBase::params, EMAN::EMConsts::rad2deg, EMAN::Symmetry3D::reduce(), EMAN::Dict::set_default(), x, and y.

◆ get_desc()

virtual string EMAN::RandomOrientationGenerator::get_desc ( ) const
inlinevirtual

Get a description.

Returns
a clear desciption of this class

Implements EMAN::FactoryBase.

Definition at line 1256 of file symmetry.h.

1256{ return "Generate random orientations within an asymmetric unit"; }

◆ get_name()

virtual string EMAN::RandomOrientationGenerator::get_name ( ) const
inlinevirtual

Return "random".

Returns
the unique name of this class

Implements EMAN::FactoryBase.

Definition at line 1251 of file symmetry.h.

1251{ return NAME; }
static const string NAME
The name of this class - used to access it from factories etc.
Definition: symmetry.h:1278

References NAME.

◆ get_orientations_tally()

virtual int EMAN::RandomOrientationGenerator::get_orientations_tally ( const Symmetry3D *const  sym,
const float &  delta 
) const
inlinevirtual

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

Implements EMAN::OrientationGenerator.

Definition at line 1280 of file symmetry.h.

1280{ (void)sym; (void)delta; return 0; }

◆ get_param_types()

virtual TypeDict EMAN::RandomOrientationGenerator::get_param_types ( ) const
inlinevirtual

Get a dictionary containing the permissable parameters of this class.

Returns
a dictionary containing the permissable parameters of this class parameters are explained in the dictionary itself

Reimplemented from EMAN::OrientationGenerator.

Definition at line 1262 of file symmetry.h.

1263 {
1264 TypeDict d;
1265 d.put("n", EMObject::INT, "The number of orientations to generate.");
1266 d.put("inc_mirror", EMObject::BOOL, "Indicates whether or not to include the mirror portion of the asymmetric unit. Default is false.");
1267 d.put("phitoo", EMObject::BOOL, "Makes phi random as well");
1268 return d;
1269 }

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

◆ NEW()

static OrientationGenerator * EMAN::RandomOrientationGenerator::NEW ( )
inlinestatic

Factory support function NEW.

Returns
a newly instantiated class of this type

Definition at line 1243 of file symmetry.h.

1244 {
1245 return new RandomOrientationGenerator();
1246 }

References RandomOrientationGenerator().

◆ operator=()

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

Disallow assignment.

Member Data Documentation

◆ NAME

const string RandomOrientationGenerator::NAME = "rand"
static

The name of this class - used to access it from factories etc.

Definition at line 1278 of file symmetry.h.

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


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