#include <vec3.h>
Inheritance diagram for EMAN::Vec3< Type >:
Public Types | |
typedef Type | type |
One can always cast to the type of a Vec3 by accessing Vec3<Type>::type. | |
Public Member Functions | |
Vec3 () | |
contruct a Vec3 object with all elements equal to 0. | |
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. | |
template<typename Type2> | |
Vec3 (const vector< Type2 > &v) | |
Construct a Vec3 object given a std::vector object. | |
template<typename Type2> | |
Vec3 (const Vec3< Type2 > &v) | |
Copy constructor copies vector elements. | |
~Vec3 () | |
Destructor. | |
float | normalize () |
Normalize the vector and return its length before the normalization. | |
float | length () const |
Calculate its length. | |
Type | squared_length () const |
Calculate its squared length. | |
template<typename Type2> | |
Type | dot (const Vec3< Type2 > &v) const |
Calculate the dot product of 'this' vector with a second vector. | |
template<typename Type2> | |
Vec3< Type > | cross (const Vec3< Type2 > &v) const |
Calculate the cross product of 'this' vector with a second vector. | |
vector< Type > | as_list () const |
Return the values of this vector as a std::vector. | |
template<typename Type2> | |
void | set_value (const vector< Type2 > &v) |
Set new values using a std::vector object. | |
template<typename Type2> | |
void | set_value_at (int index, const Type2 &value) |
Set values at a particular index. | |
void | set_value (const Type &x, const Type &y, const Type &z) |
Set new values to this vector object. | |
Type | operator[] (int i) const |
Get the ith item of the vector. | |
Type & | operator[] (int i) |
Get the ith item of the vector. | |
Type | at (int i) |
Get the ith item of the vector. | |
int | number_of_element () |
For python __len__. | |
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. | |
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. | |
template<typename Type2> | |
Vec3< Type > & | operator+= (const Vec3< Type2 > &v) |
'this' += v; Add the 2 vectors by adding item by item. | |
template<typename Type2> | |
Vec3< Type > & | operator+= (const Type2 &d) |
'this' += d. | |
template<typename Type2> | |
Vec3< Type > & | operator-= (const Vec3< Type2 > &v) |
'this' -= v; Minus the 2 vectors item by item. | |
template<typename Type2> | |
Vec3< Type > & | operator-= (const Type2 &d) |
'this' -= d; Minus a number from each item of 'this' vector. | |
template<typename Type2> | |
Vec3< Type > & | operator *= (const Type2 &d) |
'this' *= d; Multiply a number on each item of 'this' vector. | |
template<typename Type2> | |
Vec3< Type > & | operator/= (const Type2 &d) |
'this' /= d; Divide a number on each item of 'this' vector. | |
template<typename Type2> | |
operator vector () const | |
Private Attributes | |
Type | vec [3] |
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
Definition at line 66 of file vec3.h.
|
One can always cast to the type of a Vec3 by accessing Vec3<Type>::type.
|
|
contruct a Vec3 object with all elements equal to 0.
Definition at line 75 of file vec3.h. 00075 : vec[0](0),vec[1](0),vec[2](0)*/ { 00076 00077 vec[0] = static_cast<Type>(0); 00078 vec[1] = static_cast<Type>(0); 00079 vec[2] = static_cast<Type>(0); 00080 }
|
|
contruct a Vec3 object given (x,y) or (x,y,z) values.
Definition at line 89 of file vec3.h. 00090 { 00091 vec[0] = static_cast<Type>(x); 00092 vec[1] = static_cast<Type>(y); 00093 vec[2] = static_cast<Type>(z); 00094 }
|
|
Construct a Vec3 object given a std::vector object. The std::vector object should have at least 3 items.
Definition at line 101 of file vec3.h. 00102 { 00103 vec[0] = static_cast<Type>(v[0]); 00104 vec[1] = static_cast<Type>(v[1]); 00105 vec[2] = static_cast<Type>(v[2]); 00106 }
|
|
Copy constructor copies vector elements.
Definition at line 111 of file vec3.h.
|
|
Destructor.
Definition at line 120 of file vec3.h. 00120 {}
|
|
Return the values of this vector as a std::vector.
Definition at line 189 of file vec3.h. 00190 { 00191 vector < Type > v(3); 00192 v[0] = vec[0]; 00193 v[1] = vec[1]; 00194 v[2] = vec[2]; 00195 return v; 00196 }
|
|
Get the ith item of the vector. Used in the left side of the assignment.
Definition at line 263 of file vec3.h. Referenced by EMAN::EMData::rot_scale_trans(), and EMAN::EMData::rot_scale_trans_background(). 00264 { 00265 return vec[i]; 00266 }
|
|
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 282 of file vec3.h. 00283 { 00284 return &vec[0]; 00285 }
|
|
Calculate the cross product of 'this' vector with a second vector.
Definition at line 179 of file vec3.h. Referenced by EMAN::Quaternion::rotate(). 00180 { 00181 return Vec3<Type>((vec[1] * v[2] - vec[2] * v[1]), 00182 (vec[2] * v[0] - vec[0] * v[2]), 00183 (vec[0] * v[1] - vec[1] * v[0])); 00184 }
|
|
Calculate the dot product of 'this' vector with a second vector.
Definition at line 168 of file vec3.h. Referenced by EMAN::operator *(), and EMAN::Symmetry3D::point_in_which_asym_unit().
|
|
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 292 of file vec3.h. Referenced by EMAN::Symmetry3D::cache_au_planes(), wustl_mm::GraySkeletonCPP::VolumeSkeletonizer::CleanUpSkeleton(), EMAN::OptimumOrientationGenerator::optimize_distances(), EMAN::TestUtil::test_map_emobject(), EMAN::TestUtil::test_map_float(), EMAN::TestUtil::test_map_int(), EMAN::TestUtil::test_map_long(), and EMAN::TestUtil::test_map_string(). 00293 { 00294 return &vec[3]; 00295 }
|
|
Calculate its length.
Definition at line 147 of file vec3.h. Referenced by EMAN::PointArray::align_trans_2d(), EMAN::Quaternion::to_angle(), and EMAN::Quaternion::to_axis(). 00148 { 00149 float t = (float)(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]); 00150 return (float)sqrt(t); 00151 }
|
|
Normalize the vector and return its length before the normalization.
Definition at line 127 of file vec3.h. Referenced by EMAN::TetrahedralSym::get_asym_unit_points(), EMAN::PlatonicSym::get_asym_unit_points(), EMAN::OptimumOrientationGenerator::optimize_distances(), refalin3d_perturbquat(), EMAN::Transform::set_rotation(), and EMAN::MarchingCubes::surface_face_z(). 00128 { 00129 // Warning - float precision 00130 float len = length(); 00131 if (len != 0) { 00132 vec[0] = static_cast<Type> (vec[0] / len); 00133 vec[1] = static_cast<Type> (vec[1] / len); 00134 vec[2] = static_cast<Type> (vec[2] / len); 00135 } 00136 else { 00137 set_value(0, 0, 0); 00138 } 00139 return len; 00140 }
|
|
For python __len__.
Definition at line 272 of file vec3.h. 00273 {
00274 return 3;
00275 }
|
|
'this' *= d; Multiply a number on each item of 'this' vector.
Definition at line 350 of file vec3.h. 00350 { 00351 vec[0] = static_cast<Type>(vec[0]*d); 00352 vec[1] = static_cast<Type>(vec[1]*d); 00353 vec[2] = static_cast<Type>(vec[2]*d); 00354 return *this; 00355 }
|
|
Definition at line 370 of file vec3.h. 00370 { 00371 vector<Type2> v(vec,vec+3); 00372 return v; 00373 }
|
|
'this' += d. Add d to each item of this vector.
Definition at line 314 of file vec3.h. 00314 { 00315 vec[0] = static_cast<Type>(vec[0]+d); 00316 vec[1] = static_cast<Type>(vec[1]+d); 00317 vec[2] = static_cast<Type>(vec[2]+d); 00318 return *this; 00319 }
|
|
'this' += v; Add the 2 vectors by adding item by item.
Definition at line 302 of file vec3.h. 00302 { 00303 vec[0] = static_cast<Type>(vec[0]+v[0]); 00304 vec[1] = static_cast<Type>(vec[1]+v[1]); 00305 vec[2] = static_cast<Type>(vec[2]+v[2]); 00306 return *this; 00307 }
|
|
'this' -= d; Minus a number from each item of 'this' vector.
Definition at line 338 of file vec3.h. 00338 { 00339 vec[0] = static_cast<Type>(vec[0]-d); 00340 vec[1] = static_cast<Type>(vec[1]-d); 00341 vec[2] = static_cast<Type>(vec[2]-d); 00342 return *this; 00343 }
|
|
'this' -= v; Minus the 2 vectors item by item.
Definition at line 326 of file vec3.h. 00326 { 00327 vec[0] = static_cast<Type>(vec[0]-v[0]); 00328 vec[1] = static_cast<Type>(vec[1]-v[1]); 00329 vec[2] = static_cast<Type>(vec[2]-v[2]); 00330 return *this; 00331 }
|
|
'this' /= d; Divide a number on each item of 'this' vector.
Definition at line 362 of file vec3.h. 00362 { 00363 vec[0] = static_cast<Type>(vec[0]/d); 00364 vec[1] = static_cast<Type>(vec[1]/d); 00365 vec[2] = static_cast<Type>(vec[2]/d); 00366 return *this; 00367 }
|
|
Get the ith item of the vector. Used in the left side of the assignment.
Definition at line 251 of file vec3.h. 00252 { 00253 return vec[i]; 00254 }
|
|
Get the ith item of the vector. Used in the right side of the assignment.
Definition at line 239 of file vec3.h. 00240 { 00241 return vec[i]; 00242 }
|
|
Set new values to this vector object.
Definition at line 225 of file vec3.h.
|
|
Set new values using a std::vector object.
Definition at line 203 of file vec3.h. Referenced by wustl_mm::GraySkeletonCPP::VolumeSkeletonizer::CleanUpSkeleton(), and EMAN::Quaternion::to_axis(). 00204 { 00205 vec[0] = static_cast<Type>(v[0]); 00206 vec[1] = static_cast<Type>(v[1]); 00207 vec[2] = static_cast<Type>(v[2]); 00208 }
|
|
Set values at a particular index.
Definition at line 215 of file vec3.h. 00216 { 00217 vec[index] = static_cast<Type>(value); 00218 }
|
|
Calculate its squared length. no sqrt called
Definition at line 157 of file vec3.h. Referenced by EMAN::Symmetry3D::get_touching_au_transforms().
|
|
|