EMAN2
|
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of alignment parameters and euler orientations. More...
#include <transform.h>
Public Member Functions | |
Transform () | |
Default constructor Internal matrix is the identity. More... | |
Transform (const Transform &rhs) | |
Copy constructor. More... | |
Transform & | operator= (const Transform &that) |
Assignment operator. More... | |
bool | operator== (const Transform &rhs) const |
Equality comparision operator. More... | |
bool | operator!= (const Transform &rhs) const |
Unequality comparision operator. More... | |
Transform (const Dict &d) | |
Construction using a dictionary. More... | |
Transform (const float array[12]) | |
Construction using an array of floats. More... | |
Transform (const vector< float > array) | |
Construction using a vector of size 12. More... | |
~Transform () | |
void | set_rotation (const Dict &rotation) |
Set a rotation using a specific Euler type and the dictionary interface Works for all Euler types. More... | |
void | set_rotation (const Vec3f &v) |
Determine the rotation that would transform a vector pointing in the Z direction so that it points in the direction of the argument vector Automatically normalizes the vector. More... | |
void | rotate_origin (const Transform &by) |
Increment the rotation by multipling the rotation bit of the argument transfrom by the rotation part of the current transfrom. More... | |
void | rotate_origin_newBasis (const Transform &tcs, const float &omega, const float &n1, const float &n2, const float &n3) |
Increment the rotation by multipling the rotation bit of the argument transfrom by the rotation part of the current transfrom This version rotates in the standard coordinate system, even after it have been modified by tcs. More... | |
void | rotate (const Transform &by) |
Increment the rotation by multipling the rotation bit of the argument transfrom by the current transfrom. More... | |
Dict | get_rotation (const string &euler_type="eman") const |
Get a rotation in any Euler format. More... | |
Transform | get_rotation_transform () const |
Get the rotation part of the tranformation matrix as a Transform object. More... | |
Transform | get_hflip_transform () const |
How do I get the transform that will yield the horizontally flipped projection? More... | |
Transform | get_vflip_transform () const |
How do I get the transform that will yield the vertically flipped projection? More... | |
void | set_params (const Dict &d) |
Set the parameters of the entire transform. More... | |
void | set_params_inverse (const Dict &d) |
Set the parameters of the entire transform as though they there in the inverse format. More... | |
Dict | get_params (const string &euler_type) const |
Get the parameters of the entire transform, using a specific euler convention. More... | |
Dict | get_params_inverse (const string &euler_type) const |
Get the parameters of the inverse of the transform as though it were in RSMT order not MTSR. More... | |
void | set_trans (const float &x, const float &y, const float &z=0) |
Set the post translation component. More... | |
void | set_trans (const Vec3f &v) |
Set the post translation component using a Vec3f. More... | |
void | set_trans (const Vec2f &v) |
Set the post translation component using a Vec2f. More... | |
Vec3f | get_trans () const |
Get the post trans as a vec3f. More... | |
void | translate (const float &tx, const float &ty, const float &tz=0) |
Increment the current translation by tx, ty, tz. More... | |
void | translate (const Vec3f &v) |
Increment the current translation using vec3f& v. More... | |
void | translate (const Vec2f &v) |
Increment the current translation using vec2f& v. More... | |
void | translate_newBasis (const Transform &tcs, const float &tx, const float &ty, const float &tz=0) |
Increment the current translation by tx, ty, tz using a non standard basis Actualy what it does is remove the effect of tcs when a composite transfrom tcs*t (where t is the current transform) This function is used in the scenegraph. More... | |
void | translate (const Transform &tcs, const Vec3f &v) |
Increment the current translation using vec3f& v and a non standard basis. More... | |
Vec2f | get_trans_2d () const |
Get the degenerant 2D post trans as a vec2f. More... | |
Vec3f | get_pre_trans () const |
Get the translation vector as though this object was MSRT_ not MTSR, where T_ is what you want Note M means post x mirror, T means translation, S means scale, and R means rotaiton. More... | |
Vec2f | get_pre_trans_2d () const |
2D version of getting the translation vector as though this object was MSRT_ not MTSR, where T_ is what you want Note M means post x mirror, T means translation, S means scale, and R means rotation More... | |
template<typename type > | |
void | set_pre_trans (const type &v) |
Set the translational component of the matrix as though it was MSRT_ not MTSR, where T_ is the pre translation. More... | |
void | set_scale (const float &scale) |
Set the scale. More... | |
float | get_scale () const |
Get the scale that was applied. More... | |
void | scale (const float &scale) |
Increment the scale. More... | |
bool | get_mirror () const |
Query whether x_mirroring is occurring. More... | |
void | set_mirror (const bool x_mirror) |
Set whether or not x_mirroring is occurring. More... | |
void | get_scale_and_mirror (float &scale, bool &x_mirror) const |
Get scale and x_mirror with 1 function call. More... | |
void | to_identity () |
Force the internal matrix to become the identity. More... | |
bool | is_identity () const |
Returns whethers or this matrix is the identity. More... | |
bool | is_rot_identity () const |
Returns whethers or this matrix rotation is the identity. More... | |
void | orthogonalize () |
Reorthogonalize the rotation part of the matrix in place. More... | |
float | get_determinant () const |
Get the determinant of the matrix. More... | |
void | printme () const |
Print the contents of the internal matrix verbatim to standard out. More... | |
void | set_matrix (const vector< float > &v) |
Set the transformation matrix using a vector. More... | |
string | get_matrix_string (int precision) |
vector< float > | get_matrix () const |
Get the transformation matrix using a vector. More... | |
vector< float > | get_matrix_4x4 () const |
Get the 4x4 transformation matrix using a vector. More... | |
void | invert () |
Get the inverse of this transformation matrix. More... | |
Transform | inverse () const |
Get the inverse of this transformation matrix. More... | |
void | transpose_inplace () |
Get the transpose of this transformation matrix. More... | |
Transform | transpose () const |
Get the transpose of this transformation matrix. More... | |
float | at (int r, int c) const |
Get the value stored in the internal transformation matrix at at coordinate (r,c) More... | |
void | set (int r, int c, float value) |
Set the value stored in the internal transformation matrix at at coordinate (r,c) to value. More... | |
float * | operator[] (int i) |
Operator[] convenience so Transform3D[2][2] etc terminology can be used. More... | |
const float * | operator[] (int i) const |
Operator[] convenience so Transform3D[2][2] etc terminology can be used. More... | |
Vec2f | transform (const float &x, const float &y) const |
Transform 2D coordinates using the internal transformation matrix. More... | |
template<typename Type > | |
Vec2f | transform (const Vec2< Type > &v) const |
Transform a 2D vector using the internal transformation matrix. More... | |
Vec3f | transform (const float &x, const float &y, const float &z) const |
Transform 3D coordinates using the internal transformation matrix. More... | |
template<typename Type > | |
Vec3f | transform (const Vec3< Type > &v) const |
Transform a 3D vector using the internal transformation matrix. More... | |
Vec3f | get_matrix3_row (int i) const |
Get a matrix row as a Vec3f required for back compatibility with Tranform3D - see PawelProjector. More... | |
Transform | get_sym (const string &sym, int n) const |
Apply the symmetry deduced from the function arguments to this Transform and return the result. More... | |
Transform | get_sym_sparx (const string &sym, int n) const |
vector< Transform > | get_sym_proj (const string &sym) const |
void | copy_matrix_into_array (float *const) const |
Transform | negate () const |
Negates the Transform - a useful way, for example, for getting an orientation on the opposite side of the sphere. More... | |
Static Public Member Functions | |
static int | get_nsym (const string &sym) |
get the number of symmetries associated with the given symmetry name More... | |
static Transform | tet_3_to_2 () |
Get the transform that moves any tetrahedron generated by eman2 so that it matches the 2-2-2 (MRC, FREALIGN) convention. More... | |
static Transform | icos_5_to_2 () |
Get the transform that moves any icosahedron generated by eman2 so that it matches the 2-2-2 (MRC, FREALIGN) convention. More... | |
Static Public Attributes | |
static const float | ERR_LIMIT = 0.000001f |
Private Member Functions | |
void | assert_valid_2d () const |
void | init_permissable_keys () |
Called internally to initialize permissable_2d_not_rot, permissable_3d_not_rot, and permissable_rot_keys static members. More... | |
void | detect_problem_keys (const Dict &d) |
Test to ensure the parametes in the given dictionary are valid Throws if an error is detected Generic - works in every circumstance (set_params, set_rotation, set_params_inv) Uses static members permissable_2d_not_rot, permissable_3d_not_rot, and permissable_rot_keys as basis of decision. More... | |
Private Attributes | |
float | matrix [3][4] |
Static Private Attributes | |
static vector< string > | permissable_2d_not_rot |
This map is used to validate keys in the argument maps - e.g. if the type is 2d and the angle is not "alpha" then we should throw. More... | |
static vector< string > | permissable_3d_not_rot |
static map< string, vector< string > > | permissable_rot_keys |
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of alignment parameters and euler orientations.
It's designed to store four transformations in a specific order, namely Transform = MTSR Where M is a mirroring operation (about the x-axis) or the identity T is a Translation matrix S is a uniform scaling matrix R is a rotation matrix This means you can call set_scale, set_trans, set_rotation in any order but still have the operations arranged internally in the order of MTSR. This is somewhat restrictive, for example in the context of how OpenGL handles transformations, but in practice is nicely suited to the situations that arise in EMAN2 - namely, alignment and projection orientation characterization.
Note that you can fool the Transform object into storing any matrix by using the constructors that take array arguments. This can useful, for example, for shearing your image.
See http://blake.bcm.tmc.edu/emanwiki/Eman2TransformInPython for using it from Python and detailed discussion See test_transform.py for examples of the way it is unit tested See http://blake.bcm.tmc.edu/emanwiki/EMAN2/Tutorials/RotateTranslate for examples showing how to transform EMDatas with it.
Definition at line 75 of file transform.h.
Transform::Transform | ( | ) |
Default constructor Internal matrix is the identity.
Definition at line 100 of file transform.cpp.
References to_identity().
Referenced by rotate_origin_newBasis(), set_params_inverse(), and translate_newBasis().
Transform::Transform | ( | const Transform & | rhs | ) |
Copy constructor.
rhs | the object to be copied |
Definition at line 105 of file transform.cpp.
Transform::Transform | ( | const Dict & | d | ) |
Construction using a dictionary.
d | the dictionary containing the parameters |
Definition at line 132 of file transform.cpp.
References set_params(), and to_identity().
Transform::Transform | ( | const float | array[12] | ) |
Construction using an array of floats.
array | the array of values that will become the internal matrix. row order (3 rows of 4) |
Definition at line 138 of file transform.cpp.
References matrix.
Transform::Transform | ( | const vector< float > | array | ) |
Construction using a vector of size 12.
array | the array of values that will become the internal matrix. row order (3 rows of 4) |
Definition at line 142 of file transform.cpp.
References set_matrix().
|
inline |
Definition at line 123 of file transform.h.
|
private |
Definition at line 1366 of file transform.cpp.
References ERR_LIMIT, matrix, and UnexpectedBehaviorException.
Referenced by get_rotation(), and set_rotation().
|
inline |
Get the value stored in the internal transformation matrix at at coordinate (r,c)
Definition at line 396 of file transform.h.
References matrix.
Referenced by EMAN::PawelProjector::backproject3d().
void Transform::copy_matrix_into_array | ( | float * const | array | ) | const |
Definition at line 158 of file transform.cpp.
References matrix.
Referenced by EMAN::FourierReconstructor::do_compare_slice_work(), EMAN::FourierReconstructor::do_insert_slice_work(), EMAN::TransformProcessor::process(), EMAN::TransformProcessor::process_inplace(), and EMAN::StandardProjector::project3d().
|
private |
Test to ensure the parametes in the given dictionary are valid Throws if an error is detected Generic - works in every circumstance (set_params, set_rotation, set_params_inv) Uses static members permissable_2d_not_rot, permissable_3d_not_rot, and permissable_rot_keys as basis of decision.
d | the dictionary that was the function argument of the set_params, set_rotation or the set_params_inv function |
InvalidParameterException | if the dictionary is invalid in anyway |
Definition at line 369 of file transform.cpp.
References EMAN::Dict::begin(), copy(), EMAN::Dict::end(), EMAN::Dict::has_key_ci(), init_permissable_keys(), InvalidParameterException, permissable_2d_not_rot, permissable_3d_not_rot, permissable_rot_keys, and EMAN::Util::str_to_lower().
Referenced by set_params(), set_params_inverse(), and set_rotation().
float Transform::get_determinant | ( | ) | const |
Get the determinant of the matrix.
Definition at line 1279 of file transform.cpp.
References EMAN::Util::apply_precision(), ERR_LIMIT, and matrix.
Referenced by get_mirror(), get_scale(), get_scale_and_mirror(), and scale().
Transform Transform::get_hflip_transform | ( | ) | const |
How do I get the transform that will yield the horizontally flipped projection?
Definition at line 792 of file transform.cpp.
References get_rotation(), get_trans(), set_rotation(), and set_trans().
vector< float > Transform::get_matrix | ( | ) | const |
Get the transformation matrix using a vector.
Definition at line 181 of file transform.cpp.
References matrix.
Referenced by EMAN::EMData::extract_box(), rotate(), and rotate_origin().
|
inline |
Get a matrix row as a Vec3f required for back compatibility with Tranform3D - see PawelProjector.
i | the row number (starting at 0) |
Definition at line 465 of file transform.h.
References matrix.
Referenced by EMAN::PawelProjector::project3d().
vector< float > Transform::get_matrix_4x4 | ( | ) | const |
Get the 4x4 transformation matrix using a vector.
Definition at line 192 of file transform.cpp.
References matrix.
string Transform::get_matrix_string | ( | int | precision | ) |
Definition at line 169 of file transform.cpp.
References matrix.
bool Transform::get_mirror | ( | ) | const |
Query whether x_mirroring is occurring.
Definition at line 1250 of file transform.cpp.
References get_determinant().
Referenced by get_params(), get_params_inverse(), get_trans(), get_trans_2d(), EMAN::GaussFFTProjector::project3d(), set_mirror(), set_trans(), EMAN::TransformProcessor::transform(), translate(), and EMAN::RT2DTreeAligner::xform_align_nbest().
|
static |
get the number of symmetries associated with the given symmetry name
Definition at line 1570 of file transform.cpp.
References EMAN::Factory< T >::get(), and EMAN::Symmetry3D::get_nsym().
Referenced by EMAN::PointArray::set_from(), EMAN::nn4Reconstructor::setup(), EMAN::nn4_rectReconstructor::setup(), EMAN::nnSSNR_Reconstructor::setup(), EMAN::nn4_ctfReconstructor::setup(), EMAN::nnSSNR_ctfReconstructor::setup(), EMAN::nn4_ctfwReconstructor::setup(), EMAN::nn4_ctfwsReconstructor::setup(), and EMAN::nn4_ctf_rectReconstructor::setup().
Dict Transform::get_params | ( | const string & | euler_type | ) | const |
Get the parameters of the entire transform, using a specific euler convention.
euler_type | the euler type of the retrieved rotation |
Definition at line 479 of file transform.cpp.
References get_mirror(), get_rotation(), get_scale(), get_trans(), scale(), and EMAN::Util::str_to_lower().
Referenced by EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::RT3DLocalTreeAligner::testort(), EMAN::RT2Dto3DTreeAligner::testort(), EMAN::RT3DTreeAligner::testort(), EMAN::SpiderIO::write_single_header(), EMAN::RT2Dto3DTreeAligner::xform_align_nbest(), EMAN::RT3DTreeAligner::xform_align_nbest(), and EMAN::RT3DLocalTreeAligner::xform_align_nbest().
Dict Transform::get_params_inverse | ( | const string & | euler_type | ) | const |
Get the parameters of the inverse of the transform as though it were in RSMT order not MTSR.
euler_type | the euler type of the retrieved rotation |
Definition at line 499 of file transform.cpp.
References get_mirror(), get_pre_trans(), get_rotation(), get_scale(), inverse(), scale(), and EMAN::Util::str_to_lower().
Vec3f Transform::get_pre_trans | ( | ) | const |
Get the translation vector as though this object was MSRT_ not MTSR, where T_ is what you want Note M means post x mirror, T means translation, S means scale, and R means rotaiton.
Definition at line 1100 of file transform.cpp.
References get_trans(), invert(), and set_trans().
Referenced by get_params_inverse().
Vec2f Transform::get_pre_trans_2d | ( | ) | const |
2D version of getting the translation vector as though this object was MSRT_ not MTSR, where T_ is what you want Note M means post x mirror, T means translation, S means scale, and R means rotation
Definition at line 1111 of file transform.cpp.
References get_trans_2d(), invert(), and set_trans().
Dict Transform::get_rotation | ( | const string & | euler_type = "eman" | ) | const |
Get a rotation in any Euler format.
euler_type | the requested Euler type |
Definition at line 829 of file transform.cpp.
References assert_valid_2d(), EMAN::EMConsts::deg2rad, get_scale_and_mirror(), InvalidStringException, matrix, EMAN::EMConsts::rad2deg, scale(), sqrt(), EMAN::Util::str_to_lower(), and UnexpectedBehaviorException.
Referenced by EMAN::file_store::add_image(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), get_hflip_transform(), get_params(), get_params_inverse(), get_vflip_transform(), EMAN::FourierReconstructorSimple2D::insert_slice(), EMAN::FourierGriddingProjector::project3d(), EMAN::ChaoProjector::project3d(), set_pre_trans(), EMAN::TransformProcessor::transform(), EMAN::RT2Dto3DTreeAligner::xform_align_nbest(), EMAN::RT3DTreeAligner::xform_align_nbest(), EMAN::RT3DLocalTreeAligner::xform_align_nbest(), and EMAN::RT3DSymmetryAligner::xform_align_nbest().
Transform Transform::get_rotation_transform | ( | ) | const |
Get the rotation part of the tranformation matrix as a Transform object.
Definition at line 688 of file transform.cpp.
References set_mirror(), set_scale(), and set_trans().
Referenced by EMAN::GaussFFTProjector::project3d().
float Transform::get_scale | ( | ) | const |
Get the scale that was applied.
Definition at line 1145 of file transform.cpp.
References EMAN::Util::apply_precision(), ERR_LIMIT, get_determinant(), and scale().
Referenced by get_params(), get_params_inverse(), EMAN::TransformProcessor::process(), EMAN::TransformProcessor::process_inplace(), EMAN::GaussFFTProjector::project3d(), set_pre_trans(), and set_scale().
void Transform::get_scale_and_mirror | ( | float & | scale, |
bool & | x_mirror | ||
) | const |
Get scale and x_mirror with 1 function call.
More efficient than calling get_scale and get_x_mirror separately
scale | a reference to the value that will be assigned the scale value |
x_mirror | a reference to the value that will be assigned the x_mirror value |
Definition at line 1260 of file transform.cpp.
References EMAN::Util::apply_precision(), ERR_LIMIT, get_determinant(), and scale().
Referenced by get_rotation(), orthogonalize(), and set_rotation().
Transform Transform::get_sym | ( | const string & | sym, |
int | n | ||
) | const |
Apply the symmetry deduced from the function arguments to this Transform and return the result.
Definition at line 1389 of file transform.cpp.
References EMAN::Factory< T >::get(), and EMAN::Symmetry3D::get_sym().
Referenced by EMAN::PointArray::set_from().
vector< Transform > Transform::get_sym_proj | ( | const string & | sym | ) | const |
Definition at line 1407 of file transform.cpp.
References EMAN::Factory< T >::get(), EMAN::Symmetry3D::get_nsym(), EMAN::Symmetry3D::get_sym(), matrix, and EMAN::Util::str_to_lower().
Referenced by get_sym_sparx(), EMAN::nn4Reconstructor::insert_padfft_slice(), EMAN::nn4_rectReconstructor::insert_padfft_slice(), EMAN::nnSSNR_Reconstructor::insert_padfft_slice(), EMAN::nnSSNR_ctfReconstructor::insert_padfft_slice(), EMAN::nn4_ctf_rectReconstructor::insert_padfft_slice(), EMAN::nn4_ctfReconstructor::insert_padfft_slice(), EMAN::nn4_ctfwReconstructor::insert_padfft_slice_weighted(), and EMAN::nn4_ctfwsReconstructor::insert_padfft_slice_weighted().
Transform Transform::get_sym_sparx | ( | const string & | sym, |
int | n | ||
) | const |
Definition at line 1398 of file transform.cpp.
References get_sym_proj().
Vec3f Transform::get_trans | ( | ) | const |
Get the post trans as a vec3f.
Definition at line 1046 of file transform.cpp.
References EMAN::Util::apply_precision(), ERR_LIMIT, get_mirror(), and matrix.
Referenced by get_hflip_transform(), get_params(), get_pre_trans(), get_vflip_transform(), EMAN::ACFCenterProcessor::process_inplace(), EMAN::GaussFFTProjector::project3d(), EMAN::FourierReconstructor::projection(), rotate_origin_newBasis(), set_params_inverse(), set_pre_trans(), EMAN::RT3DLocalTreeAligner::testort(), EMAN::RT2Dto3DTreeAligner::testort(), EMAN::RT3DTreeAligner::testort(), EMAN::TransformProcessor::transform(), translate_newBasis(), EMAN::RT2Dto3DTreeAligner::xform_align_nbest(), EMAN::RT3DTreeAligner::xform_align_nbest(), and EMAN::RT3DLocalTreeAligner::xform_align_nbest().
Vec2f Transform::get_trans_2d | ( | ) | const |
Get the degenerant 2D post trans as a vec2f.
Definition at line 1088 of file transform.cpp.
References get_mirror(), and matrix.
Referenced by get_pre_trans_2d(), and EMAN::padfft_slice().
Transform Transform::get_vflip_transform | ( | ) | const |
How do I get the transform that will yield the vertically flipped projection?
Definition at line 811 of file transform.cpp.
References get_rotation(), get_trans(), set_rotation(), and set_trans().
|
static |
Get the transform that moves any icosahedron generated by eman2 so that it matches the 2-2-2 (MRC, FREALIGN) convention.
Doctor Steve says Phil's answer put the 2-fold in the wrong place based on the standard Virus convention (empirically). It was also 2 to 5 not 5 to 2. It is possible to rotate to a 2-fold directly from a 5-fold, though there are 2 possible orientations for the 2-2-2 convention, and this finds only one of them :^(
Doctor Phil says: alt = (acos(cos(pi/5)/sqrt(3)/sin(pi/5)) + acos(2*cos(pi/5)/ sqrt(3) ) )*180/pi This is the angle between a 5 and a 3 plus the angle between a 3 and a 2
Definition at line 63 of file transform.cpp.
References set_rotation().
|
private |
Called internally to initialize permissable_2d_not_rot, permissable_3d_not_rot, and permissable_rot_keys static members.
Definition at line 285 of file transform.cpp.
References permissable_2d_not_rot, permissable_3d_not_rot, and permissable_rot_keys.
Referenced by detect_problem_keys().
Transform Transform::inverse | ( | ) | const |
Get the inverse of this transformation matrix.
Definition at line 1327 of file transform.cpp.
References invert().
Referenced by get_params_inverse(), EMAN::BackProjectionReconstructor::insert_slice(), EMAN::EMData::max_3D_pixel_error(), EMAN::TransformProcessor::process(), EMAN::TransformProcessor::process_inplace(), EMAN::RotateInFSProcessor::process_inplace(), EMAN::MaxValProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::RT3DLocalTreeAligner::testort(), EMAN::RT2Dto3DTreeAligner::testort(), EMAN::RT3DTreeAligner::testort(), EMAN::TransformProcessor::transform(), EMAN::RT2Dto3DTreeAligner::xform_align_nbest(), EMAN::RT3DTreeAligner::xform_align_nbest(), and EMAN::RT3DLocalTreeAligner::xform_align_nbest().
void Transform::invert | ( | ) |
Get the inverse of this transformation matrix.
Definition at line 1293 of file transform.cpp.
Referenced by get_pre_trans(), get_pre_trans_2d(), EMAN::Symmetry3D::in_which_asym_unit(), inverse(), EMAN::GaussFFTProjector::project3d(), EMAN::Symmetry3D::reduce(), rotate_origin_newBasis(), set_params_inverse(), set_pre_trans(), translate_newBasis(), EMAN::RT3DSphereAligner::xform_align_nbest(), EMAN::RT3DTreeAligner::xform_align_nbest(), and EMAN::RT3DLocalTreeAligner::xform_align_nbest().
bool Transform::is_identity | ( | ) | const |
Returns whethers or this matrix is the identity.
Definition at line 222 of file transform.cpp.
References EMAN::Util::apply_precision(), ERR_LIMIT, and matrix.
Referenced by EMAN::TestTomoImage::insert_rectangle(), EMAN::FourierReconstructor::preprocess_slice(), and EMAN::FourierIterReconstructor::preprocess_slice().
bool Transform::is_rot_identity | ( | ) | const |
Returns whethers or this matrix rotation is the identity.
Definition at line 238 of file transform.cpp.
References EMAN::Util::apply_precision(), ERR_LIMIT, and matrix.
Transform Transform::negate | ( | ) | const |
Negates the Transform - a useful way, for example, for getting an orientation on the opposite side of the sphere.
Definition at line 781 of file transform.cpp.
References set().
bool Transform::operator!= | ( | const Transform & | rhs | ) | const |
Unequality comparision operator.
rhs | the Transform object compared to |
Definition at line 128 of file transform.cpp.
References operator==().
Assignment operator.
that | that which this will become |
Definition at line 110 of file transform.cpp.
References matrix.
bool Transform::operator== | ( | const Transform & | rhs | ) | const |
Equality comparision operator.
rhs | the Transform object compared to |
Definition at line 119 of file transform.cpp.
References matrix.
Referenced by operator!=().
|
inline |
Operator[] convenience so Transform3D[2][2] etc terminology can be used.
Definition at line 405 of file transform.h.
References matrix.
|
inline |
Operator[] convenience so Transform3D[2][2] etc terminology can be used.
Definition at line 410 of file transform.h.
References matrix.
void Transform::orthogonalize | ( | ) |
Reorthogonalize the rotation part of the matrix in place.
Does this by performing the SVD decomposition of the rotation matrix R such that R = USV^T - since the eigenvalues of a rotation matrix are all 1 we enforce that S should be the identity and produce a corrected matrix R' = UV^T
Definition at line 1179 of file transform.cpp.
References get_scale_and_mirror(), matrix, scale(), UnexpectedBehaviorException, and V.
|
inline |
Print the contents of the internal matrix verbatim to standard out.
Definition at line 348 of file transform.h.
References matrix.
void Transform::rotate | ( | const Transform & | by | ) |
Increment the rotation by multipling the rotation bit of the argument transfrom by the current transfrom.
rotation | multiplican, a tranform, R'', by which to multiply the current one, R' == R''R' |
Definition at line 763 of file transform.cpp.
References get_matrix(), and matrix.
void Transform::rotate_origin | ( | const Transform & | by | ) |
Increment the rotation by multipling the rotation bit of the argument transfrom by the rotation part of the current transfrom.
by | multiplican, a tranform, R'', by which to multiply the current one, R' == R''R' |
Definition at line 720 of file transform.cpp.
References get_matrix(), and matrix.
Referenced by rotate_origin_newBasis().
void Transform::rotate_origin_newBasis | ( | const Transform & | tcs, |
const float & | omega, | ||
const float & | n1, | ||
const float & | n2, | ||
const float & | n3 | ||
) |
Increment the rotation by multipling the rotation bit of the argument transfrom by the rotation part of the current transfrom This version rotates in the standard coordinate system, even after it have been modified by tcs.
The effect is to undo the distortion casued by dcs. Useful in the scenegraph
tcs,the | stansfrom that moves us to a non standard coordinate system |
by | multiplican, a tranform, R'', by which to multiply the current one, R' == R''R' |
Definition at line 738 of file transform.cpp.
References get_trans(), invert(), rotate_origin(), set_scale(), set_trans(), and Transform().
void Transform::scale | ( | const float & | scale | ) |
Increment the scale.
scale | the amount increment by |
Definition at line 1159 of file transform.cpp.
References get_determinant(), scale(), and set_scale().
Referenced by get_params(), get_params_inverse(), get_rotation(), get_scale(), get_scale_and_mirror(), orthogonalize(), scale(), set_params(), set_params_inverse(), set_pre_trans(), and set_rotation().
|
inline |
Set the value stored in the internal transformation matrix at at coordinate (r,c) to value.
Definition at line 400 of file transform.h.
References matrix.
Referenced by EMAN::PointArray::align_2d(), and negate().
void Transform::set_matrix | ( | const vector< float > & | v | ) |
Set the transformation matrix using a vector.
Must be of length 12.
v | the transformation matrix stored as a vector - 3 rows of 4. |
Definition at line 147 of file transform.cpp.
References InvalidParameterException, and matrix.
Referenced by EMAN::EMObject::operator Transform *(), and Transform().
void Transform::set_mirror | ( | const bool | x_mirror | ) |
Set whether or not x_mirroring is occurring.
x_mirror | whether x_mirroring should be applied |
Definition at line 1238 of file transform.cpp.
References get_mirror(), and matrix.
Referenced by EMAN::FourierReconstructor::determine_slice_agreement(), EMAN::WienerFourierReconstructor::determine_slice_agreement(), get_rotation_transform(), EMAN::FourierReconstructor::insert_slice(), EMAN::WienerFourierReconstructor::insert_slice(), EMAN::FourierIterReconstructor::insert_slice(), EMAN::FourierReconstructor::projection(), refalifn(), set_params(), and set_params_inverse().
void Transform::set_params | ( | const Dict & | d | ) |
Set the parameters of the entire transform.
keys acted upon are "type" - if this exists then the correct euler angles need to be included - also "tx","ty","tz", "scale", and "mirror"
d | the dictionary containing the parameters |
Definition at line 254 of file transform.cpp.
References EMAN::EMObject::BOOL, detect_problem_keys(), EMAN::Dict::get_ci(), EMAN::EMObject::get_type(), EMAN::Dict::has_key_ci(), EMAN::EMObject::INT, InvalidParameterException, scale(), set_mirror(), set_rotation(), set_scale(), set_trans(), and EMAN::EMObject::UNSIGNEDINT.
Referenced by EMAN::RT3DLocalTreeAligner::testort(), EMAN::RT2Dto3DTreeAligner::testort(), EMAN::RT3DTreeAligner::testort(), Transform(), EMAN::RT2DTreeAligner::xform_align_nbest(), EMAN::RT2Dto3DTreeAligner::xform_align_nbest(), EMAN::RT3DTreeAligner::xform_align_nbest(), and EMAN::RT3DLocalTreeAligner::xform_align_nbest().
void Transform::set_params_inverse | ( | const Dict & | d | ) |
Set the parameters of the entire transform as though they there in the inverse format.
in other words, calling set_params_inverse(get_params_inverse()) should essentially leave the object unchanged.
d | the dictionary containing the inverse parameters |
Definition at line 425 of file transform.cpp.
References EMAN::EMObject::BOOL, detect_problem_keys(), EMAN::Dict::get_ci(), get_trans(), EMAN::EMObject::get_type(), EMAN::Dict::has_key_ci(), EMAN::EMObject::INT, InvalidParameterException, invert(), scale(), set_mirror(), set_rotation(), set_scale(), set_trans(), Transform(), and EMAN::EMObject::UNSIGNEDINT.
void EMAN::Transform::set_pre_trans | ( | const type & | v | ) |
Set the translational component of the matrix as though it was MSRT_ not MTSR, where T_ is the pre translation.
Internally the correct form of MTSR is computed.
v | the vector (Vec3f or Vec2f) that is the pre trans |
Definition at line 556 of file transform.h.
References get_rotation(), get_scale(), get_trans(), invert(), scale(), set_rotation(), set_scale(), and set_trans().
Referenced by EMAN::PointArray::align_2d(), and EMAN::EMData::rotate_translate().
void Transform::set_rotation | ( | const Dict & | rotation | ) |
Set a rotation using a specific Euler type and the dictionary interface Works for all Euler types.
rotation | a dictionary containing all key-entry pair required of the associated Euler type |
Definition at line 519 of file transform.cpp.
References assert_valid_2d(), EMAN::EMConsts::deg2rad, detect_problem_keys(), EMAN::Dict::get_ci(), get_scale_and_mirror(), EMAN::Dict::has_key_ci(), EMAN::Util::hypot3(), InvalidParameterException, InvalidStringException, matrix, scale(), EMAN::Util::str_to_lower(), and UnexpectedBehaviorException.
Referenced by EMAN::PointArray::calc_transform(), get_hflip_transform(), get_vflip_transform(), icos_5_to_2(), EMAN::FourierReconstructor::preprocess_slice(), EMAN::FourierIterReconstructor::preprocess_slice(), EMAN::TransformProcessor::process(), EMAN::TransformProcessor::process_inplace(), EMAN::TestTomoImage::process_inplace(), EMAN::EMData::rotate_translate(), set_params(), set_params_inverse(), set_pre_trans(), set_rotation(), and tet_3_to_2().
void Transform::set_rotation | ( | const Vec3f & | v | ) |
Determine the rotation that would transform a vector pointing in the Z direction so that it points in the direction of the argument vector Automatically normalizes the vector.
v | the direction you want to solve for |
Definition at line 698 of file transform.cpp.
References EMAN::Vec3< Type >::normalize(), EMAN::EMConsts::rad2deg, set_rotation(), and UnexpectedBehaviorException.
void Transform::set_scale | ( | const float & | scale | ) |
Set the scale.
scale | the amount to scale by |
Definition at line 1123 of file transform.cpp.
References EMAN::Util::apply_precision(), ERR_LIMIT, get_scale(), InvalidValueException, and matrix.
Referenced by EMAN::ScaleAlignerABS::align_using_base(), EMAN::FourierReconstructor::determine_slice_agreement(), EMAN::WienerFourierReconstructor::determine_slice_agreement(), get_rotation_transform(), EMAN::FourierReconstructor::insert_slice(), EMAN::WienerFourierReconstructor::insert_slice(), EMAN::FourierIterReconstructor::insert_slice(), EMAN::ScaleTransformProcessor::process(), EMAN::ScaleTransformProcessor::process_inplace(), EMAN::FourierReconstructor::projection(), refalifn(), rotate_origin_newBasis(), scale(), EMAN::EMData::scale(), set_params(), set_params_inverse(), and set_pre_trans().
void Transform::set_trans | ( | const float & | x, |
const float & | y, | ||
const float & | z = 0 |
||
) |
Set the post translation component.
x | the x translation |
y | the y translation |
z | the z translation |
Definition at line 1036 of file transform.cpp.
References get_mirror(), matrix, x, and y.
Referenced by EMAN::PointArray::calc_transform(), EMAN::FourierReconstructor::determine_slice_agreement(), EMAN::WienerFourierReconstructor::determine_slice_agreement(), EMAN::TestUtil::emobject_transformarray_to_py(), EMAN::TestUtil::get_debug_transform(), get_hflip_transform(), get_pre_trans(), get_pre_trans_2d(), get_rotation_transform(), EMAN::HSym::get_sym(), get_vflip_transform(), EMAN::FourierReconstructor::insert_slice(), EMAN::WienerFourierReconstructor::insert_slice(), EMAN::FourierIterReconstructor::insert_slice(), EMAN::TransformProcessor::process(), EMAN::TransformProcessor::process_inplace(), EMAN::PhaseToMassCenterProcessor::process_inplace(), EMAN::ToCenterProcessor::process_inplace(), EMAN::ToMassCenterProcessor::process_inplace(), EMAN::TestTomoImage::process_inplace(), EMAN::FourierReconstructor::projection(), refalifn(), refalin3d_perturbquat(), rotate_origin_newBasis(), EMAN::EMData::rotate_translate(), set_params(), set_params_inverse(), set_pre_trans(), EMAN::RT3DLocalTreeAligner::testort(), EMAN::RT3DTreeAligner::testort(), EMAN::EMData::translate(), translate_newBasis(), EMAN::RT3DGridAligner::xform_align_nbest(), EMAN::RT3DSphereAligner::xform_align_nbest(), EMAN::RT2DTreeAligner::xform_align_nbest(), EMAN::RT2Dto3DTreeAligner::xform_align_nbest(), EMAN::RT3DTreeAligner::xform_align_nbest(), and EMAN::RT3DLocalTreeAligner::xform_align_nbest().
|
inline |
Set the post translation component using a Vec2f.
v | the 2D translation vector |
Definition at line 221 of file transform.h.
References set_trans().
Referenced by set_trans().
|
inline |
Set the post translation component using a Vec3f.
v | the 3D translation vector |
Definition at line 216 of file transform.h.
References set_trans().
Referenced by set_trans().
|
static |
Get the transform that moves any tetrahedron generated by eman2 so that it matches the 2-2-2 (MRC, FREALIGN) convention.
Doctor Phil says: AltAngle= acos(-1/3.0)*90/pi;
Definition at line 85 of file transform.cpp.
References set_rotation().
void Transform::to_identity | ( | ) |
Force the internal matrix to become the identity.
Definition at line 207 of file transform.cpp.
References matrix.
Referenced by Transform().
|
inline |
Transform 2D coordinates using the internal transformation matrix.
x | the x coordinate of the transformed point |
y | the y coordinate of the transformed point |
Definition at line 417 of file transform.h.
Referenced by EMAN::EMData::get_rotated_clip(), EMAN::operator*(), EMAN::SegmentSubunitProcessor::process_inplace(), and transform().
|
inline |
Transform 3D coordinates using the internal transformation matrix.
x | the x coordinate of the transformed point |
y | the y coordinate of the transformed point |
z | the z coordinate of the transformed point |
Definition at line 440 of file transform.h.
Transform a 2D vector using the internal transformation matrix.
v | a two dimensional vector to be transformed |
Definition at line 430 of file transform.h.
References transform().
Transform a 3D vector using the internal transformation matrix.
v | a three dimensional vector to be transformed |
Definition at line 454 of file transform.h.
References transform().
void Transform::translate | ( | const float & | tx, |
const float & | ty, | ||
const float & | tz = 0 |
||
) |
Increment the current translation by tx, ty, tz.
tx | the x incrementation |
ty | the y incrementation |
tz | the z incrementation |
Definition at line 1063 of file transform.cpp.
References get_mirror(), and matrix.
Referenced by translate_newBasis().
Increment the current translation using vec3f& v and a non standard basis.
v | the 3D translation vector |
Definition at line 258 of file transform.h.
References translate_newBasis().
|
inline |
Increment the current translation using vec2f& v.
v | the @D translation vector |
Definition at line 243 of file transform.h.
References translate().
Referenced by translate().
|
inline |
Increment the current translation using vec3f& v.
v | the 3D translation vector |
Definition at line 238 of file transform.h.
References translate().
Referenced by translate().
void Transform::translate_newBasis | ( | const Transform & | tcs, |
const float & | tx, | ||
const float & | ty, | ||
const float & | tz = 0 |
||
) |
Increment the current translation by tx, ty, tz using a non standard basis Actualy what it does is remove the effect of tcs when a composite transfrom tcs*t (where t is the current transform) This function is used in the scenegraph.
tcs | the transform specifing the new basis vectors |
tx | the x incrementation |
ty | the y incrementation |
tz | the z incrementation |
Definition at line 1072 of file transform.cpp.
References get_trans(), invert(), set_trans(), Transform(), and translate().
Referenced by translate().
Transform Transform::transpose | ( | ) | const |
Get the transpose of this transformation matrix.
Definition at line 1346 of file transform.cpp.
References transpose_inplace().
Referenced by EMAN::PDBReader::right_transform().
void Transform::transpose_inplace | ( | ) |
Get the transpose of this transformation matrix.
Definition at line 1333 of file transform.cpp.
References matrix.
Referenced by transpose().
|
static |
Definition at line 78 of file transform.h.
Referenced by assert_valid_2d(), get_determinant(), get_scale(), get_scale_and_mirror(), get_trans(), is_identity(), is_rot_identity(), EMAN::Symmetry3D::point_in_which_asym_unit(), EMAN::Util::point_is_in_triangle_2d(), and set_scale().
|
private |
Definition at line 503 of file transform.h.
Referenced by assert_valid_2d(), at(), copy_matrix_into_array(), get_determinant(), get_matrix(), get_matrix3_row(), get_matrix_4x4(), get_matrix_string(), get_rotation(), get_sym_proj(), get_trans(), get_trans_2d(), invert(), is_identity(), is_rot_identity(), operator=(), operator==(), operator[](), orthogonalize(), printme(), rotate(), rotate_origin(), set(), set_matrix(), set_mirror(), set_rotation(), set_scale(), set_trans(), to_identity(), transform(), Transform(), translate(), and transpose_inplace().
|
staticprivate |
This map is used to validate keys in the argument maps - e.g. if the type is 2d and the angle is not "alpha" then we should throw.
Definition at line 508 of file transform.h.
Referenced by detect_problem_keys(), and init_permissable_keys().
|
staticprivate |
Definition at line 509 of file transform.h.
Referenced by detect_problem_keys(), and init_permissable_keys().
|
staticprivate |
Definition at line 510 of file transform.h.
Referenced by detect_problem_keys(), and init_permissable_keys().