EMAN2
|
The Vec4 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 Vec4 by accessing Vec4<Type>::type. More... | |
Public Member Functions | |
Vec4 () | |
template<typename Type2 , typename Type3 , typename Type4 , typename Type5 > | |
Vec4 (const Type2 &a, const Type3 &b, const Type4 &c, const Type5 &d) | |
template<typename Type2 > | |
Vec4 (const vector< Type2 > &v) | |
Construct a Vec3 object given a std::vector object. More... | |
template<typename Type2 > | |
Vec4 (const Vec4< Type2 > &v) | |
Copy constructor copies vector elements. More... | |
~Vec4 () | |
Destructor. More... | |
float | length () const |
Calculate its length. More... | |
float | normalize () |
Normalize the vector and return its length before the normalization. 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 &a, const Type &b, const Type &c, const Type &d) |
Set new values to this vector object. 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... | |
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... | |
Private Attributes | |
Type | vec [4] |
The Vec4 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
WARNING This class is not as complete as Vec4f, in that I have not yet implmented object operators
For now, only functionality is for normalization typedef Vec4<float> Vec4f; typedef Vec4<int> Vec4i; typedef Vec4<double> Vec4d; // Not recommended for use unless precision is addressed in this class
typedef Type EMAN::Vec4< Type >::type |
One can always cast to the type of a Vec4 by accessing Vec4<Type>::type.
|
inline |
|
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 94 of file vec3.h.
References EMAN::Vec4< Type >::vec.
|
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 190 of file vec3.h.
References EMAN::Vec4< 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 209 of file vec3.h.
References EMAN::Vec4< 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 219 of file vec3.h.
References EMAN::Vec4< Type >::vec.
|
inline |
Calculate its length.
Definition at line 121 of file vec3.h.
References sqrt(), and EMAN::Vec4< Type >::vec.
Referenced by EMAN::Vec4< Type >::normalize().
|
inline |
Normalize the vector and return its length before the normalization.
Definition at line 131 of file vec3.h.
References EMAN::Vec4< Type >::length(), EMAN::Vec4< Type >::set_value(), and EMAN::Vec4< Type >::vec.
|
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 243 of file vec3.h.
References EMAN::Vec4< 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 231 of file vec3.h.
References EMAN::Vec4< 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 152 of file vec3.h.
References EMAN::Vec4< Type >::vec.
Referenced by EMAN::Vec4< Type >::normalize().
|
inline |
Set values at a particular index.
index | The index to be set |
value | The value to be set |
Definition at line 165 of file vec3.h.
References EMAN::Vec4< Type >::vec.
|
private |
Definition at line 249 of file vec3.h.
Referenced by EMAN::Vec4< Type >::at(), EMAN::Vec4< Type >::begin(), EMAN::Vec4< Type >::end(), EMAN::Vec4< Type >::length(), EMAN::Vec4< Type >::normalize(), EMAN::Vec4< Type >::operator[](), EMAN::Vec4< Type >::set_value(), EMAN::Vec4< Type >::set_value_at(), and EMAN::Vec4< Type >::Vec4().