struct TVector3

template<class T>

A three dimensional vector.

Public

Constructors

TVector3<T>

TVector3<T>() = default

TVector3<T>

constexpr TVector3<T>(ZeroTag)

TVector3<T>

constexpr TVector3<T>(T value)

TVector3<T>

constexpr TVector3<T>(T x, T y, T z)

TVector3<T>

explicit TVector3<T>(const Vector4 &vec)

TVector3

TVector3() noexcept = default

TVector3

constexpr TVector3(ZeroTag)

TVector3

constexpr TVector3(float value)

TVector3

constexpr TVector3(float x, float y, float z)

TVector3

explicit TVector3(const Vector4 &vec)

TVector3

TVector3() = default

TVector3

constexpr TVector3(ZeroTag)

TVector3

constexpr TVector3(double value)

TVector3

constexpr TVector3(double x, double y, double z)

TVector3

explicit TVector3(const Vector4 &vec)

Methods

Swap

void Swap(TVector3<T> &other)

Exchange the contents of this vector with another.

Length

T Length() const

Returns the length (magnitude) of the vector.

SquaredLength

T SquaredLength() const

Returns the square of the length(magnitude) of the vector.

Distance

T Distance(const TVector3<T> &rhs) const

Returns the distance to another vector.

SquaredDistance

T SquaredDistance(const TVector3<T> &rhs) const

Returns the square of the distance to another vector.

Dot

T Dot(const TVector3<T> &rhs) const

Calculates the dot (scalar) product of this vector with another.

Normalize

T Normalize()

Normalizes this vector, and returns the previous length.

NormalizeChecked

T NormalizeChecked(T tolerance = (T)1.0E-4)

Normalizes this vector, and returns the previous length.

Checks if the magnitude is above to avoid division by zero or precision issues. If false, no checks are made.

Cross

TVector3<T> Cross(const TVector3<T> &other) const

Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both.

Min

void Min(const TVector3<T> &other)

Sets this vector's components to the minimum of its own and the ones of the passed in vector.

Max

void Max(const TVector3<T> &other)

Sets this vector's components to the maximum of its own and the ones of the passed in vector.

Perpendicular

TVector3<T> Perpendicular() const

Generates a vector perpendicular to this vector.

AngleBetween

TRadian<T> AngleBetween(const TVector3<T> &other) const

Gets the angle between 2 vectors.

IsZeroLength

bool IsZeroLength(T tolerance = (T)1.0E-4) const

Returns true if this vector is zero length.

Reflect

TVector3<T> Reflect(const TVector3<T> &normal) const

Calculates a reflection vector to the plane with the given normal.

OrthogonalComplement

void OrthogonalComplement(TVector3<T> &a, TVector3<T> &b)

Calculates two vectors orthonormal to the current vector, and normalizes the current vector if not already.

staticOrthonormalize

static void Orthonormalize(TVector3<T> &vec0, TVector3<T> &vec1, TVector3<T> &vec2)

Performs Gram-Schmidt orthonormalization.

staticDot

static T Dot(const TVector3<T> &a, const TVector3<T> &b)

Calculates the dot (scalar) product of two vectors.

staticNormalize

static TVector3<T> Normalize(const TVector3<T> &rhs)

Normalizes the provided vector and returns the result.

staticNormalizeChecked

static TVector3<T> NormalizeChecked(const TVector3<T> &rhs, T tolerance = (T)1.0E-4)

Normalizes the provided vector and returns the result.

Checks if the magnitude is above to avoid division by zero or precision issues. If false, no checks are made.

staticCross

static TVector3<T> Cross(const TVector3<T> &a, const TVector3<T> &b)

Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both.

staticLerp

static TVector3<T> Lerp(T t, const TVector3<T> &a, const TVector3<T> &b)

Linearly interpolates between the two vectors using . t should be in [0, 1] range, where t = 0 corresponds to the left vector, while t = 1 corresponds to the right vector.

IsNaN

bool IsNaN() const

Checks are any of the vector components not a number.

staticMin

static TVector3<T> Min(const TVector3<T> &a, const TVector3<T> &b)

Returns the minimum of all the vector components as a new vector.

staticMax

static TVector3<T> Max(const TVector3<T> &a, const TVector3<T> &b)

Returns the maximum of all the vector components as a new vector.

Swap

void Swap(TVector3<float> &other)

Exchange the contents of this vector with another.

Length

float Length() const

Returns the length (magnitude) of the vector.

SquaredLength

float SquaredLength() const

Returns the square of the length(magnitude) of the vector.

Distance

float Distance(const TVector3<float> &rhs) const

Returns the distance to another vector.

SquaredDistance

float SquaredDistance(const TVector3<float> &rhs) const

Returns the square of the distance to another vector.

Dot

float Dot(const TVector3<float> &rhs) const

Calculates the dot (scalar) product of this vector with another.

Normalize

float Normalize()

Normalizes this vector, and returns the previous length.

NormalizeChecked

float NormalizeChecked(float tolerance)

Normalizes this vector, and returns the previous length.

