EMAN2
|
The Vec3 object is a templated object, intended to instantiated with basic types such as int, float, double etc. More...
#include <vec3.h>
Public Types | |
typedef Type | type |
One can always cast to the type of a Vec3 by accessing Vec3<Type>::type. More... | |
Public Member Functions | |
Vec3 () | |
contruct a Vec3 object with all elements equal to 0. More... | |
template<typename Type2 , typename Type3 , typename Type4 > | |
Vec3 (const Type2 &x, const Type3 &y, const Type4 &z=0) | |
contruct a Vec3 object given (x,y) or (x,y,z) values. More... | |
template<typename Type2 > | |
Vec3 (const vector< Type2 > &v) | |
Construct a Vec3 object given a std::vector object. More... | |
template<typename Type2 > | |
Vec3 (const Vec3< Type2 > &v) | |
Copy constructor copies vector elements. More... | |
~Vec3 () | |
Destructor. More... | |
float | normalize () |
Normalize the vector and return its length before the normalization. More... | |
float | length () const |
Calculate its length. More... | |
Type | squared_length () const |
Calculate its squared length. More... | |
template<typename Type2 > | |
Type | dot (const Vec3< Type2 > &v) const |
Calculate the dot product of 'this' vector with a second vector. More... | |
template<typename Type2 > | |
Vec3< Type > | cross (const Vec3< Type2 > &v) const |
Calculate the cross product of 'this' vector with a second vector. More... | |
vector< Type > | as_list () const |
Return the values of this vector as a std::vector. More... | |
template<typename Type2 > | |
void | set_value (const vector< Type2 > &v) |
Set new values using a std::vector object. More... | |
template<typename Type2 > | |
void | set_value_at (int index, const Type2 &value) |
Set values at a particular index. More... | |
void | set_value (const Type &x, const Type &y, const Type &z) |
Set new values to this vector object. More... | |
Type | operator[] (int i) const |
Get the ith item of the vector. More... | |
Type & | operator[] (int i) |
Get the ith item of the vector. More... | |
Type | at (int i) |
Get the ith item of the vector. More... | |
int | number_of_element () |
For python len More... | |
Type * | begin () |
Add this function to make it iterable in Python, so we can call list() or tuple() to convert Vec3f in python to a list or tuple. More... | |
Type * | end () |
Add this function to make it iterable in Python, so we can call list() or tuple() to convert Vec3f in python to a list or tuple. More... | |
template<typename Type2 > | |
Vec3< Type > & | operator+= (const Vec3< Type2 > &v) |
'this' += v; Add the 2 vectors by adding item by item. More... | |
template<typename Type2 > | |
Vec3< Type > & | operator+= (const Type2 &d) |
'this' += d. More... | |
template<typename Type2 > | |
Vec3< Type > & | operator-= (const Vec3< Type2 > &v) |
'this' -= v; Minus the 2 vectors item by item. More... | |
template<typename Type2 > | |
Vec3< Type > & | operator-= (const Type2 &d) |
'this' -= d; Minus a number from each item of 'this' vector. More... | |
template<typename Type2 > | |
Vec3< Type > & | operator*= (const Type2 &d) |
'this' *= d; Multiply a number on each item of 'this' vector. More... | |
template<typename Type2 > | |
Vec3< Type > & | operator/= (const Type2 &d) |
'this' /= d; Divide a number on each item of 'this' vector. More... | |
template<typename Type2 > | |
operator vector< Type2 > () const | |
Private Attributes | |
Type | vec [3] |
The Vec3 object is a templated object, intended to instantiated with basic types such as int, float, double etc.
You may try to use other more generic types such as classes but you may get bad results. Note that the normalize and length operations are precise only to 32 bits Note there are convenient typedef so one needn't bother about using template terminology typedef Vec3<float> Vec3f; typedef Vec3<int> Vec3i; typedef Vec3<double> Vec3d; // Not recommended for use unless precision is addressed in this class
typedef Type EMAN::Vec3< Type >::type |
One can always cast to the type of a Vec3 by accessing Vec3<Type>::type.
|
inline |
contruct a Vec3 object with all elements equal to 0.
Definition at line 280 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
|
inline |
Construct a Vec3 object given a std::vector object.
The std::vector object should have at least 3 items.
v | The std::vector object. It should have at least 3 items. |
Definition at line 306 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
|
inline |
|
inline |
|
inline |
Get the ith item of the vector.
Used in the left side of the assignment.
i | The index of the item to get. Its validality is not checked. |
Definition at line 468 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
Add this function to make it iterable in Python, so we can call list() or tuple() to convert Vec3f in python to a list or tuple.
Definition at line 487 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
Calculate the cross product of 'this' vector with a second vector.
v | The second vector to do the cross product. |
Definition at line 384 of file vec3.h.
References EMAN::Vec3< Type >::vec.
Referenced by EMAN::PointArray::calc_transform(), EMAN::Quaternion::rotate(), EMAN::PointArray::sim_potentiald(), and EMAN::PointArray::sim_updategeom().
|
inline |
Calculate the dot product of 'this' vector with a second vector.
v | The second vector to do the dot product. |
Definition at line 373 of file vec3.h.
References EMAN::Vec3< Type >::vec.
Referenced by EMAN::PointArray::calc_helicity(), EMAN::PointArray::calc_transform(), EMAN::operator*(), EMAN::Symmetry3D::point_in_which_asym_unit(), EMAN::PointArray::sim_potentiald(), and EMAN::PointArray::sim_updategeom().
|
inline |
Add this function to make it iterable in Python, so we can call list() or tuple() to convert Vec3f in python to a list or tuple.
Definition at line 497 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
Calculate its length.
Definition at line 352 of file vec3.h.
References sqrt(), and EMAN::Vec3< Type >::vec.
Referenced by EMAN::PointArray::calc_transform(), EMAN::PointArray::construct_helix(), EMAN::PointArray::merge_to(), EMAN::Vec3< Type >::normalize(), EMAN::PointArray::remove_helix_from_map(), EMAN::PointArray::sim_minstep_seq(), EMAN::PointArray::sim_potentiald(), EMAN::PointArray::sim_rescale(), EMAN::PointArray::sim_updategeom(), EMAN::Quaternion::to_angle(), and EMAN::Quaternion::to_axis().
|
inline |
Normalize the vector and return its length before the normalization.
Definition at line 332 of file vec3.h.
References EMAN::Vec3< Type >::length(), EMAN::Vec3< Type >::set_value(), and EMAN::Vec3< Type >::vec.
Referenced by EMAN::PointArray::calc_transform(), EMAN::PlatonicSym::get_asym_unit_points(), EMAN::TetrahedralSym::get_asym_unit_points(), EMAN::OptimumOrientationGenerator::optimize_distances(), refalin3d_perturbquat(), and EMAN::Transform::set_rotation().
|
inline |
|
inline |
Definition at line 575 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
'this' *= d; Multiply a number on each item of 'this' vector.
d | The number to multiply. |
Definition at line 555 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
'this' += d.
Add d to each item of this vector.
d | The number used to be added to this vector. |
Definition at line 519 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
'this' += v; Add the 2 vectors by adding item by item.
v | The vector used to be added to 'this' vector. |
Definition at line 507 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
'this' -= d; Minus a number from each item of 'this' vector.
d | The number used to be substracted from 'this' vector. |
Definition at line 543 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
'this' -= v; Minus the 2 vectors item by item.
v | The vector used to be substracted from 'this' vector. |
Definition at line 531 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
'this' /= d; Divide a number on each item of 'this' vector.
d | The number to divide. |
Definition at line 567 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
Get the ith item of the vector.
Used in the left side of the assignment.
i | The index of the item to get. Its validality is not checked. |
Definition at line 456 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
Get the ith item of the vector.
Used in the right side of the assignment.
i | The index of the item to get. Its validality is not checked. |
Definition at line 444 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
|
inline |
Set new values using a std::vector object.
v | A std::vector object used to set 'this' vector's value. It should have at least 3 items. |
Definition at line 408 of file vec3.h.
References EMAN::Vec3< Type >::vec.
Referenced by wustl_mm::GraySkeletonCPP::VolumeSkeletonizer::CleanUpSkeleton(), EMAN::Vec3< Type >::normalize(), and EMAN::Quaternion::to_axis().
|
inline |
Set values at a particular index.
index | The index to be set |
value | The value to be set |
Definition at line 420 of file vec3.h.
References EMAN::Vec3< Type >::vec.
|
inline |
Calculate its squared length.
no sqrt called
Definition at line 362 of file vec3.h.
References EMAN::Vec3< Type >::vec.
Referenced by EMAN::Symmetry3D::get_touching_au_transforms().
|
private |
Definition at line 582 of file vec3.h.
Referenced by EMAN::Vec3< Type >::as_list(), EMAN::Vec3< Type >::at(), EMAN::Vec3< Type >::begin(), EMAN::Vec3< Type >::cross(), EMAN::Vec3< Type >::dot(), EMAN::Vec3< Type >::end(), EMAN::Vec3< Type >::length(), EMAN::Vec3< Type >::normalize(), EMAN::Vec3< Type >::operator vector< Type2 >(), EMAN::Vec3< Type >::operator*=(), EMAN::Vec3< Type >::operator+=(), EMAN::Vec3< Type >::operator-=(), EMAN::Vec3< Type >::operator/=(), EMAN::Vec3< Type >::operator[](), EMAN::Vec3< Type >::set_value(), EMAN::Vec3< Type >::set_value_at(), EMAN::Vec3< Type >::squared_length(), and EMAN::Vec3< Type >::Vec3().