Momentum Scripting v1
Loading...
Searching...
No Matches
MOMENTUM_NAMESPACE::Vec4 Class Reference

#include <Vec4.h>

Public Types

typedef double Type
 

Public Member Functions

 Vec4 ()
 
 Vec4 (const double v[4])
 
 Vec4 (const Vec3 &v3, double w)
 
 Vec4 (const Vec4 &copy)
 
 Vec4 (double r)
 
 Vec4 (double x, double y, double z, double w)
 
Vec3 asVec3 () const
 
void clamp (const Vec4 &min, const Vec4 &max)
 
double distance (const Vec4 &v2) const
 
double distance2 (const Vec4 &v2) const
 
bool equalsZero () const
 
bool isFinite () const
 
bool isNaN () const
 
bool isValid () const
 
double length () const
 
double length2 () const
 
double maxComponent () const
 
int maxElement () const
 
double minComponent () const
 
int minElement () const
 
double normalize ()
 
bool operator!= (const Vec4 &v) const
 
double operator* (const Vec4 &rhs) const
 
const Vec4 operator* (double rhs) const
 
Vec4operator*= (double rhs)
 
const Vec4 operator+ (const double &rhs) const
 
const Vec4 operator+ (const Vec4 &rhs) const
 
Vec4operator+= (const double &rhs)
 
Vec4operator+= (const Vec4 &rhs)
 
const Vec4 operator- () const
 
const Vec4 operator- (const double &rhs) const
 
const Vec4 operator- (const Vec4 &rhs) const
 
Vec4operator-= (const double &rhs)
 
Vec4operator-= (const Vec4 &rhs)
 
const Vec4 operator/ (double rhs) const
 
Vec4operator/= (double rhs)
 
bool operator== (const Vec4 &v) const
 
double & operator[] (int i)
 
const double & operator[] (int i) const
 
const Vec4 operator| (const Vec4 &rhs) const
 
void set (const Vec4 &rhs)
 
void set (double value)
 
void set (double x, double y, double z, double w)
 
void setW (double value)
 
void setX (double value)
 
void setY (double value)
 
void setZ (double value)
 
double w () const
 
double x () const
 
double y () const
 
double z () const
 

Static Public Member Functions

static Vec4 componentMax (const Vec4 &v1, const Vec4 &v2)
 
static Vec4 componentMin (const Vec4 &v1, const Vec4 &v2)
 
static Vec4 random (const Vec4 &min, const Vec4 &max)
 
static Vec4 random (double min, double max)
 

Detailed Description

A 4 dimensional vector and contains basic arithmetic.

Member Typedef Documentation

◆ Type

Constructor & Destructor Documentation

◆ Vec4() [1/6]

MOMENTUM_NAMESPACE::Vec4::Vec4 ( const Vec4 copy)

Copy constructor.

◆ Vec4() [2/6]

MOMENTUM_NAMESPACE::Vec4::Vec4 ( )

Default constructor.

◆ Vec4() [3/6]

MOMENTUM_NAMESPACE::Vec4::Vec4 ( double  r)
explicit

Constructor, fill all elements with scalar r.

◆ Vec4() [4/6]

MOMENTUM_NAMESPACE::Vec4::Vec4 ( double  x,
double  y,
double  z,
double  w 
)

Constructor, initialize elements with the specified scalars.

◆ Vec4() [5/6]

MOMENTUM_NAMESPACE::Vec4::Vec4 ( const double  v[4])
explicit

Constructor, initialize elements with the specified scalars.

◆ Vec4() [6/6]

MOMENTUM_NAMESPACE::Vec4::Vec4 ( const Vec3 v3,
double  w 
)

Constructor, initialize the first three elements with v3 and the last with w.

Member Function Documentation

◆ asVec3()

Vec3 MOMENTUM_NAMESPACE::Vec4::asVec3 ( ) const
Returns
the x, y and z components as a Vec3

◆ clamp()

void MOMENTUM_NAMESPACE::Vec4::clamp ( const Vec4 min,
const Vec4 max 
)

Clamp a vector between a lower and upper bound (per component).

◆ componentMax()

Vec4 MOMENTUM_NAMESPACE::Vec4::componentMax ( const Vec4 v1,
const Vec4 v2 
)
static
Returns
a new vector where each component is the maximum of this and the other vector.

◆ componentMin()

Vec4 MOMENTUM_NAMESPACE::Vec4::componentMin ( const Vec4 v1,
const Vec4 v2 
)
static
Returns
a new vector where each component is the minimum of this and the other vector.

◆ distance()

double MOMENTUM_NAMESPACE::Vec4::distance ( const Vec4 v2) const
Returns
Distance to another vector

◆ distance2()

double MOMENTUM_NAMESPACE::Vec4::distance2 ( const Vec4 v2) const
Returns
squared distance to another vector

◆ equalsZero()

bool MOMENTUM_NAMESPACE::Vec4::equalsZero ( ) const
Returns
true if all elements are zero

◆ isFinite()

bool MOMENTUM_NAMESPACE::Vec4::isFinite ( ) const
Returns
true if all of the elements is are non-NaN and non-inf

◆ isNaN()

bool MOMENTUM_NAMESPACE::Vec4::isNaN ( ) const
Returns
true if any of the elements is NAN

◆ isValid()

bool MOMENTUM_NAMESPACE::Vec4::isValid ( ) const
Returns
true if all elements is valid

◆ length()

double MOMENTUM_NAMESPACE::Vec4::length ( ) const
Returns
length of the vector = sqrt( vec . vec )

◆ length2()

double MOMENTUM_NAMESPACE::Vec4::length2 ( ) const
Returns
spared length of the vector = vec . vec

◆ maxComponent()

