Vector class for a 3D double vector. More...
Public Member Functions | |
Vec3d () | |
Constructs a null vector. More... | |
Vec3d (const Vec3d &other) | |
Constructs a vector as a copy of other. More... | |
Vec3d (double x, double y, double z) | |
Constructs a vector from an x, y and z coordinate. More... | |
Vec3d & | operator= (const Vec3d &other) |
Assigns other to this vector and returns a reference to this vector. More... | |
bool | operator== (const Vec3d &rhs) const |
Returns true if two vectors are equal, otherwise returns false. More... | |
bool | operator!= (const Vec3d &rhs) const |
Returns true if two vectors are not equal, otherwise returns false. More... | |
const Vec3d | operator+ (const Vec3d &rhs) const |
Returns a vector that is this vector added with rhs. More... | |
const Vec3d | operator- (const Vec3d &rhs) const |
Returns a vector that is this vector subtracted with rhs. More... | |
const Vec3d | operator* (double scalar) const |
Returns a vector that is this vector multiplied by a given scalar. More... | |
const Vec3d | operator/ (double scalar) const |
Returns a vector that is this vector divided by a given scalar. More... | |
Vec3d & | operator+= (const Vec3d &rhs) |
Adds the given rhs vector to this. More... | |
Vec3d & | operator-= (const Vec3d &rhs) |
Subtracts the given rhs vector from this. More... | |
Vec3d & | operator*= (double scalar) |
Multiplies every component of this vector by the given scalar. More... | |
Vec3d & | operator/= (double scalar) |
Divides every component of this vector by the given scalar. More... | |
double | operator* (const Vec3d &rhs) const |
Computes the dot product of this and rhs and return the result (scalar) More... | |
const Vec3d | operator^ (const Vec3d &rhs) const |
Computes the cross product of this and rhs and return the result (vector) More... | |
const double & | x () const |
X element of the vector. More... | |
const double & | y () const |
Y element of the vector. More... | |
const double & | z () const |
Z element of the vector. More... | |
double & | x () |
X element of the vector. More... | |
double & | y () |
Y element of the vector. More... | |
double & | z () |
Z element of the vector. More... | |
void | set (double x, double y, double 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... | |
double | length () const |
Returns the length of this vector. More... | |
double | lengthSquared () const |
Returns the length of this vector. More... | |
double | angle (const Vec3d &other) |
Returns the angle (in radians) between this vector and the other. More... | |
Static Public Member Functions | |
static double | dot (const Vec3d &v1, const Vec3d &v2) |
Returns the dot product of v1 and v2. More... | |
static Vec3d | cross (const Vec3d &v1, const Vec3d &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... | |
Friends | |
Vec3d | operator* (double scalar, const Vec3d &v) |
Returns a vector that is the vector v multiplied by a given scalar. More... | |
Vector class for a 3D double vector.
cee::Vec3d::Vec3d | ( | ) |
Constructs a null vector.
cee::Vec3d::Vec3d | ( | const Vec3d & | other | ) |
Constructs a vector as a copy of other.
cee::Vec3d::Vec3d | ( | double | x, |
double | y, | ||
double | z | ||
) |
Constructs a vector from an x, y and z coordinate.
double cee::Vec3d::angle | ( | const Vec3d & | 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:
double cee::Vec3d::length | ( | ) | const |
Returns the length of this vector.
double cee::Vec3d::lengthSquared | ( | ) | const |
Returns the length of this vector.
bool cee::Vec3d::normalize | ( | ) |
Normalizes this vector.
Returns false if the vector is a null vector. Otherwise returns true.
bool cee::Vec3d::operator!= | ( | const Vec3d & | rhs | ) | const |
Returns true if two vectors are not equal, otherwise returns false.
Exact comparison is used (!= between doubles)
const Vec3d cee::Vec3d::operator* | ( | double | scalar | ) | const |
Returns a vector that is this vector multiplied by a given scalar.
double cee::Vec3d::operator* | ( | const Vec3d & | rhs | ) | const |
Computes the dot product of this and rhs and return the result (scalar)
Formula:
Vec3d & cee::Vec3d::operator*= | ( | double | scalar | ) |
Multiplies every component of this vector by the given scalar.
Returns a vector that is this vector added with rhs.
cee::Vec3d & cee::Vec3d::operator+= | ( | const Vec3d & | rhs | ) |
Adds the given rhs vector to this.
Returns a vector that is this vector subtracted with rhs.
cee::Vec3d & cee::Vec3d::operator-= | ( | const Vec3d & | rhs | ) |
Subtracts the given rhs vector from this.
const Vec3d cee::Vec3d::operator/ | ( | double | scalar | ) | const |
Returns a vector that is this vector divided by a given scalar.
Vec3d & cee::Vec3d::operator/= | ( | double | scalar | ) |
Divides every component of this vector by the given scalar.
Assigns other to this vector and returns a reference to this vector.
bool cee::Vec3d::operator== | ( | const Vec3d & | 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::Vec3d::set | ( | double | x, |
double | y, | ||
double | z | ||
) |
Sets x, y and z value.
void cee::Vec3d::transformPoint | ( | const Mat4d & | m | ) |
Transforms this point with the transformation matrix m.
void cee::Vec3d::transformVector | ( | const Mat4d & | m | ) |
Transforms this vector with the transformation matrix m.
const double & cee::Vec3d::x | ( | ) | const |
X element of the vector.
double & cee::Vec3d::x | ( | ) |
X element of the vector.
const double & cee::Vec3d::y | ( | ) | const |
Y element of the vector.
double & cee::Vec3d::y | ( | ) |
Y element of the vector.
const double & cee::Vec3d::z | ( | ) | const |
Z element of the vector.
double & cee::Vec3d::z | ( | ) |
Z element of the vector.