#include <vec3.h>
Collaboration diagram for EMAN::Vec2< Type >:
Public Types | |
typedef Type | type |
One can always cast to the type of a Vec2 by accessing Vec2<Type>::type. | |
Public Member Functions | |
Vec2 () | |
contruct a Vec2 object with all elements equal to 0. | |
template<typename Type2, typename Type3> | |
Vec2 (const Type2 &x, const Type3 &y) | |
contruct a Vec2 object given (x,y) or (x,y,z) values. | |
template<typename Type2> | |
Vec2 (const vector< Type2 > &v) | |
Construct a Vec2 object given a std::vector object. | |
template<typename Type2> | |
Vec2 (const Vec2< Type2 > &v) | |
Copy constructor copies vector elements. | |
~Vec2 () | |
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 Vec2< Type2 > &v) const |
Calculate the dot 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) |
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> | |
Vec2< Type > & | operator+= (const Vec2< Type2 > &v) |
'this' += v; Add the 2 vectors by adding item by item. | |
template<typename Type2> | |
Vec2< Type > & | operator+= (const Type2 &d) |
'this' += d. | |
template<typename Type2> | |
Vec2< Type > & | operator-= (const Vec2< Type2 > &v) |
'this' -= v; Minus the 2 vectors item by item. | |
template<typename Type2> | |
Vec2< Type > & | operator-= (const Type2 &d) |
'this' -= d; Minus a number from each item of 'this' vector. | |
template<typename Type2> | |
Vec2< Type > & | operator *= (const Type2 &d) |
'this' *= d; Multiply a number on each item of 'this' vector. | |
template<typename Type2> | |
Vec2< Type > & | operator/= (const Type2 &d) |
'this' /= d; Divide a number on each item of 'this' vector. | |
Private Attributes | |
Type | vec [2] |
Definition at line 713 of file vec3.h.
|
One can always cast to the type of a Vec2 by accessing Vec2<Type>::type.
|
|
contruct a Vec2 object with all elements equal to 0.
Definition at line 722 of file vec3.h. 00722 : vec[0](0),vec[1](0),vec[2](0)*/ { 00723 vec[0] = static_cast<Type>(0); 00724 vec[1] = static_cast<Type>(0); 00725 }
|
|
contruct a Vec2 object given (x,y) or (x,y,z) values.
Definition at line 733 of file vec3.h.
|
|
Construct a Vec2 object given a std::vector object. The std::vector object should have at least 3 items.
Definition at line 744 of file vec3.h. References v.
|
|
Copy constructor copies vector elements.
Definition at line 753 of file vec3.h. References v.
|
|
Destructor.
Definition at line 761 of file vec3.h. 00761 {}
|
|
Return the values of this vector as a std::vector.
Definition at line 816 of file vec3.h. References v. 00817 { 00818 vector < Type > v(2); 00819 v[0] = vec[0]; 00820 v[1] = vec[1]; 00821 return v; 00822 }
|
|
Get the ith item of the vector. Used in the left side of the assignment.
Definition at line 880 of file vec3.h. 00880 { return vec[i]; }
|
|
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 897 of file vec3.h. 00898 { 00899 return &vec[0]; 00900 }
|
|
Calculate the dot product of 'this' vector with a second vector.
Definition at line 808 of file vec3.h. References v. Referenced by EMAN::operator *(), and EMAN::Util::point_is_in_triangle_2d().
|
|
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 907 of file vec3.h. 00908 { 00909 return &vec[2]; 00910 }
|
|
Calculate its length.
Definition at line 787 of file vec3.h. 00788 { 00789 float t = (float)(vec[0] * vec[0] + vec[1] * vec[1]); 00790 return (float)sqrt(t); 00791 }
|
|
Normalize the vector and return its length before the normalization.
Definition at line 768 of file vec3.h. References EMAN::length(). 00769 { 00770 // Warning - float precision 00771 float len = length(); 00772 if (len != 0) { 00773 vec[0] = static_cast<Type> (vec[0] / len); 00774 vec[1] = static_cast<Type> (vec[1] / len); 00775 } 00776 else { 00777 set_value(0, 0); 00778 } 00779 return len; 00780 }
|
|
For python __len__.
Definition at line 887 of file vec3.h. 00888 {
00889 return 2;
00890 }
|
|
'this' *= d; Multiply a number on each item of 'this' vector.
Definition at line 962 of file vec3.h. 00962 { 00963 vec[0] = static_cast<Type>(vec[0]*d); 00964 vec[1] = static_cast<Type>(vec[1]*d); 00965 return *this; 00966 }
|
|
'this' += d. Add d to each item of this vector.
Definition at line 929 of file vec3.h. 00929 { 00930 vec[0] = static_cast<Type>(vec[0]+d); 00931 vec[1] = static_cast<Type>(vec[1]+d); 00932 return *this; 00933 }
|
|
'this' += v; Add the 2 vectors by adding item by item.
Definition at line 918 of file vec3.h. References v. 00918 { 00919 vec[0] = static_cast<Type>(vec[0]+v[0]); 00920 vec[1] = static_cast<Type>(vec[1]+v[1]); 00921 return *this; 00922 }
|
|
'this' -= d; Minus a number from each item of 'this' vector.
Definition at line 951 of file vec3.h. 00951 { 00952 vec[0] = static_cast<Type>(vec[0]-d); 00953 vec[1] = static_cast<Type>(vec[1]-d); 00954 return *this; 00955 }
|
|
'this' -= v; Minus the 2 vectors item by item.
Definition at line 940 of file vec3.h. References v. 00940 { 00941 vec[0] = static_cast<Type>(vec[0]-v[0]); 00942 vec[1] = static_cast<Type>(vec[1]-v[1]); 00943 return *this; 00944 }
|
|
'this' /= d; Divide a number on each item of 'this' vector.
Definition at line 973 of file vec3.h. 00973 { 00974 vec[0] = static_cast<Type>(vec[0]/d); 00975 vec[1] = static_cast<Type>(vec[1]/d); 00976 return *this; 00977 }
|
|
Get the ith item of the vector. Used in the left side of the assignment.
Definition at line 871 of file vec3.h. 00871 { return vec[i]; }
|
|
Get the ith item of the vector. Used in the right side of the assignment.
Definition at line 862 of file vec3.h. 00862 { return vec[i]; }
|
|
Set new values to this vector object.
Definition at line 849 of file vec3.h.
|
|
Set new values using a std::vector object.
Definition at line 829 of file vec3.h. References v.
|
|
Set values at a particular index.
Definition at line 840 of file vec3.h. 00841 { 00842 vec[index] = static_cast<Type>(value); 00843 }
|
|
Calculate its squared length. no sqrt called
Definition at line 797 of file vec3.h.
|
|
|