#include <vec3.h>
Collaboration diagram for EMAN::Vec4< Type >:
Public Types | |
typedef Type | type |
One can always cast to the type of a Vec4 by accessing Vec4<Type>::type. | |
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. | |
template<typename Type2> | |
Vec4 (const Vec4< Type2 > &v) | |
Copy constructor copies vector elements. | |
~Vec4 () | |
Destructor. | |
float | length () const |
Calculate its length. | |
float | normalize () |
Normalize the vector and return its length before the normalization. | |
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 &a, const Type &b, const Type &c, const Type &d) |
Set new values to this vector object. | |
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. | |
Type | operator[] (int i) const |
Get the ith item of the vector. | |
Type & | operator[] (int i) |
Get the ith item of the vector. | |
Private Attributes | |
Type | vec [4] |
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
Definition at line 69 of file vec3.h.
|
One can always cast to the type of a Vec4 by accessing Vec4<Type>::type.
|
|
Definition at line 76 of file vec3.h. 00077 { 00078 vec[0] = static_cast<Type>(0); 00079 vec[1] = static_cast<Type>(0); 00080 vec[2] = static_cast<Type>(0); 00081 vec[3] = static_cast<Type>(0); 00082 }
|
|
Definition at line 85 of file vec3.h. 00086 { 00087 vec[0] = static_cast<Type>(a); 00088 vec[1] = static_cast<Type>(b); 00089 vec[2] = static_cast<Type>(c); 00090 vec[3] = static_cast<Type>(d); 00091 }
|
|
Construct a Vec3 object given a std::vector object. The std::vector object should have at least 3 items.
Definition at line 98 of file vec3.h. References v. 00099 { 00100 vec[0] = static_cast<Type>(v[0]); 00101 vec[1] = static_cast<Type>(v[1]); 00102 vec[2] = static_cast<Type>(v[2]); 00103 vec[3] = static_cast<Type>(v[3]); 00104 }
|
|
Copy constructor copies vector elements.
Definition at line 109 of file vec3.h. References v.
|
|
Destructor.
Definition at line 119 of file vec3.h. 00119 {}
|
|
Get the ith item of the vector. Used in the left side of the assignment.
Definition at line 194 of file vec3.h. 00195 { 00196 return vec[i]; 00197 }
|
|
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 213 of file vec3.h. 00214 { 00215 return &vec[0]; 00216 }
|
|
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 223 of file vec3.h. 00224 { 00225 return &vec[4]; 00226 }
|
|
Calculate its length.
Definition at line 125 of file vec3.h. 00126 { 00127 float t = (float)(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * vec[3]); 00128 return (float)sqrt(t); 00129 }
|
|
Normalize the vector and return its length before the normalization.
Definition at line 135 of file vec3.h. References EMAN::length(). 00136 { 00137 // Warning - float precision 00138 float len = length(); 00139 if (len != 0) { 00140 vec[0] = static_cast<Type> (vec[0] / len); 00141 vec[1] = static_cast<Type> (vec[1] / len); 00142 vec[2] = static_cast<Type> (vec[2] / len); 00143 vec[3] = static_cast<Type> (vec[3] / len); 00144 } 00145 else { 00146 set_value(0, 0, 0, 0); 00147 } 00148 return len; 00149 }
|
|
For python __len__.
Definition at line 203 of file vec3.h. 00204 {
00205 return 4;
00206 }
|
|
Get the ith item of the vector. Used in the left side of the assignment.
Definition at line 247 of file vec3.h. 00248 { 00249 return vec[i]; 00250 }
|
|
Get the ith item of the vector. Used in the right side of the assignment.
Definition at line 235 of file vec3.h. 00236 { 00237 return vec[i]; 00238 }
|
|
Set new values to this vector object.
Definition at line 179 of file vec3.h.
|
|
Set new values using a std::vector object.
Definition at line 156 of file vec3.h. References v. 00157 { 00158 vec[0] = static_cast<Type>(v[0]); 00159 vec[1] = static_cast<Type>(v[1]); 00160 vec[2] = static_cast<Type>(v[2]); 00161 vec[3] = static_cast<Type>(v[3]); 00162 }
|
|
Set values at a particular index.
Definition at line 169 of file vec3.h. 00170 { 00171 vec[index] = static_cast<Type>(value); 00172 }
|
|
|