Checks if the magnitude is above to avoid division by zero or precision issues. If false, no checks are made.

Cross

TVector3<float> Cross(const TVector3<float> &other) const

Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both.

Min

void Min(const TVector3<float> &other)

Sets this vector's components to the minimum of its own and the ones of the passed in vector.

Max

void Max(const TVector3<float> &other)

Sets this vector's components to the maximum of its own and the ones of the passed in vector.

Perpendicular

TVector3<float> Perpendicular() const

Generates a vector perpendicular to this vector.

AngleBetween

TRadian<float> AngleBetween(const TVector3<float> &other) const

Gets the angle between 2 vectors.

IsZeroLength

bool IsZeroLength(float tolerance) const

Returns true if this vector is zero length.

Reflect

TVector3<float> Reflect(const TVector3<float> &normal) const

Calculates a reflection vector to the plane with the given normal.

OrthogonalComplement

void OrthogonalComplement(TVector3<float> &a, TVector3<float> &b)

Calculates two vectors orthonormal to the current vector, and normalizes the current vector if not already.

staticOrthonormalize

static void Orthonormalize(TVector3<float> &vec0, TVector3<float> &vec1, TVector3<float> &vec2)

Performs Gram-Schmidt orthonormalization.

staticDot

static float Dot(const TVector3<float> &a, const TVector3<float> &b)

Calculates the dot (scalar) product of two vectors.

staticNormalize

static TVector3<float> Normalize(const TVector3<float> &rhs)

Normalizes the provided vector and returns the result.

staticNormalizeChecked

static TVector3<float> NormalizeChecked(const TVector3<float> &rhs, float tolerance)

Normalizes the provided vector and returns the result.

Checks if the magnitude is above to avoid division by zero or precision issues. If false, no checks are made.

staticCross

static TVector3<float> Cross(const TVector3<float> &a, const TVector3<float> &b)

Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both.

staticLerp

static TVector3<float> Lerp(float t, const TVector3<float> &a, const TVector3<float> &b)

Linearly interpolates between the two vectors using . t should be in [0, 1] range, where t = 0 corresponds to the left vector, while t = 1 corresponds to the right vector.

IsNaN

bool IsNaN() const

Checks are any of the vector components not a number.

staticMin

static TVector3<float> Min(const TVector3<float> &a, const TVector3<float> &b)

Returns the minimum of all the vector components as a new vector.

staticMax

static TVector3<float> Max(const TVector3<float> &a, const TVector3<float> &b)

Returns the maximum of all the vector components as a new vector.

Swap

void Swap(TVector3<double> &other)

Exchange the contents of this vector with another.

Length

double Length() const

Returns the length (magnitude) of the vector.

SquaredLength

double SquaredLength() const

Returns the square of the length(magnitude) of the vector.

Distance

double Distance(const TVector3<double> &rhs) const

Returns the distance to another vector.

SquaredDistance

double SquaredDistance(const TVector3<double> &rhs) const

Returns the square of the distance to another vector.

Dot

double Dot(const TVector3<double> &rhs) const

Calculates the dot (scalar) product of this vector with another.

Normalize

double Normalize()

Normalizes this vector, and returns the previous length.

NormalizeChecked

double NormalizeChecked(double tolerance)

Normalizes this vector, and returns the previous length.

Checks if the magnitude is above to avoid division by zero or precision issues. If false, no checks are made.

Cross

TVector3<double> Cross(const TVector3<double> &other) const

Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both.

Min

void Min(const TVector3<double> &other)

Sets this vector's components to the minimum of its own and the ones of the passed in vector.

Max

void Max(const TVector3<double> &other)

Sets this vector's components to the maximum of its own and the ones of the passed in vector.

Perpendicular

TVector3<double> Perpendicular() const

Generates a vector perpendicular to this vector.

AngleBetween

TRadian<double> AngleBetween(const TVector3<double> &other) const

Gets the angle between 2 vectors.

IsZeroLength

bool IsZeroLength(double tolerance) const

Returns true if this vector is zero length.

Reflect

TVector3<double> Reflect(const TVector3<double> &normal) const

Calculates a reflection vector to the plane with the given normal.

OrthogonalComplement

void OrthogonalComplement(TVector3<double> &a, TVector3<double> &b)

Calculates two vectors orthonormal to the current vector, and normalizes the current vector if not already.

staticOrthonormalize

static void Orthonormalize(TVector3<double> &vec0, TVector3<double> &vec1, TVector3<double> &vec2)

Performs Gram-Schmidt orthonormalization.

staticDot

static double Dot(const TVector3<double> &a, const TVector3<double> &b)

Calculates the dot (scalar) product of two vectors.

staticNormalize

static TVector3<double> Normalize(const TVector3<double> &rhs)

Normalizes the provided vector and returns the result.

staticNormalizeChecked

static TVector3<double> NormalizeChecked(const TVector3<double> &rhs, double tolerance)

Normalizes the provided vector and returns the result.

Checks if the magnitude is above to avoid division by zero or precision issues. If false, no checks are made.

