API Documentation
Vector.h
1 // Vector.h
3 //
5 
6 namespace nkMaths
7 {
11  class Vector
12  {
13  public :
14 
19  Vector () noexcept ;
28  Vector (float x, float y) noexcept ;
38  Vector (float x, float y, float z) noexcept ;
47  Vector (float x, float y, float z, float w) noexcept ;
53  Vector (const Vector& other) noexcept ;
59  Vector (const IntVector& other) noexcept ;
60 
61  // Length
65  float getLengthVec2 () const ;
69  float getLengthVec3 () const ;
73  float getLengthVec4 () const ;
79  float getLengthSquaredVec2 () const ;
85  float getLengthSquaredVec3 () const ;
91  float getLengthSquaredVec4 () const ;
92  // Distance
97  float getDistanceVec2 (const Vector& other) const ;
102  float getDistanceVec3 (const Vector& other) const ;
107  float getDistanceVec4 (const Vector& other) const ;
114  float getDistanceSquaredVec2 (const Vector& other) const ;
121  float getDistanceSquaredVec3 (const Vector& other) const ;
128  float getDistanceSquaredVec4 (const Vector& other) const ;
129 
158  // Dot product
165  float dotProductVec2 (const Vector& other) const ;
172  float dotProductVec3 (const Vector& other) const ;
179  float dotProductVec4 (const Vector& other) const ;
180  // Cross product
186  Vector& setAsCrossVec3 (const Vector& other) ;
193  Vector getCrossVec3 (const Vector& other) const ;
194 
195  // Practical
199  nkMemory::String toString () const ;
207  Vector& fromString (nkMemory::StringView str) ;
208 
209  // Operators
216  Vector& operator= (const Vector& other) noexcept ;
223  Vector& operator= (const IntVector& other) noexcept ;
230  Vector operator+ (const Vector& other) const ;
236  void operator+= (const Vector& other) ;
242  Vector operator- () const ;
249  Vector operator- (const Vector& other) const ;
255  void operator-= (const Vector& other) ;
262  Vector operator* (const Vector& other) const ;
268  void operator*= (const Vector& other) ;
275  Vector operator* (const Quaternion& other) const ;
281  void operator*= (const Quaternion& other) ;
288  Vector operator* (const Matrix& mat) const ;
294  void operator*= (const Matrix& other) ;
301  Vector operator* (float coeff) const ;
307  void operator*= (float coeff) ;
314  Vector operator/ (const Vector& other) const ;
320  void operator/= (const Vector& other) ;
327  Vector operator/ (float coeff) const ;
333  void operator/= (float coeff) ;
340  bool operator== (const Vector& other) const ;
347  bool operator!= (const Vector& other) const ;
354  bool operator< (const Vector& other) const ;
361  bool operator<= (const Vector& other) const ;
368  bool operator> (const Vector& other) const ;
375  bool operator>= (const Vector& other) const ;
376 
377  // Statics
378  // Distance
386  static float distanceVec2 (const Vector& a, const Vector& b) ;
394  static float distanceVec3 (const Vector& a, const Vector& b) ;
402  static float distanceVec4 (const Vector& a, const Vector& b) ;
410  static float distanceSquaredVec2 (const Vector& a, const Vector& b) ;
418  static float distanceSquaredVec3 (const Vector& a, const Vector& b) ;
426  static float distanceSquaredVec4 (const Vector& a, const Vector& b) ;
427  // Dot product
435  static float dotVec2 (const Vector& a, const Vector& b) ;
443  static float dotVec3 (const Vector& a, const Vector& b) ;
451  static float dotVec4 (const Vector& a, const Vector& b) ;
452  // Cross product
460  static Vector crossVec3 (const Vector& a, const Vector& b) ;
461 
462  public :
463 
464  // Attributes
465  float _x ;
466  float _y ;
467  float _z ;
468  float _w ;
469  } ;
470 
471  using FloatVector = Vector ;
472 }
nkMaths::Vector::distanceVec3
static float distanceVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthVec4
float getLengthVec4() const
nkMaths::Vector::getDistanceSquaredVec2
float getDistanceSquaredVec2(const Vector &other) const
nkMaths::Vector::distanceSquaredVec2
static float distanceSquaredVec2(const Vector &a, const Vector &b)
nkMaths::IntVector
A 4-component vector class, with integers.
Definition: IntVector.h:12
nkMaths::Vector::distanceVec2
static float distanceVec2(const Vector &a, const Vector &b)
nkMaths::Vector::getCrossVec3
Vector getCrossVec3(const Vector &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Vector::getLengthVec3
float getLengthVec3() const
nkMaths::Vector::distanceSquaredVec4
static float distanceSquaredVec4(const Vector &a, const Vector &b)
nkMaths::Vector::getDistanceVec4
float getDistanceVec4(const Vector &other) const
nkMaths::Vector::dotVec3
static float dotVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthSquaredVec2
float getLengthSquaredVec2() const
nkMaths::Vector::dotVec4
static float dotVec4(const Vector &a, const Vector &b)
nkMaths::Vector::_x
float _x
X component of the vector.
Definition: Vector.h:465
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Vector::Vector
Vector() noexcept
nkMaths::Vector::getDistanceVec2
float getDistanceVec2(const Vector &other) const
nkMaths::Vector::setAsCrossVec3
Vector & setAsCrossVec3(const Vector &other)
nkMaths::Vector::normalizeVec2
Vector & normalizeVec2()
nkMaths::Vector::getDistanceSquaredVec4
float getDistanceSquaredVec4(const Vector &other) const
nkMaths::Vector::distanceSquaredVec3
static float distanceSquaredVec3(const Vector &a, const Vector &b)
nkMaths::Vector::normalizeVec4
Vector & normalizeVec4()
nkMaths::Vector::crossVec3
static Vector crossVec3(const Vector &a, const Vector &b)
nkMaths::Vector::toString
nkMemory::String toString() const
nkMaths::Vector::dotProductVec3
float dotProductVec3(const Vector &other) const
nkMaths::Vector::_z
float _z
Z component of the vector.
Definition: Vector.h:467
nkMaths::Vector::_w
float _w
W component of the vector.
Definition: Vector.h:468
nkMaths::Vector::getLengthSquaredVec3
float getLengthSquaredVec3() const
nkMaths::Vector::dotProductVec4
float dotProductVec4(const Vector &other) const
nkMaths::Vector::getDistanceVec3
float getDistanceVec3(const Vector &other) const
nkMaths::Vector::fromString
Vector & fromString(nkMemory::StringView str)
nkMaths::Vector::getNormalizedVec2
Vector getNormalizedVec2() const
nkMaths::Vector::getNormalizedVec3
Vector getNormalizedVec3() const
nkMaths::Vector::_y
float _y
Y component of the vector.
Definition: Vector.h:466
nkMaths::Vector::getNormalizedVec4
Vector getNormalizedVec4() const
nkMaths::Vector::getLengthVec2
float getLengthVec2() const
nkMaths::Vector::dotProductVec2
float dotProductVec2(const Vector &other) const
nkMaths::Vector::getLengthSquaredVec4
float getLengthSquaredVec4() const
nkMaths::Vector::getDistanceSquaredVec3
float getDistanceSquaredVec3(const Vector &other) const
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Vector::distanceVec4
static float distanceVec4(const Vector &a, const Vector &b)
nkMaths::Vector::normalizeVec3
Vector & normalizeVec3()
nkMaths::Vector::dotVec2
static float dotVec2(const Vector &a, const Vector &b)
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7