Homogenous vector for three dimensional space. More...
#include <vec4d.hpp>
Public Member Functions | |
Vec4D () | |
Vec4D (double x) | |
Vec4D (double x, double y) | |
Vec4D (double x, double y, double z) | |
Vec4D (double x, double y, double z, double w) | |
Vec4D (const class Vec3D &vec) | |
Vec4D (std::istream &s) | |
~Vec4D () | |
double & | operator[] (int i) |
const double & | operator[] (int i) const |
double & | operator() (int i) |
const double & | operator() (int i) const |
Vec4D | operator+ (const Vec4D &vec) const |
Addition. | |
Vec4D | operator- (const Vec4D &vec) const |
Difference. | |
Vec4D & | operator+= (const Vec4D &vec) |
Accumulation. | |
double | operator* (const Vec4D &vec) const |
Dot product. | |
Vec4D | operator* (double x) const |
Vector scaling. | |
Vec4D & | operator*= (double x) |
Vector scaling. | |
Vec4D & | operator/= (double x) |
Vector scaling with divisor. | |
bool | operator!= (const Vec4D &x) |
Inequality test. | |
bool | operator== (const Vec4D &x) |
Equality test. | |
Vec4D & | operator= (const Vec4D &x) |
Assignment. | |
void | homogenize () |
Homogenize vector. | |
void | normalize () |
Normalize vector. | |
double | norm2 () const |
Returns 2-norm of vector. | |
double | ssqr () const |
Returns square of 2-norm of vector. | |
void | save (std::ostream &s) const |
Friends | |
Vec4D | cross (const Vec4D &vec1, const Vec4D &vec2) |
Cross product. | |
double | norm2 (const Vec4D &vec) |
Second norm of vector. | |
Vec4D | operator* (double x, const Vec4D &vec) |
Vector scaling. | |
std::ostream & | operator<< (std::ostream &os, const Vec4D &vec) |
Outputting to stream. | |
Homogenous vector for three dimensional space.
Homogenous space has 4-vectors (x,y,z,w).
Most operations assume the arguments are either vectors (w=0) or points (w=1). These are only checked where the algorithm is dependent on this information. Otherwise the fourth coordinate (w) is assumed what the algorithm is designed for. User is responsible for calling legal operations for corrent type of vectors.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Vec4D::Vec4D | ( | const class Vec3D & | vec | ) |
|
inline |
|
inline |
|
inline |
Homogenize vector.
Homogenize vector by dividing all components of vector with w. Not valid for w=0.
|
inline |
Returns 2-norm of vector.
|
inline |
Normalize vector.
Only valid for vector. Output is guaranteed to be a vector.
|
inline |
Inequality test.
Also tests w.
|
inline |
|
inline |
|
inline |
Dot product.
Valid for vectors only.
|
inline |
Vector scaling.
Valid for points and vectors. Scaling does not affect w.
|
inline |
Vector scaling.
Valid for points and vectors. Scaling does not affect w.
Addition.
Only valid for point+vector=point or vector+vector=vector. Output is of the correct type.
Accumulation.
Only valid for point += vector or vector += vector. Output type does not change.
Difference.
Only valid for vector-vector=vector, point-vector=point or point-point=vector. Output is of the correct type.
|
inline |
Vector scaling with divisor.
Valid for points and vectors. Scaling does not affect w.
|
inline |
Equality test.
Also tests w.
|
inline |
|
inline |
|
inline |
|
inline |
Returns square of 2-norm of vector.
Cross product.
Only valid for vectors. Output is guaranteed to be a vector.
|
friend |
Second norm of vector.
|
friend |
Outputting to stream.