Colobot
|
3D (3x1) vector More...
#include <vector.h>
Public Member Functions | |
Vector () | |
Creates a zero vector (0, 0, 0) More... | |
Vector (float _x, float _y, float _z) | |
Creates a vector from given values. More... | |
void | LoadZero () |
Loads the zero vector (0, 0, 0) More... | |
float * | Array () |
Returns the struct cast to float* array; use with care! More... | |
const float * | Array () const |
Returns the struct cast to const float* array; use with care! More... | |
float | Length () const |
Returns the vector length. More... | |
void | Normalize () |
Normalizes the vector. More... | |
Vector | CrossMultiply (const Vector &right) const |
Calculates the cross product with another vector. More... | |
float | DotMultiply (const Vector &right) const |
Calculates the dot product with another vector. More... | |
float | CosAngle (const Vector &right) const |
Returns the cosine of angle between this and another vector. More... | |
float | Angle (const Vector &right) const |
Returns angle (in radians) between this and another vector. More... | |
Vector | operator- () const |
Returns the inverted vector. More... | |
const Vector & | operator+= (const Vector &right) |
Adds the given vector. More... | |
const Vector & | operator-= (const Vector &right) |
Subtracts the given vector. More... | |
const Vector & | operator*= (const float &right) |
Multiplies by given scalar. More... | |
const Vector & | operator/= (const float &right) |
Divides by given scalar. More... | |
std::string | ToString () const |
Returns a string "[x, y, z]". More... | |
Public Attributes | |
float | x |
X - 1st coord. More... | |
float | y |
Y - 2nd coord. More... | |
float | z |
Z - 3rd coord. More... | |
Friends | |
const Vector | operator+ (const Vector &left, const Vector &right) |
Adds two vectors. More... | |
const Vector | operator- (const Vector &left, const Vector &right) |
Subtracts two vectors. More... | |
const Vector | operator* (const float &left, const Vector &right) |
Multiplies vector by scalar. More... | |
const Vector | operator* (const Vector &left, const float &right) |
Multiplies vector by scalar. More... | |
const Vector | operator/ (const Vector &left, const float &right) |
Divides vector by scalar. More... | |
3D (3x1) vector
Represents a universal 3x1 vector that can be used in OpenGL and DirectX engines. Contains the required methods for operating on vectors.
All methods are made inline to maximize optimization.
Unit tests for the structure and related functions are in module: math/test/vector_test.cpp.
|
inline |
Creates a zero vector (0, 0, 0)
|
inlineexplicit |
Creates a vector from given values.
|
inline |
Loads the zero vector (0, 0, 0)
|
inline |
Returns the struct cast to float*
array; use with care!
|
inline |
Returns the struct cast to const float*
array; use with care!
|
inline |
Returns the vector length.
|
inline |
Normalizes the vector.
Calculates the cross product with another vector.
right | right-hand side vector |
|
inline |
Calculates the dot product with another vector.
right | right-hand side vector |
|
inline |
Returns the cosine of angle between this and another vector.
|
inline |
Returns angle (in radians) between this and another vector.
|
inline |
Returns the inverted vector.
|
inline |
Multiplies by given scalar.
|
inline |
Divides by given scalar.
|
inline |
Returns a string "[x, y, z]".
Multiplies vector by scalar.
Multiplies vector by scalar.
Divides vector by scalar.
float Math::Vector::x |
X - 1st coord.
float Math::Vector::y |
Y - 2nd coord.
float Math::Vector::z |
Z - 3rd coord.