Vector4
Inherited: None
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.
Public Methods
Vector4 () |
|
Vector4 (areal v) |
|
Vector4 (const Vector2 & vector) |
|
Vector4 (const Vector3 & vector) |
|
Vector4 (const Vector3 & vector, areal w) |
|
Vector4 (const Vector2 & vector, areal z, areal w) |
|
Vector4 (areal x, areal y, areal z, areal w) |
|
Vector4 (const Vector4 & vector) |
|
areal |
dot (const Vector4 & vector) const |
areal |
length () const |
areal |
normalize () |
areal |
sqrLength () const |
bool |
operator!= (const Vector4 & vector) const |
operator* (areal factor) const |
|
operator* (const Vector4 & vector) const |
|
Vector4 & |
operator*= (areal factor) |
operator+ (const Vector4 & vector) const |
|
Vector4 & |
operator+= (const Vector4 & vector) |
operator- () const |
|
operator- (const Vector4 & vector) const |
|
Vector4 & |
operator-= (const Vector4 & vector) |
operator/ (areal divisor) const |
|
Vector4 & |
operator/= (areal divisor) |
bool |
operator (const Vector4 & vector) const |
Vector4 & |
operator= (const Vector4 & value) |
bool |
operator== (const Vector4 & vector) const |
bool |
operator> (const Vector4 & vector) const |
areal |
operator[] (int i) |
areal |
operator[] (int i) const |
Static Methods
None
Methods Description
Vector4::Vector4 ()
Constructs a null vector, i.e. with coordinates (0, 0, 0, 1).
Vector4::Vector4 (areal v)
Constructs a *v*ector with coordinates (v).
Vector4::Vector4 (Vector2 & vector)
Constructs a 4D vector from the specified 2D vector.
Vector4::Vector4 (Vector3 & vector)
Constructs a 4D vector from the specified 3D vector.
See also Vector3::Vector3().
Vector4::Vector4 (Vector3 & vector, areal w)
Constructs a 4D vector from the specified 3D vector. The w coordinate is set to w.
See also Vector3::Vector3().
Vector4::Vector4 (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.
Vector4::Vector4 (areal x, areal y, areal z, areal w)
Constructs a vector w*ith coordinates (x, *y, z, w).
Vector4::Vector4 (Vector4 & vector)
Copy constructor.
areal Vector4::dot (Vector4 & vector) const
Returns the dot-product of this vector and given vector.
areal Vector4::length () const
Returns the length of this vector.
See also sqrLength().
areal Vector4::normalize ()
Normalizes the currect vector in place. Returns length of prenormalized vector.
See also length().
areal Vector4::sqrLength () const
Returns the squared length of this vector.
See also length().
bool Vector4::operator!= (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.
Vector4 Vector4::operator* (areal factor) const
Returns a copy of this vector, multiplied by the given factor.
See also operator*=().
Returns a copy of this vector, multiplied by the given vector.
See also operator*=().
Vector4 & Vector4::operator*= (areal factor)
Multiplies this vector’s coordinates by the given factor, and returns a reference to this vector.
See also operator/=().
Returns a Vector4 object that is the sum of the this vector and vector; each component is added separately.
See also operator+=().
Adds the given vector to this vector and returns a reference to this vector.
See also operator-=().
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.
Returns a Vector4 object that is formed by subtracting vector from this vector; each component is subtracted separately.
See also operator-=().
Subtracts the given vector from this vector and returns a reference to this vector.
See also operator+=().
Vector4 Vector4::operator/ (areal divisor) const
Returns a copy of this vector, divided by the given divisor.
See also operator/=().
Vector4 & Vector4::operator/= (areal divisor)
Divides this vector’s coordinates by the given divisor, and returns a reference to this vector.
See also operator*=().
bool Vector4::operator< (Vector4 & vector) const
Returns true if this vector is less than vector; otherwise returns false. This operator uses an exact floating-point comparison.
Assignment operator. The value will be assigned to this object.
bool Vector4::operator== (Vector4 & vector) const
Returns true if this vector is equal to given vector; otherwise returns false. This operator uses an exact floating-point comparison.
bool Vector4::operator> (Vector4 & vector) const
Returns true if this vector is bigger than given vector; otherwise returns false. This operator uses an exact floating-point comparison.
areal Vector4::operator[] (int i)
Returns the component of the vector at i*ndex position *i as a modifiable reference. i must be a valid i*ndex position *i*n the vector (i.e., 0 <= *i < 4).
areal Vector4::operator[] (int i) const
Returns the component of the vector at i*ndex position. *i must be a valid i*ndex position *i*n the vector (i.e., 0 <= *i < 4).