EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions
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]

List of all members.

Public Member Functions

 RandomOrientationGenerator ()
virtual ~RandomOrientationGenerator ()
virtual string get_name () const
 Return "random".
virtual string get_desc () const
 Get a description.
virtual TypeDict get_param_types () const
 Get a dictionary containing the permissable parameters of this class.
virtual vector< Transformgen_orientations (const Symmetry3D *const sym) const
 Generate random orientations in the asymmetric unit of the symmetry.
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.

Static Public Member Functions

static OrientationGeneratorNEW ()
 Factory support function NEW.

Static Public Attributes

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

Private Member Functions

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

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 1165 of file symmetry.h.


Constructor & Destructor Documentation

EMAN::RandomOrientationGenerator::RandomOrientationGenerator ( ) [inline]

Definition at line 1168 of file symmetry.h.

Referenced by NEW().

{}
virtual EMAN::RandomOrientationGenerator::~RandomOrientationGenerator ( ) [inline, virtual]

Definition at line 1169 of file symmetry.h.

{}
EMAN::RandomOrientationGenerator::RandomOrientationGenerator ( const RandomOrientationGenerator ) [private]

Disallow copy construction.


Member Function Documentation

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

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

{
        int n = params.set_default("n", 0);

        if ( n <= 0 ) throw InvalidParameterException("You must specify a positive, non zero n for the Random Orientation Generator");

        bool phitoo = params.set_default("phitoo", false);
        bool inc_mirror = params.set_default("inc_mirror", false);

        vector<Transform> ret;

        int i = 0;
        Dict d("type","eman");
        while ( i < n ){
                float u1 =  Util::get_frand(-1.0f,1.0f);
                float u2 =  Util::get_frand(-1.0f,1.0f);
                float s = u1*u1 + u2*u2;
                if ( s > 1.0f ) continue;
                float alpha = 2.0f*sqrtf(1.0f-s);
                float x = alpha * u1;
                float y = alpha * u2;
                float z = 2.0f*s-1.0f;

                float altitude = (float)EMConsts::rad2deg*acos(z);
                float azimuth = (float)EMConsts::rad2deg*atan2(y,x);

                float phi = 0.0f;
                if ( phitoo ) phi = Util::get_frand(0.0f,359.9999f);

                d["az"] = azimuth; d["phi"] = phi; d["alt"] = altitude;
                Transform t(d);

                if ( !(sym->is_c_sym() && sym->get_nsym() == 1)) t = sym->reduce(t); //reduce doesn't make sense for C1 symmetry

                if ( !sym->is_in_asym_unit(altitude,azimuth,inc_mirror) ){
                        // is_in_asym_unit has returned the wrong value!
                        // FIXME
//                      cout << "warning, there is an unresolved issue - email D Woolford" << endl;
                }
                ret.push_back(t);
                i++;
        }
        return ret;
}
virtual string EMAN::RandomOrientationGenerator::get_desc ( ) const [inline, virtual]

Get a description.

Returns:
a clear desciption of this class

Implements EMAN::FactoryBase.

Definition at line 1187 of file symmetry.h.

{ return "Generate random orientations within an asymmetric unit"; }
virtual string EMAN::RandomOrientationGenerator::get_name ( ) const [inline, virtual]

Return "random".

Returns:
the unique name of this class

Implements EMAN::FactoryBase.

Definition at line 1182 of file symmetry.h.

References NAME.

{ return NAME; }
virtual int EMAN::RandomOrientationGenerator::get_orientations_tally ( const Symmetry3D *const  sym,
const float &  delta 
) const [inline, 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

Implements EMAN::OrientationGenerator.

Definition at line 1211 of file symmetry.h.

{ (void)sym; (void)delta; return 0; }
virtual TypeDict EMAN::RandomOrientationGenerator::get_param_types ( ) const [inline, virtual]

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 1193 of file symmetry.h.

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

                {
                        TypeDict d;
                        d.put("n", EMObject::INT, "The number of orientations to generate.");
                        d.put("inc_mirror", EMObject::BOOL, "Indicates whether or not to include the mirror portion of the asymmetric unit. Default is false.");
                        d.put("phitoo", EMObject::BOOL, "Makes phi random as well");
                        return d;
                }
static OrientationGenerator* EMAN::RandomOrientationGenerator::NEW ( ) [inline, static]

Factory support function NEW.

Returns:
a newly instantiated class of this type

Definition at line 1174 of file symmetry.h.

References RandomOrientationGenerator().

                {
                        return new RandomOrientationGenerator();
                }
RandomOrientationGenerator& EMAN::RandomOrientationGenerator::operator= ( const RandomOrientationGenerator ) [private]

Disallow assignment.


Member Data Documentation

const string RandomOrientationGenerator::NAME = "rand" [static]

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

Definition at line 1209 of file symmetry.h.

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


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