A 3D Vector with floating point coordinates, used for storing normals and all sorts of other 3D graphics operations.
Vector3s can be transformed by a Matrix4, and a Vector3 can be created by subtracting two Point3s. Example:
Point3 a(0,0,0);
Point3 b(2,0,0);
float f = d.Dot(e);
float option1 = v.x();
float option2 = v[0];
std::cout << v << std::endl;
static float ToDegrees(float radians)
float w() const
In homogeneous coordinates, the w coordinate for all vectors is 0.0.
Vector3()
Default constructor to create zero vector.
Definition at line 62 of file vector3.h.
|
| Vector3 () |
| Default constructor to create zero vector. More...
|
|
| Vector3 (float x, float y, float z) |
| Constructs a vector (x,y,z,0), where the 0 comes from the use of homogeneous coordinates in computer graphics. More...
|
|
| Vector3 (float *v) |
| Constructs a vector given a pointer to x,y,z data. More...
|
|
| Vector3 (const Vector3 &v) |
| Copy constructor for vector. More...
|
|
virtual | ~Vector3 () |
| Vector destructor. More...
|
|
bool | operator== (const Vector3 &v) const |
| Check for "equality", taking floating point imprecision into account. More...
|
|
bool | operator!= (const Vector3 &v) const |
| Check for "inequality", taking floating point imprecision into account. More...
|
|
Vector3 & | operator= (const Vector3 &v) |
| Vector assignment operator. More...
|
|
float | operator[] (const int i) const |
| Read only access to the ith coordinate of the vector. More...
|
|
float & | operator[] (const int i) |
| Returns a reference to the ith coordinate of the vector. Use this accessor if you wish to set the coordinate rather than just request its value. Example: More...
|
|
float | x () const |
| Read only access to the x coordinate. Can also use my_vector[0]. Use the my_vector[0] = 1.0; form if you need to set the value. More...
|
|
float | y () const |
| Read only access to the y coordinate. Can also use my_vector[1]. Use the my_vector[1] = 1.0; form if you need to set the value. More...
|
|
float | z () const |
| Read only access to the z coordinate. Can also use my_vector[2]. Use the my_vector[2] = 1.0; form if you need to set the value. More...
|
|
float | w () const |
| In homogeneous coordinates, the w coordinate for all vectors is 0.0. More...
|
|
float | Dot (const Vector3 &v) const |
| Returns "this dot v", for example: More...
|
|
Vector3 | Cross (const Vector3 &v) const |
| Returns "this cross v", for example: More...
|
|
float | Length () const |
| Returns the length of the vector. More...
|
|
void | Normalize () |
| Normalizes the vector by making it unit length. More...
|
|
Vector3 | ToUnit () const |
| Returns a normalized (i.e., unit length) version of the vector without modifying the original 'this' vector. More...
|
|
const float * | value_ptr () const |
| Returns a const pointer to the raw data array. More...
|
|
Vector3 | Lerp (const Vector3 &b, float alpha) const |
| Linear interpolation between this vector and another. Alpha=0.0 returns this vector, and alpha=1.0 returns the other vector, other values blend between the two. More...
|
|
|
static const Vector3 & | Zero () |
| (0,0,0) - a shortcut for a special vector that is frequently needed More...
|
|
static const Vector3 & | One () |
| (1,1,1) - a shortcut for a special vector that is frequently needed More...
|
|
static const Vector3 & | UnitX () |
| (1,0,0) - a shortcut for a special vector that is frequently needed More...
|
|
static const Vector3 & | UnitY () |
| (0,1,0) - a shortcut for a special vector that is frequently needed More...
|
|
static const Vector3 & | UnitZ () |
| (0,0,1) - a shortcut for a special vector that is frequently needed More...
|
|
static Vector3 | Normalize (const Vector3 &v) |
| Returns a new vector that is the unit version of v. More...
|
|
static Vector3 | Cross (const Vector3 &v1, const Vector3 &v2) |
| Returns v1 cross v2. More...
|
|
static float | Dot (const Vector3 &v1, const Vector3 &v2) |
| Returns v1 dot v2. More...
|
|
static Vector3 | Lerp (const Vector3 &a, const Vector3 &b, float alpha) |
| Linear interpolation between two vectors. Alpha=0.0 returns 'a' and alpha=1.0 returns 'b', other values blend between the two. More...
|
|