.. _api_Vector4: Vector4 ======= Inherited: None .. _api_Vector4_description: Description ----------- Vectors are one of the main building blocks of 4D representation and drawing. They consist of three coordinates, traditionally called x, y, z and w. The Vector4 class can also be used to represent vertices in 4D space. We therefore do not need to provide a separate vertex class. Note: By design values in the Vector4 instance are stored as float. This means that on platforms where the areal arguments to Vector4 functions are represented by double values, it is possible to lose precision. .. _api_Vector4_public: Public Methods -------------- +--------------------------------+-----------------------------------------------------------------------------------+ | | :ref:`Vector4` () | +--------------------------------+-----------------------------------------------------------------------------------+ | | :ref:`Vector4` (areal v) | +--------------------------------+-----------------------------------------------------------------------------------+ | | :ref:`Vector4` (areal x, areal y, areal z, areal w) | +--------------------------------+-----------------------------------------------------------------------------------+ | | :ref:`Vector4` (const Vector2 & vector) | +--------------------------------+-----------------------------------------------------------------------------------+ | | :ref:`Vector4` (const Vector2 & vector, areal z, areal w) | +--------------------------------+-----------------------------------------------------------------------------------+ | | :ref:`Vector4` (const Vector3 & vector) | +--------------------------------+-----------------------------------------------------------------------------------+ | | :ref:`Vector4` (const Vector3 & vector, areal w) | +--------------------------------+-----------------------------------------------------------------------------------+ | | :ref:`Vector4` (const Vector4 & vector) | +--------------------------------+-----------------------------------------------------------------------------------+ | areal | :ref:`dot` (const Vector4 & vector) const | +--------------------------------+-----------------------------------------------------------------------------------+ | areal | :ref:`length` () const | +--------------------------------+-----------------------------------------------------------------------------------+ | areal | :ref:`normalize` () | +--------------------------------+-----------------------------------------------------------------------------------+ | areal | :ref:`sqrLength` () const | +--------------------------------+-----------------------------------------------------------------------------------+ | bool | :ref:`operator!=` (const Vector4 & vector) const | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`operator*` (areal factor) const | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`operator*` (const Vector4 & vector) const | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` & | :ref:`operator*=` (areal factor) | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`operator+` (const Vector4 & vector) const | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` & | :ref:`operator+=` (const Vector4 & vector) | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`operator-` () const | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`operator-` (const Vector4 & vector) const | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` & | :ref:`operator-=` (const Vector4 & vector) | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` | :ref:`operator/` (areal divisor) const | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` & | :ref:`operator/=` (areal divisor) | +--------------------------------+-----------------------------------------------------------------------------------+ | bool | :ref:`operator\<` (const Vector4 & vector) const | +--------------------------------+-----------------------------------------------------------------------------------+ | :ref:`Vector4` & | :ref:`operator=` (const Vector4 & value) | +--------------------------------+-----------------------------------------------------------------------------------+ | bool | :ref:`operator==` (const Vector4 & vector) const | +--------------------------------+-----------------------------------------------------------------------------------+ | bool | :ref:`operator>` (const Vector4 & vector) const | +--------------------------------+-----------------------------------------------------------------------------------+ | areal | :ref:`operator[]` (int i) | +--------------------------------+-----------------------------------------------------------------------------------+ | areal | :ref:`operator[]` (int i) const | +--------------------------------+-----------------------------------------------------------------------------------+ .. _api_Vector4_static: Static Methods -------------- None .. _api_Vector4_methods: Methods Description ------------------- .. _api_Vector4_681e70ba: **Vector4::Vector4** () Constructs a null vector, i.e. with coordinates (0, 0, 0, 0). ---- .. _api_Vector4_67a204bd: **Vector4::Vector4** (areal *v*) Constructs a vector with coordinates (v). ---- .. _api_Vector4_e086fdb5: **Vector4::Vector4** (areal *x*, areal *y*, areal *z*, areal *w*) Constructs a vector with coordinates (x, y, z, w). ---- .. _api_Vector4_492ce375: **Vector4::Vector4** (:ref:`Vector2` & *vector*) Constructs a 4D *vector* from the specified 2D vector. ---- .. _api_Vector4_486971b0: **Vector4::Vector4** (:ref:`Vector2` & *vector*, areal *z*, areal *w*) Constructs a 4D *vector* from the specified 2D vector. The *z* and *w* coordinates is set to *z* and w. ---- .. _api_Vector4_d89f072c: **Vector4::Vector4** (:ref:`Vector3` & *vector*) Constructs a 4D *vector* from the specified 3D vector. **See also** Vector3::Vector3(). ---- .. _api_Vector4_c1da6e89: **Vector4::Vector4** (:ref:`Vector3` & *vector*, areal *w*) Constructs a 4D *vector* from the specified 3D vector. The *w* coordinate is set to w. **See also** Vector3::Vector3(). ---- .. _api_Vector4_8497ec50: **Vector4::Vector4** (:ref:`Vector4` & *vector*) Copy constructor. ---- .. _api_Vector4_5a49fdb3: areal **Vector4::dot** (:ref:`Vector4` & *vector*) const Returns the dot-product of this *vector* and given vector. ---- .. _api_Vector4_b3185da6: areal **Vector4::length** () const Returns the length of this vector. **See also** sqrLength(). ---- .. _api_Vector4_8f19d624: areal **Vector4::normalize** () Normalizes the currect vector in place. Returns length of prenormalized vector. **See also** length(). ---- .. _api_Vector4_c2718ef9: areal **Vector4::sqrLength** () const Returns the squared length of this vector. **See also** length(). ---- .. _api_Vector4_ca1be784: bool **Vector4::operator!=** (:ref:`Vector4` & *vector*) const Returns true if this *vector* is NOT equal to given vector; otherwise returns false. This operator uses an exact floating-point comparison. ---- .. _api_Vector4_b5308c9e: :ref:`Vector4` **Vector4::operator*** (areal *factor*) const Returns a copy of this vector, multiplied by the given factor. **See also** operator*=(). ---- .. _api_Vector4_403bc972: :ref:`Vector4` **Vector4::operator*** (:ref:`Vector4` & *vector*) const Returns a copy of this vector, multiplied by the given vector. **See also** operator*=(). ---- .. _api_Vector4_e1054cdf: :ref:`Vector4` & **Vector4::operator*=** (areal *factor*) Multiplies this vector's coordinates by the given factor, and returns a reference to this vector. **See also** operator/=(). ---- .. _api_Vector4_ba980e14: :ref:`Vector4` **Vector4::operator+** (:ref:`Vector4` & *vector*) const Returns a Vector4 object that is the sum of the this *vector* and vector; each component is added separately. **See also** operator+=(). ---- .. _api_Vector4_5eb732a0: :ref:`Vector4` & **Vector4::operator+=** (:ref:`Vector4` & *vector*) Adds the given *vector* to this *vector* and returns a reference to this vector. **See also** operator-=(). ---- .. _api_Vector4_05f846b3: :ref:`Vector4` **Vector4::operator-** () const Returns a Vector4 object that is formed by changing the sign of all three components of the this vector. Equivalent to Vector4(0,0,0,1) - vector. ---- .. _api_Vector4_c061df2e: :ref:`Vector4` **Vector4::operator-** (:ref:`Vector4` & *vector*) const Returns a Vector4 object that is formed by subtracting *vector* from this vector; each component is subtracted separately. **See also** operator-=(). ---- .. _api_Vector4_40ca273b: :ref:`Vector4` & **Vector4::operator-=** (:ref:`Vector4` & *vector*) Subtracts the given *vector* from this *vector* and returns a reference to this vector. **See also** operator+=(). ---- .. _api_Vector4_a1e9c687: :ref:`Vector4` **Vector4::operator/** (areal *divisor*) const Returns a copy of this vector, divided by the given divisor. **See also** operator/=(). ---- .. _api_Vector4_2b6a15d0: :ref:`Vector4` & **Vector4::operator/=** (areal *divisor*) Divides this vector's coordinates by the given divisor, and returns a reference to this vector. **See also** operator*=(). ---- .. _api_Vector4_9561e3df: bool **Vector4::operator<** (:ref:`Vector4` & *vector*) const Returns true if this *vector* is less than vector; otherwise returns false. This operator uses an exact floating-point comparison. ---- .. _api_Vector4_bd0c3f92: :ref:`Vector4` & **Vector4::operator=** (:ref:`Vector4` & *value*) Assignment operator. The *value* will be assigned to this object. ---- .. _api_Vector4_9ca538f2: bool **Vector4::operator==** (:ref:`Vector4` & *vector*) const Returns true if this *vector* is equal to given vector; otherwise returns false. This operator uses an exact floating-point comparison. ---- .. _api_Vector4_67a90c38: bool **Vector4::operator>** (:ref:`Vector4` & *vector*) const Returns true if this *vector* is bigger than given vector; otherwise returns false. This operator uses an exact floating-point comparison. ---- .. _api_Vector4_48216073: areal **Vector4::operator[]** (int *i*) Returns the component of the vector at index position *i* as a modifiable reference. *i* must be a valid index position in the vector (i.e., 0 <= *i* < 4). .. _api_Vector4_e189d0f6: areal **Vector4::operator[]** (int *i*) const Returns the component of the vector at index position. *i* must be a valid index position in the vector (i.e., 0 <= *i* < 4).