Vector3

Fields

double _x
double _y
double _z
const Vector3 UNIT
const Vector3 ZERO
const Vector3 XAXIS
const Vector3 YAXIS
const Vector3 ZAXIS
const Vector3 UNDEFINED

Detailed Description

class Vector3 : public RED::Object

3D vector used for geometrical operations.

@related class RED::Vector4, class RED::Matrix

Public Functions

SET_CID (CID_class_REDVector3) IMPLEMENT_AS()
Vector3()

Default constructor.

Constructs a zero vector.

Vector3(double iX, double iY, double iZ)

Constructor.

Parameters:
  • iX – X dimension of the vector.
  • iY – Y dimension of the vector.
  • iZ – Z dimension of the vector.
Vector3(double iV)

Direct assignment construction.

Parameters:iV – Value, replicated on the 3 members of the vector.
Vector3(const RED::Vector4 &iSource)

Construction from a clamped RED::Vector4.

Parameters:iSource – The source of the values. The W vector4 value is lost.
Vector3(const RED::Color &iSource)

Construction from a clamped RED::Color.

Parameters:iSource – The source of the values. The alpha color value is lost.
virtual ~Vector3()

Destructor.

inline void Set(double iX, double iY, double iZ)

Sets the 3d vector coordinates to the provided values.

Parameters:
  • iX – First vector coordinate.
  • iY – Second vector coordinate.
  • iZ – Third vector coordinate.
inline void Set(const double iValues[3])

Sets the 3d vector coordinates to the provided values.

Parameters:iValues – Three vector coordinates.
inline double operator[](unsigned int iIndex) const

Vector member access.

Parameters:iIndexVector coordinate to access 0:x, 1:y, 2:z.
Returns:The corresponding vector coordinate.
inline double &operator[](unsigned int iIndex)

Vector member access.

Parameters:iIndexVector coordinate to access 0:x, 1:y, 2:z.
Returns:The corresponding vector coordinate.
inline RED::Vector3 operator+(const RED::Vector3 &iSource) const

Addition operation.

Builds a new vector by the addition of two others.

Returns:the sum of the two input vectors.
inline RED::Vector3 operator-(const RED::Vector3 &iSource) const

Subtraction operation.

Builds a new vector by the subtraction of two others.

Returns:the subtraction of the two input vectors.
inline void operator+=(const RED::Vector3 &iSource)

Increment operation.

Adds the iSource vector to ‘this’.

Parameters:iSource – Right operand of the addition.
inline void operator-=(const RED::Vector3 &iSource)

Decrement operation.

Subtracts the iSource vector to ‘this’.

Parameters:iSource – Right operand of the addition.
inline RED::Vector3 operator*(double iScalar) const

Multiplies the components of a vector with a scalar.

Parameters:iScalar – Number to multiply the vector with.
Returns:The product of the vector with the scalar.
inline RED::Vector3 operator*(const RED::Vector3 &iRight) const

Component-wise multiplication of a vector by a vector.

Parameters:iRight – Right operand of the multiplication.
Returns:The product of the two vectors.
inline void operator*=(double iScalar)

Multiplies the components of the vector with a scalar.

Parameters:iScalar – Number to multiply the vector with.
inline void operator*=(const RED::Vector3 &iRight)

Multiplication of members of two vectors.

Store in ‘this’ the result of the component wise product of ‘this’ with iRight.

Parameters:iRightVector to multiply to this.
inline RED::Vector3 operator/(double iScalar) const

Divides the components of a vector by a scalar.

Parameters:iScalar – Number to divide the vector by.
Returns:The division of the vector by the scalar.
inline RED::Vector3 operator/(const RED::Vector3 &iRight) const

Division of members of two vectors.

Builds a new vector whose members are the component wise division of ‘this’ with iRight.

Parameters:iRightVector to divide from this.
Returns:The division of the two vectors.
inline void operator/=(double iScalar)

Divides the components of the vector by a scalar.

Parameters:iScalar – Number to divide the vector by.
inline void operator/=(const RED::Vector3 &iRight)

Division of members of two vectors.

Store in ‘this’ the result of the component wise division of ‘this’ by iRight.

Parameters:iRightVector to divide from this.
inline RED::Vector3 operator-() const

Returns the opposite of the vector.

Returns:-‘this’
inline bool operator==(const RED::Vector3 &iOther) const

Returns the result of an equality test between two vectors.

Parameters:iOther – Reference to the vector to test with.
Returns:true if the two vectors are identical, false otherwise.
inline bool operator!=(const RED::Vector3 &iOther) const

Returns the result of a difference test between two vectors.

Parameters:iOther – Reference to the vector to test with.
Returns:true if the two vectors are different, false otherwise.
inline bool operator<(const RED::Vector3 &iOther) const

Returns true if this is lower than iOther, component wise.

Parameters:iOther – Reference to the vector to test with.
Returns:true if this is lower than iOther, false otherwise.
inline double GetLength() const

Gets the length of the vector.

Returns:The length of the vector.
inline double GetLength2() const

Gets the squared length of the vector.

Returns:The squared length of the vector.
inline double Normalize()

Normalizes the vector.

The normalized vector is constructed by dividing its three components by its length.

Returns:The length of the vector before normalization.
inline double Dot(const RED::Vector3 &iV) const

Dot product of two vectors.

Parameters:iV – Right operand of the dot product.
Returns:The dot product of the two vectors.
inline void Cross(const RED::Vector3 &iV)

Cross product of two vectors.

The result is stored in ‘this’.

Parameters:iV – Right operand of the cross product.
inline RED::Vector3 Cross2(const RED::Vector3 &iV) const

Cross product of two vectors.

Returns:the result of the cross product between ‘this’ and iV.
inline double X() const

Gets the X dimension of the vector.

Returns:The X dimension of the vector.
inline double Y() const

Gets the Y dimension of the vector.

Returns:The Y dimension of the vector.
inline double Z() const

Gets the Z dimension of the vector.

Returns:The Z dimension of the vector.
inline void OrthoBasis(RED::Vector3 &u, RED::Vector3 &v) const

Builds an orthogonal basis from an input vector.

The returned basis is (u, v, this). u and v are normalized before returning.

Parameters:
  • u – The first basis vector.
  • v – The second basis vector.

Public Members

double _x

X dimension of the vector.

double _y

Y dimension of the vector.

double _z

Z dimension of the vector.

Public Static Attributes

static const RED::Vector3 UNIT

Unit vector.

static const RED::Vector3 ZERO

Zero vector.

static const RED::Vector3 XAXIS

( 1, 0, 0 ) vector.

static const RED::Vector3 YAXIS

( 0, 1, 0 ) vector.

static const RED::Vector3 ZAXIS

( 0, 0, 1 ) vector.

static const RED::Vector3 UNDEFINED

( DBL_MAX, DBL_MAX, DBL_MAX ) vector.