EMAN2
|
The Vec2 is precisely the same as Vec3 except it works exclusively in 2D Note there are convenient typedef so one needn't bother about using template terminology typedef Vec2<float> Vec2f; typedef Vec2<int> Vec2i; typedef Vec2double> Vec2d; // Not recommended for use unless precision is addressed in this class. More...
#include <vec3.h>
Public Types | |
typedef Type | type |
One can always cast to the type of a Vec2 by accessing Vec2<Type>::type. More... | |
Public Member Functions | |
Vec2 () | |
contruct a Vec2 object with all elements equal to 0. More... | |
template<typename Type2 , typename Type3 > | |
Vec2 (const Type2 &x, const Type3 &y) | |
contruct a Vec2 object given (x,y) or (x,y,z) values. More... | |
template<typename Type2 > | |
Vec2 (const vector< Type2 > &v) | |
Construct a Vec2 object given a std::vector object. More... | |
template<typename Type2 > | |
Vec2 (const Vec2< Type2 > &v) | |
Copy constructor copies vector elements. More... | |
~Vec2 () | |
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 Vec2< Type2 > &v) const |
Calculate the dot 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) |
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 > | |
Vec2< Type > & | operator+= (const Vec2< Type2 > &v) |
'this' += v; Add the 2 vectors by adding item by item. More... | |
template<typename Type2 > | |
Vec2< Type > & | operator+= (const Type2 &d) |
'this' += d. More... | |
template<typename Type2 > | |
Vec2< Type > & | operator-= (const Vec2< Type2 > &v) |
'this' -= v; Minus the 2 vectors item by item. More... | |
template<typename Type2 > | |
Vec2< Type > & | operator-= (const Type2 &d) |
'this' -= d; Minus a number from each item of 'this' vector. More... | |
template<typename Type2 > | |
Vec2< Type > & | operator*= (const Type2 &d) |
'this' *= d; Multiply a number on each item of 'this' vector. More... | |
template<typename Type2 > | |
Vec2< Type > & | operator/= (const Type2 &d) |
'this' /= d; Divide a number on each item of 'this' vector. More... | |
Private Attributes | |
Type | vec [2] |
The Vec2 is precisely the same as Vec3 except it works exclusively in 2D Note there are convenient typedef so one needn't bother about using template terminology typedef Vec2<float> Vec2f; typedef Vec2<int> Vec2i; typedef Vec2double> Vec2d; // Not recommended for use unless precision is addressed in this class.
typedef Type EMAN::Vec2< Type >::type |
One can always cast to the type of a Vec2 by accessing Vec2<Type>::type.
|
inline |
contruct a Vec2 object with all elements equal to 0.
Definition at line 718 of file vec3.h.
References EMAN::Vec2< Type >::vec.
|
inline |
|
inline |
Construct a Vec2 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 740 of file vec3.h.
References EMAN::Vec2< Type >::vec.
|
inline |
Copy constructor copies vector elements.
Definition at line 749 of file vec3.h.
References EMAN::Vec2< Type >::vec.
|
inline |
|
inline |
Return the values of this vector as a std::vector.
Definition at line 812 of file vec3.h.
References EMAN::Vec2< 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 876 of file vec3.h.
References EMAN::Vec2< 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 893 of file vec3.h.
References EMAN::Vec2< Type >::vec.
|
inline |
Calculate the dot product of 'this' vector with a second vector.
v | The second vector to do the dot product. |
Definition at line 804 of file vec3.h.
References EMAN::Vec2< Type >::vec.
Referenced by EMAN::operator*(), and EMAN::Util::point_is_in_triangle_2d().
|
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 903 of file vec3.h.
References EMAN::Vec2< Type >::vec.
|
inline |
Calculate its length.
Definition at line 783 of file vec3.h.
References sqrt(), and EMAN::Vec2< Type >::vec.
Referenced by EMAN::Vec2< Type >::normalize().
|
inline |
Normalize the vector and return its length before the normalization.
Definition at line 764 of file vec3.h.
References EMAN::Vec2< Type >::length(), EMAN::Vec2< Type >::set_value(), and EMAN::Vec2< Type >::vec.
|
inline |
|
inline |
'this' *= d; Multiply a number on each item of 'this' vector.
d | The number to multiply. |
Definition at line 958 of file vec3.h.
References EMAN::Vec2< 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 925 of file vec3.h.
References EMAN::Vec2< 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 914 of file vec3.h.
References EMAN::Vec2< 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 947 of file vec3.h.
References EMAN::Vec2< 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 936 of file vec3.h.
References EMAN::Vec2< Type >::vec.
|
inline |
'this' /= d; Divide a number on each item of 'this' vector.
d | The number to divide. |
Definition at line 969 of file vec3.h.
References EMAN::Vec2< 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 867 of file vec3.h.
References EMAN::Vec2< 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 858 of file vec3.h.
References EMAN::Vec2< 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 825 of file vec3.h.
References EMAN::Vec2< Type >::vec.
Referenced by EMAN::Vec2< Type >::normalize().
|
inline |
Set values at a particular index.
index | The index to be set |
value | The value to be set |
Definition at line 836 of file vec3.h.
References EMAN::Vec2< Type >::vec.
|
inline |
|
private |
Definition at line 977 of file vec3.h.
Referenced by EMAN::Vec2< Type >::as_list(), EMAN::Vec2< Type >::at(), EMAN::Vec2< Type >::begin(), EMAN::Vec2< Type >::dot(), EMAN::Vec2< Type >::end(), EMAN::Vec2< Type >::length(), EMAN::Vec2< Type >::normalize(), EMAN::Vec2< Type >::operator*=(), EMAN::Vec2< Type >::operator+=(), EMAN::Vec2< Type >::operator-=(), EMAN::Vec2< Type >::operator/=(), EMAN::Vec2< Type >::operator[](), EMAN::Vec2< Type >::set_value(), EMAN::Vec2< Type >::set_value_at(), EMAN::Vec2< Type >::squared_length(), and EMAN::Vec2< Type >::Vec2().