14 #ifndef SRC_VECTOR2_H_
15 #define SRC_VECTOR2_H_
70 float x()
const {
return v[0]; }
74 float y()
const {
return v[1]; }
77 float w()
const {
return 0.0; }
A 2D Point with floating point coordinates, used for storing 2D texture coordinates,...
A 2D Vector with floating point coordinates, used for storing 2D translations, mouse movements,...
static Vector2 Normalize(const Vector2 &v)
Returns a new vector that is the unit version of v.
bool operator!=(const Vector2 &v) const
Check for "inequality", taking floating point imprecision into account.
float w() const
In homogeneous coordinates, the w coordinate for all vectors is 0.0.
Vector2 & operator=(const Vector2 &v)
Vector assignment operator.
Vector2(const Vector2 &v)
Copy constructor for vector.
Vector2 Lerp(const Vector2 &b, float alpha) const
Linear interpolation between this vector and another. Alpha=0.0 returns this vector,...
static const Vector2 & One()
(1,1) - a shortcut for a special vector that is frequently needed
void Normalize()
Normalizes the vector by making it unit length.
Vector2(float *v)
Constructs a vector given a pointer to x,y,z data.
Vector2 ToUnit() const
Returns a normalized (i.e., unit length) version of the vector without modifying the original ('this'...
float Length() const
Returns the length of the vector.
static const Vector2 & Zero()
(0,0) - a shortcut for a special vector that is frequently needed
const float * value_ptr() const
Returns a const pointer to the raw data array.
static const Vector2 & UnitX()
(1,0) - a shortcut for a special vector that is frequently needed
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...
Vector2()
Default constructor to create zero vector.
static float Dot(const Vector2 &v1, const Vector2 &v2)
Returns v1 dot v2.
static const Vector2 & UnitY()
(0,1) - a shortcut for a special vector that is frequently needed
static Vector2 Lerp(const Vector2 &a, const Vector2 &b, float alpha)
Linear interpolation between two vectors. Alpha=0.0 returns 'a' and alpha=1.0 returns 'b',...
float y() const
Read only access to the y coordinate. Can also use my_vector[1]. Use the my_vector[1] = 1....
virtual ~Vector2()
Vector destructor.
Vector2(float x, float y)
Constructs a vector (x,y,0), where the 0 comes from the use of homogeneous coordinates in computer gr...
bool operator==(const Vector2 &v) const
Check for "equality", taking floating point imprecision into account.
float operator[](const int i) const
Read only access to the ith coordinate of the vector.
float Dot(const Vector2 &v) const
Returns "this dot v".
float x() const
Read only access to the x coordinate. Can also use my_vector[0]. Use the my_vector[0] = 1....
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.