Vector3
Inherited: None
Description
Vectors are one of the main building blocks of 3D representation and drawing. They consist of three coordinates, traditionally called x, y, and z.
The Vector3 class can also be used to represent vertices in 3D space. We therefore do not need to provide a separate vertex class.
Note: By design values in the Vector3 instance are stored as float. This means that on platforms where the areal arguments to Vector3 functions are represented by double values, it is possible to lose precision.
Public Methods
Vector3 () |
|
Vector3 (areal v) |
|
Vector3 (const areal * v) |
|
Vector3 (const Vector2 & vector, areal z) |
|
Vector3 (areal x, areal y, areal z) |
|
Vector3 (const Vector3 & vector) |
|
abs () const |
|
areal |
angle (const Vector3 & vector) const |
cross (const Vector3 & vector) const |
|
areal |
dot (const Vector3 & vector) const |
areal |
length () const |
areal |
normalize () |
areal |
signedAngle (const Vector3 & vector, const Vector3 up) const |
areal |
sqrLength () const |
bool |
operator!= (const Vector3 & vector) const |
operator* (areal factor) const |
|
operator* (const Vector3 & vector) const |
|
Vector3 & |
operator*= (areal factor) |
operator+ (const Vector3 & vector) const |
|
Vector3 & |
operator+= (const Vector3 & vector) |
operator- () const |
|
operator- (const Vector3 & vector) const |
|
Vector3 & |
operator-= (const Vector3 & vector) |
operator/ (areal divisor) const |
|
Vector3 & |
operator/= (areal divisor) |
bool |
operator (const Vector3 & vector) const |
Vector3 & |
operator= (const Vector3 & value) |
bool |
operator== (const Vector3 & vector) const |
bool |
operator> (const Vector3 & vector) const |
areal |
operator[] (int i) |
areal |
operator[] (int i) const |
Static Methods
None
Methods Description
Vector3::Vector3 ()
Constructs a null vector, i.e. with coordinates (0, 0, 0).
Vector3::Vector3 (areal v)
Constructs a *v*ector with coordinates (v).
Vector3::Vector3 (areal * v)
Constructs a 3D v*ector from *v (areal[3] array).
Vector3::Vector3 (Vector2 & vector, areal z)
Constructs a 3D vector from the specified 2D vector. The z coordinate is set to z.
Vector3::Vector3 (areal x, areal y, areal z)
Constructs a vector with coordinates (x, y, z).
Vector3::Vector3 (Vector3 & vector)
Copy constructor.
Vector3 Vector3::abs () const
Returns the absplute value of this vector.
areal Vector3::angle (Vector3 & vector) const
Returns an absolute angle between current and provided vector.
See also signedAngle().
Returns the cross-product of this vector and given vector.
See also dot().
areal Vector3::dot (Vector3 & vector) const
Returns the dot-product of this vector and given vector.
See also cross().
areal Vector3::length () const
Returns the length of this vector.
See also sqrLength().
areal Vector3::normalize ()
Normalizes the currect vector in place. Returns length of prenormalized vector.
See also length().
Returns an signed angle between current and provided vector. The up vector around which the current and provided *vector*s are rotated.
See also angle().
areal Vector3::sqrLength () const
Returns the squared length of this vector.
See also length().
bool Vector3::operator!= (Vector3 & vector) const
Returns true if this vector is NOT equal to given vector; otherwise returns false. This operator uses an exact floating-point comparison.
Vector3 Vector3::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*=().
Vector3 & Vector3::operator*= (areal factor)
Multiplies this vector’s coordinates by the given factor, and returns a reference to this vector.
See also operator/=().
Returns a Vector3 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-=().
Vector3 Vector3::operator- () const
Returns a Vector3 object that is formed by changing the sign of all three components of the this vector.
Equivalent to Vector3(0,0,0) - vector.
Returns a Vector3 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+=().
Vector3 Vector3::operator/ (areal divisor) const
Returns a copy of this vector, divided by the given divisor.
See also operator/=().
Vector3 & Vector3::operator/= (areal divisor)
Divides this vector’s coordinates by the given divisor, and returns a reference to this vector.
See also operator*=().
bool Vector3::operator< (Vector3 & 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 Vector3::operator== (Vector3 & vector) const
Returns true if this vector is equal to given vector; otherwise returns false. This operator uses an exact floating-point comparison.
bool Vector3::operator> (Vector3 & vector) const
Returns true if this vector is bigger than given vector; otherwise returns false. This operator uses an exact floating-point comparison.
areal Vector3::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 < 3).
areal Vector3::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 < 3).