14 #ifndef SRC_VECTOR3_H_
15 #define SRC_VECTOR3_H_
104 float x()
const {
return v[0]; }
108 float y()
const {
return v[1]; }
112 float z()
const {
return v[2]; }
115 float w()
const {
return 0.0; }
A 3D Point with floating point coordinates, used for storing vertices and all sorts of other 3D graph...
A 3D Vector with floating point coordinates, used for storing normals and all sorts of other 3D graph...
static float Dot(const Vector3 &v1, const Vector3 &v2)
Returns v1 dot v2.
float w() const
In homogeneous coordinates, the w coordinate for all vectors is 0.0.
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 ...
float Dot(const Vector3 &v) const
Returns "this dot v", for example:
Vector3 Cross(const Vector3 &v) const
Returns "this cross v", for example:
Vector3 ToUnit() const
Returns a normalized (i.e., unit length) version of the vector without modifying the original 'this' ...
static Vector3 Cross(const Vector3 &v1, const Vector3 &v2)
Returns v1 cross v2.
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',...
static const Vector3 & UnitZ()
(0,0,1) - a shortcut for a special vector that is frequently needed
static const Vector3 & Zero()
(0,0,0) - a shortcut for a special vector that is frequently needed
virtual ~Vector3()
Vector destructor.
float Length() const
Returns the length of the vector.
float z() const
Read only access to the z coordinate. Can also use my_vector[2]. Use the my_vector[2] = 1....
Vector3()
Default constructor to create zero vector.
bool operator==(const Vector3 &v) const
Check for "equality", taking floating point imprecision into account.
static const Vector3 & UnitY()
(0,1,0) - a shortcut for a special vector that is frequently needed
Vector3 Lerp(const Vector3 &b, float alpha) const
Linear interpolation between this vector and another. Alpha=0.0 returns this vector,...
Vector3(float *v)
Constructs a vector given a pointer to x,y,z data.
void Normalize()
Normalizes the vector by making it unit length.
float operator[](const int i) const
Read only access to the ith coordinate of the vector.
Vector3 & operator=(const Vector3 &v)
Vector assignment operator.
const float * value_ptr() const
Returns a const pointer to the raw data array.
bool operator!=(const Vector3 &v) const
Check for "inequality", taking floating point imprecision into account.
float & operator[](const int i)
Returns a reference to the ith coordinate of the vector. Use this accessor if you wish to set the coo...
float x() const
Read only access to the x coordinate. Can also use my_vector[0]. Use the my_vector[0] = 1....
static const Vector3 & UnitX()
(1,0,0) - a shortcut for a special vector that is frequently needed
float y() const
Read only access to the y coordinate. Can also use my_vector[1]. Use the my_vector[1] = 1....
static Vector3 Normalize(const Vector3 &v)
Returns a new vector that is the unit version of v.
Vector3(const Vector3 &v)
Copy constructor for vector.
static const Vector3 & One()
(1,1,1) - a shortcut for a special vector that is frequently needed
Namespace for the MinGfx Toolkit.
Quaternion operator-(const Quaternion &q)
AABB operator+(const AABB &A, const AABB &B)
Quaternion operator/(const Quaternion &q, const float s)
std::ostream & operator<<(std::ostream &os, const Color &c)
std::istream & operator>>(std::istream &is, Color &c)
Matrix4 operator*(const Matrix4 &m, const float &s)
Multiply matrix and scalar, returns the new matrix.