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

Saff orientation generator - based on the work of Saff and Kuijlaars, 1997 E.B. More...

#include <symmetry.h>

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

Public Member Functions

 SaffOrientationGenerator ()
 
virtual ~SaffOrientationGenerator ()
 
virtual string get_name () const
 Return "saff". 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 Saff orientations in the asymmetric unit of the symmetry. 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 = "saff"
 The name of this class - used to access it from factories etc. Should be "icos". More...
 

Private Member Functions

 SaffOrientationGenerator (const SaffOrientationGenerator &)
 Disallow copy construction. More...
 
SaffOrientationGeneratoroperator= (const SaffOrientationGenerator &)
 Disallow assignment. 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 does this by simulated gen_orientations. 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

Saff orientation generator - based on the work of Saff and Kuijlaars, 1997 E.B.

Saff and A.B.J. Kuijlaars, Distributing many points on a sphere, Mathematical Intelligencer 19 (1997), pp. 5–11. This is a spiral based approach

Author
David Woolford (ported directly from Sparx utilities.py, which is written by Pawel Penczek)
Date
March 2008

Definition at line 1365 of file symmetry.h.

Constructor & Destructor Documentation

◆ SaffOrientationGenerator() [1/2]

EMAN::SaffOrientationGenerator::SaffOrientationGenerator ( )
inline

Definition at line 1368 of file symmetry.h.

1368{}

Referenced by NEW().

◆ ~SaffOrientationGenerator()

virtual EMAN::SaffOrientationGenerator::~SaffOrientationGenerator ( )
inlinevirtual

Definition at line 1369 of file symmetry.h.

1369{}

◆ SaffOrientationGenerator() [2/2]

EMAN::SaffOrientationGenerator::SaffOrientationGenerator ( const SaffOrientationGenerator )
private

Disallow copy construction.

Member Function Documentation

◆ gen_orientations()

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

Generate Saff 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 722 of file symmetry.cpp.

723{
724 float delta = params.set_default("delta", 0.0f);
725 int n = params.set_default("n", 0);
726
727 if ( delta <= 0 && n <= 0 ) throw InvalidParameterException("Error, you must specify a positive non-zero delta or n");
728 if ( delta > 0 && n > 0 ) throw InvalidParameterException("Error, the delta and the n arguments are mutually exclusive");
729
730 if ( n > 0 ) {
731 delta = get_optimal_delta(sym,n);
732 }
733
734// if ( sym->is_platonic_sym() ) return gen_platonic_orientations(sym, delta);
735
736 bool inc_mirror = params.set_default("inc_mirror",false);
737 Dict delimiters = sym->get_delimiters(inc_mirror);
738 float altmax = delimiters["alt_max"];
739 float azmax = delimiters["az_max"];
740
741 float altmin = 0.0f;
742 // #If it's a h symmetry then the alt iterator starts at very close
743 // #to the altmax... the object is a h symmetry then it knows its alt_min...
744 if (sym->is_h_sym()){
745 altmin = delimiters["alt_min"];
746 if (inc_mirror) {
747 altmin -= (float) sym->get_params()["maxtilt"];
748 }
749 }
750
751 float Deltaz = (float)(cos(altmax*EMConsts::deg2rad)-cos(altmin*EMConsts::deg2rad));
752 float s = delta*M_PI/180.0f;
753 float NFactor = 3.6f/s;
754 float wedgeFactor = fabs( Deltaz*(azmax)/720.0f) ;
755 int NumPoints = static_cast<int> (NFactor*NFactor*wedgeFactor);
756
757 vector<Transform> ret;
758
759 if (!sym->is_h_sym()) add_orientation(ret,0,0);
760 float az = 0.0f;
761 float dz = (float)cos(altmin*EMConsts::deg2rad);
762 for(int i = 1; i < NumPoints; ++i ){
763 float z = dz + Deltaz* (float)i/ float(NumPoints-1);
764 float r= sqrt(1.0f-z*z);
765 az = fmod(az + delta/r,azmax);
766 float alt = (float)(acos(z)*EMConsts::rad2deg);
767 if (sym->is_platonic_sym()) {
768 if ( sym->is_in_asym_unit(alt,az,inc_mirror) == false ) continue;
769 else {
770 az += sym->get_az_alignment_offset(); // Align to the symmetry axes
771 }
772 }
773 add_orientation(ret,az,alt);
774 }
775
776 return ret;
777}
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
static const double deg2rad
Definition: emobject.h:78
Dict params
This is the dictionary the stores the parameters of the object.
Definition: emobject.h:953
Dict get_params() const
get a copy of the parameters of this class
Definition: emobject.h:911
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...
Definition: symmetry.cpp:273
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...
Definition: symmetry.cpp:236
virtual bool is_h_sym() const
A function that is used to determine if this is a Helical symmetry object This function is only virtu...
Definition: symmetry.h:100
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_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...
virtual Dict get_delimiters(const bool inc_mirror=false) const =0
Every Symmetry3D object must return a dictionary containing the delimiters that define its asymmetric...
virtual float get_az_alignment_offset() const
This functionality is only relevant to platonic symmetries.
Definition: symmetry.h:86
EMData * sqrt() const
return square root of current image
#define InvalidParameterException(desc)
Definition: exception.h:361