double MOMENTUM_NAMESPACE::Vec4::maxComponent ( ) const
Returns
the largest component (in absolute value).

◆ maxElement()

int MOMENTUM_NAMESPACE::Vec4::maxElement ( ) const
Returns
the index of the largest element (in absolute value)

◆ minComponent()

double MOMENTUM_NAMESPACE::Vec4::minComponent ( ) const
Returns
the smallest component (in absolute value).

◆ minElement()

int MOMENTUM_NAMESPACE::Vec4::minElement ( ) const
Returns
the index of the smallest element (in absolute value)

◆ normalize()

double MOMENTUM_NAMESPACE::Vec4::normalize ( )

Normalize the vector so that it has length unity.

Returns
the previous length of the vector.

◆ operator!=()

bool MOMENTUM_NAMESPACE::Vec4::operator!= ( const Vec4 v) const

In-equality test.

◆ operator*() [1/2]

double MOMENTUM_NAMESPACE::Vec4::operator* ( const Vec4 rhs) const
Returns
the Dot product.

◆ operator*() [2/2]

const Vec4 MOMENTUM_NAMESPACE::Vec4::operator* ( double  rhs) const
Returns
a new Vec4 multiplied by scalar rhs.

◆ operator*=()

Vec4 & MOMENTUM_NAMESPACE::Vec4::operator*= ( double  rhs)
Returns
a reference to the Vec4 Unary multiplied by the scalar rhs

◆ operator+() [1/2]

const Vec4 MOMENTUM_NAMESPACE::Vec4::operator+ ( const double &  rhs) const

Binary vector add.

◆ operator+() [2/2]

const Vec4 MOMENTUM_NAMESPACE::Vec4::operator+ ( const Vec4 rhs) const

Binary vector add.

Returns
a new Vec4 which is the sum of this Vec4 and rhs

◆ operator+=() [1/2]

Vec4 & MOMENTUM_NAMESPACE::Vec4::operator+= ( const double &  rhs)

Unary vector add.

Slightly more efficient because no temporary intermediate object.

◆ operator+=() [2/2]

Vec4 & MOMENTUM_NAMESPACE::Vec4::operator+= ( const Vec4 rhs)

Unary vector add.

Slightly more efficient because no temporary intermediate object.

◆ operator-() [1/3]

const Vec4 MOMENTUM_NAMESPACE::Vec4::operator- ( ) const

Negation operator.

Returns the negative of the Vec4.

◆ operator-() [2/3]

const Vec4 MOMENTUM_NAMESPACE::Vec4::operator- ( const double &  rhs) const

Binary vector subtract.

◆ operator-() [3/3]

const Vec4 MOMENTUM_NAMESPACE::Vec4::operator- ( const Vec4 rhs) const

Binary vector subtract.

◆ operator-=() [1/2]

Vec4 & MOMENTUM_NAMESPACE::Vec4::operator-= ( const double &  rhs)

Unary vector subtract.

◆ operator-=() [2/2]

Vec4 & MOMENTUM_NAMESPACE::Vec4::operator-= ( const Vec4 rhs)

Unary vector subtract.

◆ operator/()

const Vec4 MOMENTUM_NAMESPACE::Vec4::operator/ ( double  rhs) const

Divide by scalar.

◆ operator/=()

Vec4 & MOMENTUM_NAMESPACE::Vec4::operator/= ( double  rhs)
Returns
reference to the Vec4 Unary divided by scalar rhs.

◆ operator==()

bool MOMENTUM_NAMESPACE::Vec4::operator== ( const Vec4 v) const

Equality test.

◆ operator[]() [1/2]

double & MOMENTUM_NAMESPACE::Vec4::operator[] ( int  i)
Returns
a reference to the i:th element

◆ operator[]() [2/2]

const double & MOMENTUM_NAMESPACE::Vec4::operator[] ( int  i) const
Returns
a reference to the i:th element

◆ operator|()

const Vec4 MOMENTUM_NAMESPACE::Vec4::operator| ( const Vec4 rhs) const
Returns
the result of an Element-wise-multiplication

◆ random() [1/2]

Vec4 MOMENTUM_NAMESPACE::Vec4::random ( const Vec4 min,
const Vec4 max 
)
static
Returns
a random Vec4 in the range of [min..max]

◆ random() [2/2]

Vec4 MOMENTUM_NAMESPACE::Vec4::random ( double  min,
double  max 
)
static
Returns
a random Vec4 in the range of [min..max]

◆ set() [1/3]

void MOMENTUM_NAMESPACE::Vec4::set ( const Vec4 rhs)

Set the value of the vector with rhs.

◆ set() [2/3]

void MOMENTUM_NAMESPACE::Vec4::set ( double  value)

Set all elements of the vector with scalar value value.

◆ set() [3/3]

void MOMENTUM_NAMESPACE::Vec4::set ( double  x,
double  y,
double  z,
double  w 
)

Set the elements of the vector.

◆ setW()

void MOMENTUM_NAMESPACE::Vec4::setW ( double  value)

◆ setX()

void MOMENTUM_NAMESPACE::Vec4::setX ( double  value)

◆ setY()

void MOMENTUM_NAMESPACE::Vec4::setY ( double  value)

◆ setZ()

void MOMENTUM_NAMESPACE::Vec4::setZ ( double  value)

◆ w()

double MOMENTUM_NAMESPACE::Vec4::w ( ) const
Returns
the 4:th element

◆ x()

double MOMENTUM_NAMESPACE::Vec4::x ( ) const
Returns
the 1:st element

◆ y()

double MOMENTUM_NAMESPACE::Vec4::y ( ) const
Returns
the 2:nd element

◆ z()

double MOMENTUM_NAMESPACE::Vec4::z ( ) const
Returns
the 3:rd element