Vector class for a 3D float vector. More...
Public Member Functions | |
Vec3f () | |
Constructs a null vector. More... | |
Vec3f (const Vec3f &other) | |
Constructs a vector as a copy of other. More... | |
Vec3f (float x, float y, float z) | |
Constructs a vector from an x, y and z coordinate. More... | |
Vec3f & | operator= (const Vec3f &other) |
Assigns other to this vector and returns a reference to this vector. More... | |
bool | operator== (const Vec3f &rhs) const |
Returns true if two vectors are equal, otherwise returns false. More... | |
bool | operator!= (const Vec3f &rhs) const |
Returns true if two vectors are not equal, otherwise returns false. More... | |
const Vec3f | operator+ (const Vec3f &rhs) const |
Returns a vector that is this vector added with rhs. More... | |
const Vec3f | operator- (const Vec3f &rhs) const |
Returns a vector that is this vector subtracted with rhs. More... | |
const Vec3f | operator* (float scalar) const |
Returns a vector that is this vector multiplies with scalar. More... | |
const Vec3f | operator/ (float scalar) const |
Returns a vector that is this vector divided with scalar. More... | |
Vec3f & | operator+= (const Vec3f &rhs) |
Adds the given rhs vector to this. More... | |
Vec3f & | operator-= (const Vec3f &rhs) |
Subtracts the given rhs vector from this. More... | |
Vec3f & | operator*= (float scalar) |
Multiplies every components of this vector with the given scalar. More... | |
Vec3f & | operator/= (float scalar) |
Divides every components of this vector with the given scalar. More... | |
float | operator* (const Vec3f &rhs) const |
Computes the dot product of this and rhs and return the result (scalar) More... | |
const Vec3f | operator^ (const Vec3f &rhs) const |
Computes the cross product of this and rhs and return the result (vector) More... | |
const float & | x () const |
X element of the vector. More... | |
const float & | y () const |
Y element of the vector. More... | |
const float & | z () const |
Z element of the vector. More... | |
float & | x () |
X element of the vector. More... | |
float & | y () |
Y element of the vector. More... | |
float & | z () |
Z element of the vector. More... | |
void | set (float x, float y, float z) |
Sets x, y and z value. More... | |
void | transformPoint (const Mat4d &m) |
Transforms this point with the transformation matrix m. More... | |
void | transformVector (const Mat4d &m) |
Transforms this vector with the transformation matrix m. More... | |
bool | normalize () |
Normalizes this vector. More... | |
float | length () const |
Returns the length of this vector. More... | |
float | angle (const Vec3f &other) |
Returns the angle (in radians) between this vector and the other. More... | |
Static Public Member Functions | |
static float | dot (const Vec3f &v1, const Vec3f &v2) |
Returns the dot product of v1 and v2. More... | |
static Vec3f | cross (const Vec3f &v1, const Vec3f &v2) |
Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2. More... | |
Vector class for a 3D float vector.
cee::Vec3f::Vec3f | ( | ) |
Constructs a null vector.
cee::Vec3f::Vec3f | ( | const Vec3f & | other | ) |
Constructs a vector as a copy of other.
cee::Vec3f::Vec3f | ( | float | x, |
float | y, | ||
float | z | ||
) |
Constructs a vector from an x, y and z coordinate.
float cee::Vec3f::angle | ( | const Vec3f & | other | ) |
Returns the angle (in radians) between this vector and the other.
Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2.
Returns the dot product of v1 and v2.
Formula:
float cee::Vec3f::length | ( | ) | const |
Returns the length of this vector.
bool cee::Vec3f::normalize | ( | ) |
Normalizes this vector.
Returns false if the vector is a null vector. Otherwise returns true.
bool cee::Vec3f::operator!= | ( | const Vec3f & | rhs | ) | const |
Returns true if two vectors are not equal, otherwise returns false.
Exact comparison is used (!= between floats)
const Vec3f cee::Vec3f::operator* | ( | float | scalar | ) | const |
Returns a vector that is this vector multiplies with scalar.
float cee::Vec3f::operator* | ( | const Vec3f & | rhs | ) | const |
Computes the dot product of this and rhs and return the result (scalar)
Formula:
Vec3f & cee::Vec3f::operator*= | ( | float | scalar | ) |
Multiplies every components of this vector with the given scalar.
Returns a vector that is this vector added with rhs.
cee::Vec3f & cee::Vec3f::operator+= | ( | const Vec3f & | rhs | ) |
Adds the given rhs vector to this.
Returns a vector that is this vector subtracted with rhs.
cee::Vec3f & cee::Vec3f::operator-= | ( | const Vec3f & | rhs | ) |
Subtracts the given rhs vector from this.
const Vec3f cee::Vec3f::operator/ | ( | float | scalar | ) | const |
Returns a vector that is this vector divided with scalar.
Vec3f & cee::Vec3f::operator/= | ( | float | scalar | ) |
Divides every components of this vector with the given scalar.
Assigns other to this vector and returns a reference to this vector.
bool cee::Vec3f::operator== | ( | const Vec3f & | rhs | ) | const |
Returns true if two vectors are equal, otherwise returns false.
An exact match is required x() == rhs.x(), etc.
Computes the cross product of this and rhs and return the result (vector)
Formula:
void cee::Vec3f::set | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets x, y and z value.
void cee::Vec3f::transformPoint | ( | const Mat4d & | m | ) |
Transforms this point with the transformation matrix m.
void cee::Vec3f::transformVector | ( | const Mat4d & | m | ) |
Transforms this vector with the transformation matrix m.
const float & cee::Vec3f::x | ( | ) | const |
X element of the vector.
float & cee::Vec3f::x | ( | ) |
X element of the vector.
const float & cee::Vec3f::y | ( | ) | const |
Y element of the vector.
float & cee::Vec3f::y | ( | ) |
Y element of the vector.
const float & cee::Vec3f::z | ( | ) | const |
Z element of the vector.
float & cee::Vec3f::z | ( | ) |
Z element of the vector.