#include <Vector3.h>
Definition at line 25 of file Vector3.h.
Public Member Functions | |
Vector3 (void) | |
Creates empty vector of zeros. | |
Vector3 (double x, double y) | |
Creates new vector. | |
Vector3 (double x, double y, double z) | |
Vector3 (const Vector3 &o) | |
bool | operator== (const Vector3 &rhs) const |
Equal operator. | |
bool | operator!= (const Vector3 &rhs) const |
const Vector3 & | operator= (const Vector3 &rhs) |
const Vector3 & | operator+= (const Vector3 &rhs) |
const Vector3 & | operator-= (const Vector3 &rhs) |
const Vector3 & | operator *= (const double &rhs) |
const Vector3 & | operator/= (const double &rhs) |
Vector3 | operator+ (const Vector3 &rhs) const |
Vector3 | operator- (const Vector3 &rhs) const |
double | dot (const Vector3 &rhs) const |
Dot product of vectors. | |
Vector3 | operator * (const double &rhs) const |
Vector3 | operator/ (const double &rhs) const |
double & | operator[] (int i) |
Access operator, first element has index zero. | |
Vector3 | crossProduct (const Vector3 &rhs) const |
Cross product of 3x1 vectors. | |
double | operator[] (int i) const |
Access operator, first element has index zero. | |
double | x () const |
double & | x () |
double | y () const |
double & | y () |
double | z () const |
double & | z () |
double | abs () const |
Absolute value of the vector. | |
Vector3 | norm () const |
Returns normalized vector. | |
void | normalize () |
Normalize current vector. | |
void | negate () |
Negate each element of the vector. | |
void | print (std::ostream &out, char *name) const |
Static Public Member Functions | |
static Vector3 | e1 () |
Returns unit vector in x direction. | |
static Vector3 | e2 () |
Returns unit vector in y direction. | |
static Vector3 | e3 () |
Returns unit vector in z direction. | |
static Vector3 | ones () |
Returns 3x1 vector of all ones. | |
Private Member Functions | |
void | copy (const Vector3 &o) |
const Vector3 & | operator *= (const Vector3 &rhs) |
Private Attributes | |
double | vec [vDim] |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Vector3 &m) |
std::istream & | operator>> (std::istream &in, Vector3 &m) |
|
Creates empty vector of zeros.
Definition at line 55 of file Vector3.h.
|
|
Creates new vector.
Definition at line 64 of file Vector3.h.
|
|
Definition at line 68 of file Vector3.h.
|
|
Definition at line 72 of file Vector3.h. 00072 { 00073 copy(o); 00074 }
|
|
Absolute value of the vector.
Definition at line 199 of file Vector3.h. 00199 { 00200 double sum = 0; 00201 for (int i = 0; i < vDim; i++) 00202 sum += vec[i]*vec[i]; 00203 return sqrt(sum); 00204 }
|
|
Definition at line 31 of file Vector3.h.
|
|
Cross product of 3x1 vectors.
Definition at line 169 of file Vector3.h. 00169 { 00170 Vector3 tmp; 00171 tmp[0] = vec[1]*rhs[2] - vec[2]*rhs[1]; 00172 tmp[1] = vec[2]*rhs[0] - vec[0]*rhs[2]; 00173 tmp[2] = vec[0]*rhs[1] - vec[1]*rhs[0]; 00174 return tmp; 00175 }
|
|
Dot product of vectors.
Definition at line 137 of file Vector3.h. 00137 { 00138 Vector3 tmp(*this); 00139 tmp *= rhs; 00140 double sum = 0; 00141 for (int i = 0; i < vDim; i++) 00142 sum += tmp.vec[i]; 00143 return sum; 00144 }
|
|
Returns unit vector in x direction.
Definition at line 46 of file Vector3.h. 00046 {return Vector3(1, 0, 0);}
|
|
Returns unit vector in y direction.
Definition at line 48 of file Vector3.h. 00048 {return Vector3(0, 1, 0);}
|
|
Returns unit vector in z direction.
Definition at line 50 of file Vector3.h. 00050 {return Vector3(0, 0, 1);}
|
|
Negate each element of the vector.
Definition at line 230 of file Vector3.h.
|
|
Returns normalized vector.
Definition at line 210 of file Vector3.h. 00210 { 00211 Vector3 norm; 00212 double length = abs(); 00213 for (int i = 0; i < vDim; i++) 00214 norm[i] = vec[i]/length; 00215 return norm; 00216 }
|
|
Normalize current vector.
Definition at line 221 of file Vector3.h. 00221 { 00222 double length = abs(); 00223 for (int i = 0; i < vDim; i++) 00224 vec[i] = vec[i]/length; 00225 }
|
|
Returns 3x1 vector of all ones.
Definition at line 52 of file Vector3.h. 00052 {return Vector3(1, 1, 1);}
|
|
Definition at line 146 of file Vector3.h. 00146 { 00147 Vector3 tmp(*this); 00148 tmp *= rhs; 00149 return tmp; 00150 }
|
|
Definition at line 108 of file Vector3.h.
|
|
Definition at line 36 of file Vector3.h. 00036 { 00037 for (int i = 0; i < vDim; i++) 00038 vec[i] = vec[i]*rhs.vec[i]; 00039 return *this; 00040 }
|
|
Definition at line 85 of file Vector3.h.
|
|
Definition at line 121 of file Vector3.h. 00121 { 00122 Vector3 tmp(*this); 00123 tmp += rhs; 00124 return tmp; 00125 }
|
|
Definition at line 95 of file Vector3.h. 00095 { 00096 for (int i = 0; i < vDim; i++) 00097 vec[i] = vec[i]+rhs.vec[i]; 00098 return *this; 00099 }
|
|
Definition at line 128 of file Vector3.h. 00128 { 00129 Vector3 tmp(*this); 00130 tmp -= rhs; 00131 return tmp; 00132 }
|
|
Definition at line 101 of file Vector3.h. 00101 { 00102 for (int i = 0; i < vDim; i++) 00103 vec[i] = vec[i]-rhs.vec[i]; 00104 return *this; 00105 }
|
|
Definition at line 152 of file Vector3.h. 00152 { 00153 Vector3 tmp(*this); 00154 tmp /= rhs; 00155 return tmp; 00156 }
|
|
Definition at line 114 of file Vector3.h.
|
|
Definition at line 89 of file Vector3.h. 00089 { 00090 if (this != &rhs) 00091 copy(rhs); 00092 return *this; 00093 }
|
|
Equal operator.
Definition at line 79 of file Vector3.h. 00079 { 00080 return (fabs(vec[0] - rhs.vec[0]) < 1.e-14 && 00081 fabs(vec[1] - rhs.vec[1]) < 1.e-14 && 00082 fabs(vec[2] - rhs.vec[2]) < 1.e-14); 00083 }
|
|
Access operator, first element has index zero.
Definition at line 180 of file Vector3.h. 00180 { 00181 if (i >= vDim || i < 0){ 00182 std::cerr << "Out of bounds vector accessing: [" << i << "]" << std::endl; 00183 return 0; 00184 } 00185 else 00186 return vec[i]; 00187 }
|
|
Access operator, first element has index zero.
Definition at line 162 of file Vector3.h. 00162 { 00163 return vec[i]; 00164 }
|
|
Definition at line 237 of file Vector3.h. 00237 { 00238 for (int i = 0; i < vDim; i++) 00239 out << name << "(" << (i+1) << ")= " << vec[i] << "; "; 00240 out << std::endl; 00241 }
|
|
Definition at line 190 of file Vector3.h. 00190 {return vec[0];}
|
|
Definition at line 189 of file Vector3.h. 00189 {return vec[0];}
|
|
Definition at line 192 of file Vector3.h. 00192 {return vec[1];}
|
|
Definition at line 191 of file Vector3.h. 00191 {return vec[1];}
|
|
Definition at line 194 of file Vector3.h. 00194 {return vec[2];}
|
|
Definition at line 193 of file Vector3.h. 00193 {return vec[2];}
|
|
Definition at line 243 of file Vector3.h. 00243 { 00244 out << m.vec[0]; 00245 for (int i = 1; i < vDim; i++) 00246 out << " " << m.vec[i]; 00247 return out; 00248 }
|
|
Definition at line 251 of file Vector3.h.
|
|
|