staticCross

static TVector3<double> Cross(const TVector3<double> &a, const TVector3<double> &b)

Calculates the cross-product of 2 vectors, that is, the vector that lies perpendicular to them both.

staticLerp

static TVector3<double> Lerp(double t, const TVector3<double> &a, const TVector3<double> &b)

Linearly interpolates between the two vectors using . t should be in [0, 1] range, where t = 0 corresponds to the left vector, while t = 1 corresponds to the right vector.

IsNaN

bool IsNaN() const

Checks are any of the vector components not a number.

staticMin

static TVector3<double> Min(const TVector3<double> &a, const TVector3<double> &b)

Returns the minimum of all the vector components as a new vector.

staticMax

static TVector3<double> Max(const TVector3<double> &a, const TVector3<double> &b)

Returns the maximum of all the vector components as a new vector.

Fields

X

T X

Y

T Y

Z

T Z

X

float X

Y

float Y

Z

float Z

X

double X

Y

double Y

Z

double Z

Operators

operator[]

T operator[](u32 i) const

operator[]

T &operator[](u32 i)

operator=

TVector3<T> &operator=(T rhs)

operator==

bool operator==(const TVector3<T> &rhs) const

operator!=

bool operator!=(const TVector3<T> &rhs) const

operator+

TVector3<T> operator+(const TVector3<T> &rhs) const

operator-

TVector3<T> operator-(const TVector3<T> &rhs) const

operator*

TVector3<T> operator*(T rhs) const

operator*

TVector3<T> operator*(const TVector3<T> &rhs) const

operator/

TVector3<T> operator/(T value) const

operator/

TVector3<T> operator/(const TVector3<T> &rhs) const

operator+

const TVector3<T> &operator+() const

operator-

TVector3<T> operator-() const

operator+=

TVector3<T> &operator+=(const TVector3<T> &rhs)

operator+=

TVector3<T> &operator+=(T rhs)

operator-=

TVector3<T> &operator-=(const TVector3<T> &rhs)

operator-=

TVector3<T> &operator-=(T rhs)

operator*=

TVector3<T> &operator*=(T rhs)

operator*=

TVector3<T> &operator*=(const TVector3<T> &rhs)

operator/=

TVector3<T> &operator/=(T rhs)

operator/=

TVector3<T> &operator/=(const TVector3<T> &rhs)

operator[]

float operator[](u32 i) const

operator[]

float &operator[](u32 i)

operator=

TVector3<float> &operator=(float rhs)

operator==

bool operator==(const TVector3<float> &rhs) const

operator!=

bool operator!=(const TVector3<float> &rhs) const

operator+

TVector3<float> operator+(const TVector3<float> &rhs) const

operator-

TVector3<float> operator-(const TVector3<float> &rhs) const

operator*

TVector3<float> operator*(float rhs) const

operator*

TVector3<float> operator*(const TVector3<float> &rhs) const

operator/

TVector3<float> operator/(float value) const

operator/

TVector3<float> operator/(const TVector3<float> &rhs) const

operator+

const TVector3<float> &operator+() const

operator-

TVector3<float> operator-() const

operator+=

TVector3<float> &operator+=(const TVector3<float> &rhs)

operator+=

TVector3<float> &operator+=(float rhs)

operator-=

TVector3<float> &operator-=(const TVector3<float> &rhs)

operator-=

TVector3<float> &operator-=(float rhs)

operator*=

TVector3<float> &operator*=(float rhs)

operator*=

TVector3<float> &operator*=(const TVector3<float> &rhs)

operator/=

TVector3<float> &operator/=(float rhs)

operator/=

TVector3<float> &operator/=(const TVector3<float> &rhs)

operator[]

double operator[](u32 i) const

operator[]

double &operator[](u32 i)

operator=

TVector3<double> &operator=(double rhs)

operator==

bool operator==(const TVector3<double> &rhs) const

operator!=

bool operator!=(const TVector3<double> &rhs) const

operator+

TVector3<double> operator+(const TVector3<double> &rhs) const

operator-

TVector3<double> operator-(const TVector3<double> &rhs) const

operator*

TVector3<double> operator*(double rhs) const

operator*

TVector3<double> operator*(const TVector3<double> &rhs) const

operator/

TVector3<double> operator/(double value) const

operator/

TVector3<double> operator/(const TVector3<double> &rhs) const

operator+

const TVector3<double> &operator+() const

operator-

TVector3<double> operator-() const

operator+=

TVector3<double> &operator+=(const TVector3<double> &rhs)

operator+=

TVector3<double> &operator+=(double rhs)

operator-=

TVector3<double> &operator-=(const TVector3<double> &rhs)

operator-=

TVector3<double> &operator-=(double rhs)

operator*=

TVector3<double> &operator*=(double rhs)

operator*=

TVector3<double> &operator*=(const TVector3<double> &rhs)

operator/=

TVector3<double> &operator/=(double rhs)

operator/=

TVector3<double> &operator/=(const TVector3<double> &rhs)