3D float vector. More...
#include <Vec3f.h>
Public Member Functions | |
Vec3f () | |
Construct 0 vector. | |
Vec3f (float a, float b, float c) | |
Construct a 3D float vector. | |
Vec3f (float a) | |
Construct a vector with 3 identical coordinates. | |
Vec3f (const Vec3i &v) | |
Construct from a 3D int vector. | |
Vec3f (const Vec3usi &v) | |
Construct from a 3D unsigned int vector. | |
Vec3f (const Vec3d &) | |
Construct from a 3D double vector. | |
Vec3f (const Vec4f &) | |
Construct from a 4D float vector (skipping the last value) | |
![]() | |
ArithVec3Float (floata, floatb, floatc) noexcept | |
Construct a 3D float vector. | |
ArithVec3Float () noexcept | |
Construct a 3D float vector. | |
void | get_spherical (float &, float &, float &) const |
void | set_spherical (float, float, float) |
![]() | |
ArithVecFloat (floata) noexcept | |
ArithVecFloat (floata, floatb) noexcept | |
ArithVecFloat (floata, floatb, floatc) noexcept | |
ArithVecFloat (floata, floatb, floatc, floatd) noexcept | |
float | length () const |
Compute Euclidean length. | |
void | normalize () |
Normalize vector. | |
void | cond_normalize () |
Conditionally normalize vector. The condition being that the vector has non-zero length. | |
![]() | |
void | set (float_a, float_b) |
Set all coordinates of a 2D vector. | |
void | set (float_a, float_b, float_c) |
Set all coordinates of a 3D vector. | |
void | set (float_a, float_b, float_c, float_d) |
Set all coordinates of a 4D vector. | |
const float & | operator[] (unsigned int i) const |
Const index operator. | |
float & | operator[] (unsigned int i) |
Non-const index operator. | |
const float & | operator() (unsigned int i) const |
Const index operator. | |
float & | operator() (unsigned int i) |
Non-const index operator. | |
float * | get () |
const float * | get () const |
bool | operator== (const Vec3f &v) const |
Equality operator. | |
bool | operator== (floatk) const |
Equality wrt scalar. True if all coords are equal to scalar. | |
bool | operator!= (const Vec3f &v) const |
Inequality operator. | |
bool | operator!= (floatk) const |
Inequality wrt scalar. True if any coord not equal to scalar. | |
bool | all_l (const Vec3f &v) const |
bool | all_le (const Vec3f &v) const |
bool | all_g (const Vec3f &v) const |
bool | all_ge (const Vec3f &v) const |
const Vec3f & | operator*= (floatk) |
Assignment multiplication with scalar. | |
const Vec3f & | operator*= (const Vec3f &v) |
const Vec3f & | operator/= (floatk) |
Assignment division with scalar. | |
const Vec3f & | operator/= (const Vec3f &v) |
Assigment division with vector. Each coord divided independently. | |
const Vec3f & | operator+= (floatk) |
Assignment addition with scalar. Adds scalar to each coordinate. | |
const Vec3f & | operator+= (const Vec3f &v) |
Assignmment addition with vector. | |
const Vec3f & | operator-= (floatk) |
Assignment subtraction with scalar. Subtracts scalar from each coord. | |
const Vec3f & | operator-= (const Vec3f &v) |
Assignment subtraction with vector. | |
const Vec3f | operator- () const |
Negate vector. | |
const Vec3f | operator- (const Vec3f &v1) const |
Subtract two vectors. | |
const Vec3f | operator* (const Vec3f &v1) const |
const Vec3f | operator* (floatk) const |
Multiply scalar onto vector. | |
const Vec3f | operator+ (const Vec3f &v1) const |
Add two vectors. | |
const Vec3f | operator/ (const Vec3f &v1) const |
Divide two vectors. Each coord separately. | |
const Vec3f | operator/ (floatk) const |
Divide vector by scalar. | |
const float | min_coord () const |
Return the smallest coordinate of the vector. | |
const float | max_coord () const |
Return the largest coordinate of the vector. | |
Additional Inherited Members | |
![]() | |
typedef float | ScalarType |
For convenience we define a more meaningful name for the scalar type. | |
typedef Vec3f | VectorType |
A more meaningful name for vector type. | |
![]() | |
static unsigned int | get_dim () |
Return dimension of vector. | |
![]() | |
ArithVec () | |
Construct uninitialized vector. | |
ArithVec (float_a) | |
Construct a vector where all coordinates are identical. | |
ArithVec (float_a, float_b) | |
Construct a 2D vector. | |
ArithVec (float_a, float_b, float_c) | |
Construct a 3D vector. | |
ArithVec (float_a, float_b, float_c, float_d) | |
Construct a 4D vector. | |
![]() | |
float | data [N] |
The actual contents of the vector. | |
3D float vector.
Class Vec3f is the vector typically used in 3D computer graphics. The class has many constructors since we may need to convert from other vector types. Most of these are explicit to avoid automatic conversion.