References EMAN::OrientationGenerator::add_orientation(), EMAN::EMConsts::deg2rad, EMAN::Symmetry3D::get_az_alignment_offset(), EMAN::Symmetry3D::get_delimiters(), EMAN::OrientationGenerator::get_optimal_delta(), EMAN::FactoryBase::get_params(), InvalidParameterException, EMAN::Symmetry3D::is_h_sym(), EMAN::Symmetry3D::is_in_asym_unit(), EMAN::Symmetry3D::is_platonic_sym(), EMAN::FactoryBase::params, EMAN::EMConsts::rad2deg, EMAN::Dict::set_default(), and sqrt().

◆ get_desc()

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

Get a description.

Returns
a clear desciption of this class

Implements EMAN::FactoryBase.

Definition at line 1387 of file symmetry.h.

1387{ return "Generate quasi-evenly distributed orientations within an asymmetric unit using a spiraling method attributed to Saff"; }

◆ get_name()

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

Return "saff".

Returns
the unique name of this class

Implements EMAN::FactoryBase.

Definition at line 1382 of file symmetry.h.

1382{ return NAME; }
static const string NAME
The name of this class - used to access it from factories etc. Should be "icos".
Definition: symmetry.h:1409

References NAME.

◆ get_orientations_tally()

int SaffOrientationGenerator::get_orientations_tally ( const Symmetry3D *const  sym,
const float &  delta 
) const
privatevirtual

This function returns how many orientations will be generated for a given delta (angular spacing) It does this by simulated 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 681 of file symmetry.cpp.

682{
683 bool inc_mirror = params.set_default("inc_mirror",false);
684 Dict delimiters = sym->get_delimiters(inc_mirror);
685 float altmax = delimiters["alt_max"];
686 float azmax = delimiters["az_max"];
687
688 float altmin = 0.0f;
689 // #If it's a h symmetry then the alt iterator starts at very close
690 // #to the altmax... the object is a h symmetry then it knows its alt_min...
691 if (sym->is_h_sym()){
692 altmin = delimiters["alt_min"];
693 if (inc_mirror) {
694 altmin -= (float) sym->get_params()["maxtilt"];
695 }
696 }
697
698 float Deltaz = (float)(cos(altmax*EMConsts::deg2rad)-cos(altmin*EMConsts::deg2rad));
699 float s = delta*M_PI/180.0f;
700 float NFactor = 3.6f/s;
701 float wedgeFactor = fabs( Deltaz*(azmax)/720.0f) ;
702 int NumPoints = static_cast<int> (NFactor*NFactor*wedgeFactor);
703
704 int tally = 0;
705 if (!sym->is_h_sym()) ++tally;
706 float az = 0.0f;
707 float dz = (float)cos(altmin*EMConsts::deg2rad);
708 for(int i = 1; i < NumPoints; ++i ){
709 float z = dz + Deltaz* (float)i/ float(NumPoints-1);
710 float r= sqrt(1.0f-z*z);
711 az = fmod(az + delta/r,azmax);
712 float alt = (float)(acos(z)*EMConsts::rad2deg);
713 if (sym->is_platonic_sym()) {
714 if ( sym->is_in_asym_unit(alt,az,inc_mirror) == false ) continue;
715 }
716 tally++;
717 }
718
719 return tally;
720}

References EMAN::EMConsts::deg2rad, EMAN::Symmetry3D::get_delimiters(), EMAN::FactoryBase::get_params(), EMAN::Symmetry3D::is_h_sym(), EMAN::Symmetry3D::is_in_asym_unit(), EMAN::Symmetry3D::is_platonic_sym(), EMAN::FactoryBase::params, EMAN::EMConsts::rad2deg, EMAN::Dict::set_default(), and sqrt().

◆ get_param_types()

virtual TypeDict EMAN::SaffOrientationGenerator::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 1393 of file symmetry.h.

1394 {
1396 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.");
1397 d.put("inc_mirror", EMObject::BOOL, "Indicates whether or not to include the mirror portion of the asymmetric unit. Default is false.");
1398 d.put("delta", EMObject::FLOAT, "The angular separation of orientations in degrees. This option is mutually exclusively of the n argument.");
1399 return d;
1400 }
virtual TypeDict get_param_types() const
Definition: symmetry.h:1011

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

◆ NEW()

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

Factory support function NEW.

Returns
a newly instantiated class of this type

Definition at line 1374 of file symmetry.h.

1375 {
1376 return new SaffOrientationGenerator();
1377 }

References SaffOrientationGenerator().

◆ operator=()

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

Disallow assignment.

Member Data Documentation

◆ NAME

const string SaffOrientationGenerator::NAME = "saff"
static

The name of this class - used to access it from factories etc. Should be "icos".

Definition at line 1409 of file symmetry.h.

Referenced by get_name().


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