#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 504 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 513 of file vec3.h. 00513 : vec[0](0),vec[1](0),vec[2](0)*/ { 00514 vec[0] = static_cast<Type>(0); 00515 vec[1] = static_cast<Type>(0); 00516 }
|
|
contruct a Vec2 object given (x,y) or (x,y,z) values.
Definition at line 524 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 535 of file vec3.h. References v.
|
|
Copy constructor copies vector elements.
Definition at line 544 of file vec3.h. References v.
|
|
Destructor.
Definition at line 552 of file vec3.h. 00552 {}
|
|
Return the values of this vector as a std::vector.
Definition at line 607 of file vec3.h. References v. 00608 { 00609 vector < Type > v(2); 00610 v[0] = vec[0]; 00611 v[1] = vec[1]; 00612 return v; 00613 }
|
|
Get the ith item of the vector. Used in the left side of the assignment.
Definition at line 671 of file vec3.h. 00671 { 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 688 of file vec3.h. 00689 { 00690 return &vec[0]; 00691 }
|
|
Calculate the dot product of 'this' vector with a second vector.
Definition at line 599 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 698 of file vec3.h. 00699 { 00700 return &vec[2]; 00701 }
|
|
Calculate its length.
Definition at line 578 of file vec3.h. 00579 { 00580 float t = (float)(vec[0] * vec[0] + vec[1] * vec[1]); 00581 return (float)sqrt(t); 00582 }
|
|
Normalize the vector and return its length before the normalization.
Definition at line 559 of file vec3.h. References EMAN::length(). 00560 { 00561 // Warning - float precision 00562 float len = length(); 00563 if (len != 0) { 00564 vec[0] = static_cast<Type> (vec[0] / len); 00565 vec[1] = static_cast<Type> (vec[1] / len); 00566 } 00567 else { 00568 set_value(0, 0); 00569 } 00570 return len; 00571 }
|
|
For python __len__.
Definition at line 678 of file vec3.h. 00679 {
00680 return 2;
00681 }
|
|
'this' *= d; Multiply a number on each item of 'this' vector.
Definition at line 753 of file vec3.h. 00753 { 00754 vec[0] = static_cast<Type>(vec[0]*d); 00755 vec[1] = static_cast<Type>(vec[1]*d); 00756 return *this; 00757 }
|
|
'this' += d. Add d to each item of this vector.
Definition at line 720 of file vec3.h. 00720 { 00721 vec[0] = static_cast<Type>(vec[0]+d); 00722 vec[1] = static_cast<Type>(vec[1]+d); 00723 return *this; 00724 }
|
|
'this' += v; Add the 2 vectors by adding item by item.
Definition at line 709 of file vec3.h. References v. 00709 { 00710 vec[0] = static_cast<Type>(vec[0]+v[0]); 00711 vec[1] = static_cast<Type>(vec[1]+v[1]); 00712 return *this; 00713 }
|
|
'this' -= d; Minus a number from each item of 'this' vector.
Definition at line 742 of file vec3.h. 00742 { 00743 vec[0] = static_cast<Type>(vec[0]-d); 00744 vec[1] = static_cast<Type>(vec[1]-d); 00745 return *this; 00746 }
|
|
'this' -= v; Minus the 2 vectors item by item.
Definition at line 731 of file vec3.h. References v. 00731 { 00732 vec[0] = static_cast<Type>(vec[0]-v[0]); 00733 vec[1] = static_cast<Type>(vec[1]-v[1]); 00734 return *this; 00735 }
|
|
'this' /= d; Divide a number on each item of 'this' vector.
Definition at line 764 of file vec3.h. 00764 { 00765 vec[0] = static_cast<Type>(vec[0]/d); 00766 vec[1] = static_cast<Type>(vec[1]/d); 00767 return *this; 00768 }
|
|
Get the ith item of the vector. Used in the left side of the assignment.
Definition at line 662 of file vec3.h. 00662 { return vec[i]; }
|
|
Get the ith item of the vector. Used in the right side of the assignment.
Definition at line 653 of file vec3.h. 00653 { return vec[i]; }
|
|
Set new values to this vector object.
Definition at line 640 of file vec3.h.
|
|
Set new values using a std::vector object.
Definition at line 620 of file vec3.h. References v.
|
|
Set values at a particular index.
Definition at line 631 of file vec3.h. 00632 { 00633 vec[index] = static_cast<Type>(value); 00634 }
|
|
Calculate its squared length. no sqrt called
Definition at line 588 of file vec3.h.
|
|
|