#include <symmetry.h>
Inheritance diagram for EMAN::Symmetry3D:
Public Types | |
typedef vector< vector< Vec3f > >::const_iterator | cit |
typedef vector< vector< Vec3f > >::iterator | ncit |
Public Member Functions | |
Symmetry3D () | |
virtual | ~Symmetry3D () |
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 unit (this is not strictly true in the case of the PlatonicSym class). | |
virtual Transform | get_sym (const int n) const =0 |
Every Symmetry3D object must provide access to the full set of its symmetry operators via this function. | |
virtual int | get_nsym () const =0 |
The total number of unique symmetry operations that will be return by this object when a calling program access Symmetry3D::get_sym. | |
virtual float | get_az_alignment_offset () const |
This functionality is only relevant to platonic symmetries. | |
virtual bool | is_platonic_sym () const |
A function that is used to determine if this is a platonic symmetry object This function is only virtually overidden by the PlatonicSym symmetry, which returns true, not false. | |
virtual bool | is_h_sym () const |
A function that is used to determine if this is a Helical symmetry object This function is only virtually overidden by the HSym symmetry, which returns true, not false. | |
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 overidden by the CSym object, which returns true. | |
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 overidden by the DSym object, which returns true. | |
virtual bool | is_tet_sym () const |
A function that is used to determine if this is the tetrahedral symmetry object This function is only virtually overidden by the TetSym object, which returns true. | |
virtual int | get_max_csym () const =0 |
The Symmetry3D object must return the maximum degree of symmetry it exhibits about any one axis. | |
virtual vector< Vec3f > | get_asym_unit_points (bool inc_mirror) const =0 |
The Symmetry3D object must be capable of returning an ordered list of points on the unit sphere that define its asymmetric unit (with mirror considerations). | |
vector< Transform > | gen_orientations (const string &generatorname="eman", const Dict &parms=Dict()) |
Ask the Symmetry3D object to generate a set of orientations in its asymmetric unit using an OrientationGenerator constructed from the given parameters (using a Factory). | |
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 parameters returned by get_delimiters. | |
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 asymmetric unit. | |
virtual int | in_which_asym_unit (const Transform &t3d) const |
A function that will determine in which asymmetric unit a given orientation resides The asymmetric unit 'number' will depend entirely on the order in which different symmetry operations are return by the Symmetry3D::get_sym function. | |
virtual int | point_in_which_asym_unit (const Vec3f &v) const |
A function that will determine in which asymmetric unit a given vector resides The asymmetric unit 'number' will depend entirely on the order in which different symmetry operations are return by the Symmetry3D::get_sym function The vector is a point. | |
virtual vector< vector< Vec3f > > | get_asym_unit_triangles (bool inc_mirror) const =0 |
Get triangles that precisely occlude the projection area of the default asymmetric unit. | |
virtual vector< Transform > | get_touching_au_transforms (bool inc_mirror=true) const |
Gets a vector of Transform objects that define the set of asymmetric units that touch the default asymmetric unit. | |
virtual vector< Transform > | get_syms () const |
Static Public Member Functions | |
static vector< Transform > | get_symmetries (const string &symmetry) |
Protected Member Functions | |
void | cache_au_planes () const |
Establish the asymmetric unit planes cache. | |
void | delete_au_planes () |
Clear the asymmetric unit planes cache. | |
Protected Attributes | |
float ** | cached_au_planes |
The asymmetric unit planes are cached to provide a great speed up the point_in_which_asym_unit function, which is called by reduce and by in_which_asym_unit. | |
int | cache_size |
Have to remember the cache size. | |
int | num_triangles |
This is stores the number of triangles returned by get_asym_unit_triangles(true). | |
vector< vector< Vec3f > > | au_sym_triangles |
This cache is of size cache_size. | |
Private Member Functions | |
Symmetry3D (const Symmetry3D &) | |
Disallow copy construction. | |
Symmetry3D & | operator= (const Symmetry3D &) |
Disallow assignment. |
Objects of this type must provide delimiters for the asymmetric unit (get_delimiters), and must also provide all of the rotational symmetric operations (get_sym(const int n)). They must also provide the total number of unique symmetric operations with get_nsym (except in helical symmetry). get_delimiter returns a dictionary with "alt_max" and "az_max" keys, which correspond to the encompassing azimuth and altitude angles of the asymmetric unit. These can be interpreted in a relatively straight forward fashion when dealing with C and D symmetries to demarcate the asymmetric unit, however when dealing with Platonic symmetries the asymmetric unit is not so trivial. see http://blake.bcm.edu/emanwiki/EMAN2/Symmetry for figures and description of what we're doing here, for all the symmetries, and look in the comments of the PlatonicSym classes themselves. It inherits from a factory base, making it amenable to incorporation in EMAN2 style factories
Definition at line 56 of file symmetry.h.
typedef vector<vector<Vec3f> >::const_iterator EMAN::Symmetry3D::cit |
Definition at line 59 of file symmetry.h.
typedef vector<vector<Vec3f> >::iterator EMAN::Symmetry3D::ncit |
Definition at line 60 of file symmetry.h.
Symmetry3D::Symmetry3D | ( | ) |
Definition at line 899 of file symmetry.cpp.
00899 : cached_au_planes(0),cache_size(0),num_triangles(0),au_sym_triangles() {}
Symmetry3D::~Symmetry3D | ( | ) | [virtual] |
Definition at line 900 of file symmetry.cpp.
References cached_au_planes, and delete_au_planes().
00900 { 00901 if (cached_au_planes != 0 ) { 00902 delete_au_planes(); 00903 } 00904 }
EMAN::Symmetry3D::Symmetry3D | ( | const Symmetry3D & | ) | [private] |
Disallow copy construction.
void Symmetry3D::cache_au_planes | ( | ) | const [protected] |
Establish the asymmetric unit planes cache.
Definition at line 956 of file symmetry.cpp.
References au_sym_triangles, cache_size, cached_au_planes, EMAN::Util::equation_of_plane(), fit, get_asym_unit_triangles(), get_nsym(), get_sym(), num_triangles, t, and UnexpectedBehaviorException.
Referenced by point_in_which_asym_unit().
00956 { 00957 if (cached_au_planes == 0 ) { 00958 vector< vector<Vec3f> > au_triangles = get_asym_unit_triangles(true); 00959 num_triangles = au_triangles.size(); 00960 cache_size = get_nsym()*au_triangles.size(); 00961 00962 cached_au_planes = new float*[cache_size]; 00963 float** fit = cached_au_planes; 00964 for(int i =0; i < cache_size; ++i,++fit) { 00965 float *t = new float[4]; 00966 *fit = t; 00967 } 00968 00969 00970 int k = 0; 00971 for(int i = 0; i < get_nsym(); ++i) { 00972 00973 for( ncit it = au_triangles.begin(); it != au_triangles.end(); ++it, ++k) 00974 { 00975 // For each given triangle 00976 vector<Vec3f> points = *it; 00977 if ( i != 0 ) { 00978 for (vector<Vec3f>::iterator iit = points.begin(); iit != points.end(); ++iit ) { 00979 // Rotate the points in the triangle so that the triangle occupies the 00980 // space of the current asymmetric unit 00981 *iit = (*iit)*get_sym(i); 00982 } 00983 } 00984 00985 au_sym_triangles.push_back(points); 00986 00987 // Determine the equation of the plane for the points, store it in plane 00988 Util::equation_of_plane(points[0],points[2],points[1],cached_au_planes[k]); 00989 } 00990 } 00991 } 00992 else throw UnexpectedBehaviorException("Attempt to generate a cache when cache exists"); 00993 }
void Symmetry3D::delete_au_planes | ( | ) | [protected] |
Clear the asymmetric unit planes cache.
Definition at line 995 of file symmetry.cpp.
References cache_size, cached_au_planes, fit, and UnexpectedBehaviorException.
Referenced by ~Symmetry3D().
00995 { 00996 if (cached_au_planes == 0 ) throw UnexpectedBehaviorException("Attempt to delete a cache that does not exist"); 00997 float** fit = cached_au_planes; 00998 for(int i =0; i < cache_size; ++i,++fit) { 00999 if (*fit == 0) throw UnexpectedBehaviorException("Attempt to delete a cache that does not exist"); 01000 delete [] *fit; 01001 *fit = 0; 01002 } 01003 01004 delete [] cached_au_planes; 01005 cached_au_planes = 0; 01006 }
vector< Transform > Symmetry3D::gen_orientations | ( | const string & | generatorname = "eman" , |
|
const Dict & | parms = Dict() | |||
) |
Ask the Symmetry3D object to generate a set of orientations in its asymmetric unit using an OrientationGenerator constructed from the given parameters (using a Factory).
This is reminiscent of the strategy design pattern
generatorname | the string name of the OrientationGenerator, as accessed for the OrientationGenerator factory | |
parms | the parameters handed to OrientationGenerator::set_params after initial construction |
Definition at line 156 of file symmetry.cpp.
References ENTERFUNC, EXITFUNC, EMAN::OrientationGenerator::gen_orientations(), and EMAN::Util::str_to_lower().
Referenced by EMAN::RT3DSphereAligner::xform_align_nbest().
00157 { 00158 ENTERFUNC; 00159 vector<Transform> ret; 00160 OrientationGenerator *g = Factory < OrientationGenerator >::get(Util::str_to_lower(generatorname), parms); 00161 if (g) { 00162 ret = g->gen_orientations(this); 00163 if( g ) 00164 { 00165 delete g; 00166 g = 0; 00167 } 00168 } 00169 else throw; 00170 00171 EXITFUNC; 00172 00173 return ret; 00174 }
virtual vector<Vec3f> EMAN::Symmetry3D::get_asym_unit_points | ( | bool | inc_mirror | ) | const [pure virtual] |
The Symmetry3D object must be capable of returning an ordered list of points on the unit sphere that define its asymmetric unit (with mirror considerations).
The list can be any length, and must be constructed carefully. If the list consists of points A B and C, then arcs on the unit sphere connecting A to B, then B to C, then C to A must define the asymmetric unit (with or without its mirror portion). i.e. it is a cyclic list, on any length
inc_mirror | whether or not to include the mirror portion of the asymmetric unit |
Implemented in EMAN::CSym, EMAN::DSym, EMAN::HSym, EMAN::PlatonicSym, and EMAN::TetrahedralSym.
Referenced by get_touching_au_transforms().
virtual vector<vector<Vec3f> > EMAN::Symmetry3D::get_asym_unit_triangles | ( | bool | inc_mirror | ) | const [pure virtual] |
Get triangles that precisely occlude the projection area of the default asymmetric unit.
This will be used for collision detection in Symmetry3D::reduce
inc_mirror | whether to include the mirror portion of the asymmetric unit |
Implemented in EMAN::CSym, EMAN::DSym, EMAN::HSym, and EMAN::PlatonicSym.
Referenced by cache_au_planes().
virtual float EMAN::Symmetry3D::get_az_alignment_offset | ( | ) | const [inline, virtual] |
This functionality is only relevant to platonic symmetries.
But it could grow into functionality for the other symmetries.
Reimplemented in EMAN::TetrahedralSym, and EMAN::IcosahedralSym.
Definition at line 86 of file symmetry.h.
Referenced by EMAN::SaffOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), EMAN::EmanOrientationGenerator::gen_orientations(), and EMAN::PlatonicSym::get_asym_unit_points().
virtual Dict EMAN::Symmetry3D::get_delimiters | ( | const bool | inc_mirror = false |
) | const [pure virtual] |
Every Symmetry3D object must return a dictionary containing the delimiters that define its asymmetric unit (this is not strictly true in the case of the PlatonicSym class).
inc_mirror | whether or not the mirror part of the asymmetric unit should be included in the consideration |
Implemented in EMAN::CSym, EMAN::DSym, EMAN::HSym, and EMAN::PlatonicSym.
Referenced by EMAN::SaffOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), EMAN::EmanOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::get_orientations_tally(), EMAN::EvenOrientationGenerator::get_orientations_tally(), EMAN::EmanOrientationGenerator::get_orientations_tally(), and get_touching_au_transforms().
virtual int EMAN::Symmetry3D::get_max_csym | ( | ) | const [pure virtual] |
The Symmetry3D object must return the maximum degree of symmetry it exhibits about any one axis.
This function is only called in the AsymmUnitOrientationGenerator.
Implemented in EMAN::CSym, EMAN::DSym, EMAN::HSym, EMAN::TetrahedralSym, EMAN::OctahedralSym, and EMAN::IcosahedralSym.
Referenced by EMAN::EmanOrientationGenerator::gen_orientations(), EMAN::EmanOrientationGenerator::get_orientations_tally(), and EMAN::PlatonicSym::init().
virtual int EMAN::Symmetry3D::get_nsym | ( | ) | const [pure virtual] |
The total number of unique symmetry operations that will be return by this object when a calling program access Symmetry3D::get_sym.
However in the case of HSym, this is really something else.
Implemented in EMAN::CSym, EMAN::DSym, EMAN::HSym, EMAN::TetrahedralSym, EMAN::OctahedralSym, and EMAN::IcosahedralSym.
Referenced by cache_au_planes(), EMAN::BackProjectionReconstructor::finish(), EMAN::RandomOrientationGenerator::gen_orientations(), EMAN::OrientationGenerator::get_az_max(), EMAN::Transform::get_nsym(), get_syms(), get_touching_au_transforms(), and point_in_which_asym_unit().
virtual Transform EMAN::Symmetry3D::get_sym | ( | const int | n | ) | const [pure virtual] |
Every Symmetry3D object must provide access to the full set of its symmetry operators via this function.
n | the symmetry operator number |
Implemented in EMAN::CSym, EMAN::DSym, EMAN::HSym, EMAN::TetrahedralSym, EMAN::OctahedralSym, and EMAN::IcosahedralSym.
Referenced by cache_au_planes(), EMAN::Transform::get_sym(), get_syms(), get_touching_au_transforms(), and reduce().
vector< Transform > Symmetry3D::get_symmetries | ( | const string & | symmetry | ) | [static] |
Definition at line 1160 of file symmetry.cpp.
References get_syms(), and EMAN::Util::str_to_lower().
Referenced by EMAN::WienerFourierReconstructor::do_compare_slice_work(), EMAN::FourierReconstructor::do_compare_slice_work(), EMAN::WienerFourierReconstructor::do_insert_slice_work(), EMAN::FourierReconstructor::do_insert_slice_work(), and EMAN::SymSearchProcessor::process_inplace().
01161 { 01162 Symmetry3D* sym = Factory<Symmetry3D>::get(Util::str_to_lower(symmetry)); 01163 vector<Transform> ret = sym->get_syms(); 01164 delete sym; 01165 return ret; 01166 }
vector< Transform > Symmetry3D::get_syms | ( | ) | const [virtual] |
Definition at line 1144 of file symmetry.cpp.
References get_nsym(), and get_sym().
Referenced by EMAN::BackProjectionReconstructor::finish(), and get_symmetries().
01145 { 01146 01147 vector<Transform> ret; 01148 // if (t.is_identity()) { 01149 for(int i = 0; i < get_nsym(); ++i ) { 01150 ret.push_back(get_sym(i)); 01151 } 01152 // } else { 01153 // for(int i = 0; i < get_nsym(); ++i ) { 01154 // ret.push_back(get_sym(i)*t); 01155 // } 01156 // } 01157 return ret; 01158 }
vector< Transform > Symmetry3D::get_touching_au_transforms | ( | bool | inc_mirror = true |
) | const [virtual] |
Gets a vector of Transform objects that define the set of asymmetric units that touch the default asymmetric unit.
The 'default asymmetric unit' is defined by the results of Symmetry3d::get_asym_unit_points and is sensitive to whether or not you want to include the mirror part of the asymmetric unit. This function is useful when used in conjunction with Symmetry3D::reduce, and particularly when finding the angular deviation of particles through different stages of iterative Single Particle Reconstruction This function could be expanded to work for an asymmetric unit number supplied by the user.
inc_mirror | whether or not to include the mirror portion of the asymmetric unit |
Definition at line 1075 of file symmetry.cpp.
References EMAN::EMConsts::deg2rad, get_asym_unit_points(), get_delimiters(), get_nsym(), get_sym(), is_d_sym(), is_platonic_sym(), EMAN::Vec3< Type >::squared_length(), t, x, and y.
01076 { 01077 vector<Transform> ret; 01078 vector<int> hit_cache; 01079 01080 vector<Vec3f> points = get_asym_unit_points(inc_mirror); 01081 // Warning, this is a gross hack because it is assuming that the asym_unit_points 01082 // returned by DSym are in a particular orientation with respect to symmetric axes 01083 // if the internals of DSym change it could change what we should do here... 01084 // but for the time being it will do 01085 if (inc_mirror && is_d_sym() && (get_nsym()/2 % 2 == 0)) { 01086 Dict delim = get_delimiters(false); 01087 float angle = (float)(EMConsts::deg2rad*float(delim["az_max"])); 01088 float y = -cos(angle); 01089 float x = sin(angle); 01090 points.push_back(Vec3f(x,y,0)); 01091 } 01092 else if ( is_d_sym() && (get_nsym()/2 % 2 == 1)) { 01093 Dict delim = get_delimiters(false); 01094 float angle = float(delim["az_max"])/2.0f; 01095 // cout << "Odd dsym using " << angle << endl; 01096 angle *= (float)EMConsts::deg2rad; 01097 float y = -cos(angle); 01098 float x = sin(angle); 01099 points.push_back(Vec3f(x,y,0)); 01100 01101 if ( inc_mirror ) { 01102 angle = 3.0f*(float(delim["az_max"]))/2.0f; 01103 angle *= (float)EMConsts::deg2rad; 01104 float y = -cos(angle); 01105 float x = sin(angle); 01106 points.push_back(Vec3f(x,y,0)); 01107 } 01108 } 01109 01110 typedef vector<Vec3f>::const_iterator const_point_it; 01111 for(const_point_it point = points.begin(); point != points.end(); ++point ) { 01112 01113 for(int i = 1; i < get_nsym(); ++i) { 01114 01115 if ( find(hit_cache.begin(),hit_cache.end(),i) != hit_cache.end() ) continue; 01116 Transform t = get_sym(i); 01117 Vec3f result = (*point)*t; 01118 01119 if (is_platonic_sym()) { 01120 for(const_point_it tmp = points.begin(); tmp != points.end(); ++tmp ) { 01121 Vec3f tt = result-(*tmp); 01122 if (tt.squared_length() < 0.01f) { 01123 hit_cache.push_back(i); 01124 ret.push_back(t); 01125 } 01126 01127 } 01128 } 01129 else { 01130 result -= *point; 01131 if (result.squared_length() < 0.05f) { 01132 hit_cache.push_back(i); 01133 ret.push_back(t); 01134 } 01135 } 01136 } 01137 01138 } 01139 01140 return ret; 01141 }
int Symmetry3D::in_which_asym_unit | ( | const Transform & | t3d | ) | const [virtual] |
A function that will determine in which asymmetric unit a given orientation resides The asymmetric unit 'number' will depend entirely on the order in which different symmetry operations are return by the Symmetry3D::get_sym function.
t3d | a Transform characterizing an orientation |
Definition at line 937 of file symmetry.cpp.
References EMAN::Transform::invert(), and point_in_which_asym_unit().
Referenced by reduce().
00938 { 00939 // Here it is assumed that final destination of the orientation (as encapsulated in the t3d object) is 00940 // in the z direction, so in essence we will start in the direction z and 'undo' the orientation to get the real 00941 // direction 00942 Vec3f p(0,0,1); 00943 00944 Transform o(t3d); 00945 // Orientations are alway transposed when dealing with asymmetric units, projections,etc 00946 // We take the transpose to 'undo' the transform and get the true direction of the point. 00947 o.invert(); 00948 // Figure out where the point would end up. No we could just as easily not transpose and do 00949 // left multiplation (as in what occurs in the FourierReconstructor during slice insertion) 00950 p = o*p; 00951 00952 return point_in_which_asym_unit(p); 00953 }
virtual bool EMAN::Symmetry3D::is_c_sym | ( | ) | const [inline, virtual] |
A function that is used to determine if this is a c symmetry object This function is only virtually overidden by the CSym object, which returns true.
Reimplemented in EMAN::CSym.
Definition at line 106 of file symmetry.h.
Referenced by EMAN::RandomOrientationGenerator::gen_orientations(), and EMAN::OrientationGenerator::get_az_max().
virtual bool EMAN::Symmetry3D::is_d_sym | ( | ) | const [inline, virtual] |
A function that is used to determine if this is a d symmetry object This function is only virtually overidden by the DSym object, which returns true.
Reimplemented in EMAN::DSym.
Definition at line 112 of file symmetry.h.
Referenced by EMAN::OrientationGenerator::get_az_max(), and get_touching_au_transforms().
virtual bool EMAN::Symmetry3D::is_h_sym | ( | ) | const [inline, virtual] |
A function that is used to determine if this is a Helical symmetry object This function is only virtually overidden by the HSym symmetry, which returns true, not false.
Reimplemented in EMAN::HSym.
Definition at line 100 of file symmetry.h.
Referenced by EMAN::SaffOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), EMAN::EmanOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::get_orientations_tally(), EMAN::EvenOrientationGenerator::get_orientations_tally(), and EMAN::EmanOrientationGenerator::get_orientations_tally().
virtual bool EMAN::Symmetry3D::is_in_asym_unit | ( | const float & | altitude, | |
const float & | azimuth, | |||
const bool | inc_mirror | |||
) | const [pure virtual] |
A function to be used when generating orientations over portion of the unit sphere defined by parameters returned by get_delimiters.
In platonic symmetry altitude and azimuth alone are not enough to correctly demarcate the asymmetric unit. See the get_delimiters comments.
altitude | the EMAN style altitude of the 3D orientation in degrees | |
azimuth | the EMAN style azimuth of the 3D orientation in degrees | |
inc_mirror | whether or not to include orientations if they are in the mirror portion of the asymmetric unit |
Implemented in EMAN::CSym, EMAN::DSym, EMAN::HSym, EMAN::PlatonicSym, and EMAN::TetrahedralSym.
Referenced by EMAN::OptimumOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), EMAN::RandomOrientationGenerator::gen_orientations(), EMAN::EmanOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::get_orientations_tally(), EMAN::EvenOrientationGenerator::get_orientations_tally(), and EMAN::EmanOrientationGenerator::get_orientations_tally().
virtual bool EMAN::Symmetry3D::is_platonic_sym | ( | ) | const [inline, virtual] |
A function that is used to determine if this is a platonic symmetry object This function is only virtually overidden by the PlatonicSym symmetry, which returns true, not false.
Reimplemented in EMAN::PlatonicSym.
Definition at line 94 of file symmetry.h.
Referenced by EMAN::SaffOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), EMAN::EmanOrientationGenerator::gen_orientations(), EMAN::OrientationGenerator::get_az_max(), EMAN::SaffOrientationGenerator::get_orientations_tally(), EMAN::EvenOrientationGenerator::get_orientations_tally(), EMAN::EmanOrientationGenerator::get_orientations_tally(), and get_touching_au_transforms().
virtual bool EMAN::Symmetry3D::is_tet_sym | ( | ) | const [inline, virtual] |
A function that is used to determine if this is the tetrahedral symmetry object This function is only virtually overidden by the TetSym object, which returns true.
Reimplemented in EMAN::TetrahedralSym.
Definition at line 118 of file symmetry.h.
Referenced by EMAN::OrientationGenerator::get_az_max().
Symmetry3D& EMAN::Symmetry3D::operator= | ( | const Symmetry3D & | ) | [private] |
Disallow assignment.
int Symmetry3D::point_in_which_asym_unit | ( | const Vec3f & | v | ) | const [virtual] |
A function that will determine in which asymmetric unit a given vector resides The asymmetric unit 'number' will depend entirely on the order in which different symmetry operations are return by the Symmetry3D::get_sym function The vector is a point.
v | a Vec3f characterizing a point |
Definition at line 1008 of file symmetry.cpp.
References au_sym_triangles, cache_au_planes(), cached_au_planes, EMAN::Vec3< Type >::dot(), EMAN::Transform::ERR_LIMIT, get_nsym(), num_triangles, t, and v.
Referenced by in_which_asym_unit(), and EMAN::AutoMaskAsymUnit::process_inplace().
01009 { 01010 if (cached_au_planes == 0) { 01011 cache_au_planes(); 01012 } 01013 01014 int k = 0; 01015 for(int i = 0; i < get_nsym(); ++i) { 01016 for( int j = 0; j < num_triangles; ++j,++k) { 01017 vector<Vec3f> points = au_sym_triangles[k]; 01018 01019 float* plane = cached_au_planes[k]; 01020 Vec3f tmp = p; 01021 01022 // Determine the intersection of p with the plane - do this by finding out how much p should be scaled by 01023 float scale = plane[0]*tmp[0]+plane[1]*tmp[1]+plane[2]*tmp[2]; 01024 if ( scale != 0 ) 01025 scale = -plane[3]/scale; 01026 else { 01027 // parralel! 01028 continue; 01029 } 01030 01031 // If the scale factor is less than zero, then p is definitely not in this asymmetric unit 01032 if (scale <= 0) continue; 01033 01034 // This is the intersection point 01035 Vec3f pp = tmp*scale; 01036 01037 // Now we have to see if the point p is inside the region bounded by the points, or if it is outside 01038 // If it is inside the region then p is in this asymmetric unit. 01039 01040 // This formula take from FIXME fill in once I get to work 01041 Vec3f v = points[2]-points[0]; 01042 Vec3f u = points[1]-points[0]; 01043 Vec3f w = pp - points[0]; 01044 01045 float udotu = u.dot(u); 01046 float udotv = u.dot(v); 01047 float udotw = u.dot(w); 01048 float vdotv = v.dot(v); 01049 float vdotw = v.dot(w); 01050 01051 float d = 1.0f/(udotv*udotv - udotu*vdotv); 01052 float s = udotv*vdotw - vdotv*udotw; 01053 s *= d; 01054 01055 float t = udotv*udotw - udotu*vdotw; 01056 t *= d; 01057 01058 // We've done a few multiplications, so detect when there are tiny residuals that may throw off the final 01059 // decision 01060 if (fabs(s) < Transform::ERR_LIMIT ) s = 0; 01061 if (fabs(t) < Transform::ERR_LIMIT ) t = 0; 01062 01063 if ( fabs((fabs(s)-1.0)) < Transform::ERR_LIMIT ) s = 1; 01064 if ( fabs((fabs(t)-1.0)) < Transform::ERR_LIMIT ) t = 1; 01065 01066 // The final decision, if this is true then we've hit the jackpot 01067 if ( s >= 0 && t >= 0 && (s+t) <= 1 ) { 01068 return i; 01069 } 01070 } 01071 } 01072 01073 return -1; 01074 }
vector< vector<Vec3f> > EMAN::Symmetry3D::au_sym_triangles [mutable, protected] |
This cache is of size cache_size.
Definition at line 214 of file symmetry.h.
Referenced by cache_au_planes(), and point_in_which_asym_unit().
int EMAN::Symmetry3D::cache_size [mutable, protected] |
Have to remember the cache size.
Definition at line 210 of file symmetry.h.
Referenced by cache_au_planes(), and delete_au_planes().
float** EMAN::Symmetry3D::cached_au_planes [mutable, protected] |
The asymmetric unit planes are cached to provide a great speed up the point_in_which_asym_unit function, which is called by reduce and by in_which_asym_unit.
Definition at line 207 of file symmetry.h.
Referenced by cache_au_planes(), delete_au_planes(), point_in_which_asym_unit(), and ~Symmetry3D().
int EMAN::Symmetry3D::num_triangles [mutable, protected] |
This is stores the number of triangles returned by get_asym_unit_triangles(true).
Definition at line 212 of file symmetry.h.
Referenced by cache_au_planes(), and point_in_which_asym_unit().