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

#include <Vec3.h>

Public Types

typedef double Type
 

Public Member Functions

 Vec3 ()
 
 Vec3 (const double v[3])
 
 Vec3 (const Vec3 &copy)
 
 Vec3 (const Vec3 &copy, double length)
 
 Vec3 (const Vec3 &copy, double value, int i)
 
 Vec3 (double r)
 
 Vec3 (double x, double y, double z)
 
void clamp (const Vec3 &min, const Vec3 &max)
 
const Vec3 cross (const Vec3 &rhs) const
 
double distance (const Vec3 &v2) const
 
double distance2 (const Vec3 &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
 
Vec3 normal () const
 
double normalize ()
 
bool operator!= (const Vec3 &v) const
 
double operator* (const Vec3 &rhs) const
 
const Vec3 operator* (double rhs) const
 
Vec3operator*= (double rhs)
 
const Vec3 operator+ (const double rhs) const
 
const Vec3 operator+ (const Vec3 &rhs) const
 
Vec3operator+= (const double rhs)
 
Vec3operator+= (const Vec3 &rhs)
 
const Vec3 operator- () const
 
const Vec3 operator- (const double rhs) const
 
const Vec3 operator- (const Vec3 &rhs) const
 
Vec3operator-= (const double rhs)
 
Vec3operator-= (const Vec3 &rhs)
 
const Vec3 operator/ (double rhs) const
 
Vec3operator/= (double rhs)
 
bool operator== (const Vec3 &v) const
 
double & operator[] (int i)
 
const double operator[] (int i) const
 
const Vec3 operator^ (const Vec3 &rhs) const
 
void set (const Vec3 &rhs)
 
void set (double value)
 
void set (double x, double y, double z)
 
double setLength (double l)
 
void setX (double value)
 
void setY (double value)
 
void setZ (double value)
 
double x () const
 
double y () const
 
double z () const
 

Static Public Member Functions

static Vec3 AXIS (int i)
 
static Vec3 componentMax (const Vec3 &v1, const Vec3 &v2)
 
static Vec3 componentMin (const Vec3 &v1, const Vec3 &v2)
 
static Vec3 div (const Vec3 &lhs, const Vec3 &rhs)
 
static Vec3 mul (const Vec3 &lhs, const Vec3 &rhs)
 
static Vec3 random (const Vec3 &min, const Vec3 &max)
 
static Vec3 random (double min=double(0), double max=double(1))
 
static Vec3 X_AXIS ()
 
static Vec3 Y_AXIS ()
 
static Vec3 Z_AXIS ()
 

Detailed Description

A 3 dimensional vector which can be used to define a point or a vector and contains basic arithmetic.

Member Typedef Documentation

◆ Type

Constructor & Destructor Documentation

◆ Vec3() [1/7]

MOMENTUM_NAMESPACE::Vec3::Vec3 ( const Vec3 copy)

Copy constructor.

◆ Vec3() [2/7]

MOMENTUM_NAMESPACE::Vec3::Vec3 ( const Vec3 copy,
double  length 
)

◆ Vec3() [3/7]

MOMENTUM_NAMESPACE::Vec3::Vec3 ( const Vec3 copy,
double  value,
int  i 
)

◆ Vec3() [4/7]

MOMENTUM_NAMESPACE::Vec3::Vec3 ( )

Default constructor.

◆ Vec3() [5/7]

MOMENTUM_NAMESPACE::Vec3::Vec3 ( double  r)
explicit

Initialize from another vector.

◆ Vec3() [6/7]

MOMENTUM_NAMESPACE::Vec3::Vec3 ( double  x,
double  y,
double  z 
)

◆ Vec3() [7/7]

MOMENTUM_NAMESPACE::Vec3::Vec3 ( const double  v[3])
explicit

Member Function Documentation

◆ AXIS()

Vec3 MOMENTUM_NAMESPACE::Vec3::AXIS ( int  i)
static
Parameters
iThe axis to choose. 0, 1 or 2.
Returns
a vec3 defining an unit vector along the i-th axis.

◆ clamp()

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

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

◆ componentMax()

Vec3 MOMENTUM_NAMESPACE::Vec3::componentMax ( const Vec3 v1,
const Vec3 v2 
)
static

Creates a new vector where each component is the maximum of this and the other vector.

◆ componentMin()

Vec3 MOMENTUM_NAMESPACE::Vec3::componentMin ( const Vec3 v1,
const Vec3 v2 
)
static

Creates a new vector where each component is the minimum of this and the other vector.

◆ cross()

const Vec3 MOMENTUM_NAMESPACE::Vec3::cross ( const Vec3 rhs) const
Returns
the result of the Cross product operator between this vecor and rhs

◆ distance()

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

◆ distance2()

double MOMENTUM_NAMESPACE::Vec3::distance2 ( const Vec3 v2) const
Returns
Squared distance to another vector

◆ div()

Vec3 MOMENTUM_NAMESPACE::Vec3::div ( const Vec3 lhs,
const Vec3 rhs 
)
static

Element-wise-division.

◆ equalsZero()

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

◆ isFinite()

bool MOMENTUM_NAMESPACE::Vec3::isFinite ( ) const
Returns
true if none of the elements is isNaN and not infinite.

◆ isNaN()

bool MOMENTUM_NAMESPACE::Vec3::isNaN ( ) const
Returns
true if none of the elements is isNaN

◆ isValid()

bool MOMENTUM_NAMESPACE::Vec3::isValid ( ) const
Returns
true if none of the elements is isNaN

◆ length()

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

◆ length2()

double MOMENTUM_NAMESPACE::Vec3::length2 ( ) const
Returns
Length squared of the vector = vec . vec

◆ maxComponent()

double MOMENTUM_NAMESPACE::Vec3::maxComponent ( ) const
Returns
the largest component (value).

◆ maxElement()

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

◆ minComponent()

double MOMENTUM_NAMESPACE::Vec3::minComponent ( ) const
Returns
the smallest component (value).

◆ minElement()

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

◆ mul()

Vec3 MOMENTUM_NAMESPACE::Vec3::mul ( const Vec3 lhs,
const Vec3 rhs 
)
static

Element-wise-multiplication.

◆ normal()

Vec3 MOMENTUM_NAMESPACE::Vec3::normal ( ) const
Returns
a vec3 containing the normalized version of this vector.

◆ normalize()

double MOMENTUM_NAMESPACE::Vec3::normalize ( )

Normalize the vector so that it has length unity.

Returns
the previous length of the vector.

◆ operator!=()

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

In-equality test.

◆ operator*() [1/2]

double MOMENTUM_NAMESPACE::Vec3::operator* ( const Vec3 rhs) const
Returns
the result of the Dot product between this vector and rhs

◆ operator*() [2/2]

const Vec3 MOMENTUM_NAMESPACE::Vec3::operator* ( double  rhs) const

return this vector multiplied by a scalar rhs

◆ operator*=()

Vec3 & MOMENTUM_NAMESPACE::Vec3::operator*= ( double  rhs)

Unary multiply by scalar.

◆ operator+() [1/2]

const Vec3 MOMENTUM_NAMESPACE::Vec3::operator+ ( const double  rhs) const

Binary vector add.

◆ operator+() [2/2]

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

Binary vector add.

◆ operator+=() [1/2]

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

Unary vector add.

Slightly more efficient because no temporary intermediate object.

◆ operator+=() [2/2]

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

Unary vector add.

Slightly more efficient because no temporary intermediate object.

◆ operator-() [1/3]

const Vec3 MOMENTUM_NAMESPACE::Vec3::operator- ( ) const

Negation operator.

Returns
the negative of the Vec3.

◆ operator-() [2/3]

const Vec3 MOMENTUM_NAMESPACE::Vec3::operator- ( const double  rhs) const

Binary vector subtract.

◆ operator-() [3/3]

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

Binary vector subtract.

◆ operator-=() [1/2]

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

Unary vector subtract.

◆ operator-=() [2/2]

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

Unary vector subtract.

◆ operator/()

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

Divide by scalar.

◆ operator/=()

Vec3 & MOMENTUM_NAMESPACE::Vec3::operator/= ( double  rhs)

Unary divide by scalar.

◆ operator==()

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

Equality test.

◆ operator[]() [1/2]

double & MOMENTUM_NAMESPACE::Vec3::operator[] ( int  i)

\access the ith element of this vector

◆ operator[]() [2/2]

const double MOMENTUM_NAMESPACE::Vec3::operator[] ( int  i) const

\access the ith element of this vector

◆ operator^()

const Vec3 MOMENTUM_NAMESPACE::Vec3::operator^ ( const Vec3 rhs) const
Returns
the result of the Cross product operator between this vecor and rhs

◆ random() [1/2]

Vec3 MOMENTUM_NAMESPACE::Vec3::random ( const Vec3 min,
const Vec3 max 
)
static
Parameters
min- each element define a lower range of the generate random value (default 0)
max- each element define a upper range of the generate random value (default 1)
Returns
a randomized vector

◆ random() [2/2]

Vec3 MOMENTUM_NAMESPACE::Vec3::random ( double  min = double(0),
double  max = double(1) 
)
static
Parameters
min- lower range of the generate random value (default 0)
max- upper range of the generate random value (default 1)
Returns
a randomized vector

◆ set() [1/3]

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

◆ set() [2/3]

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

Set the value of this vector with the vector.

◆ set() [3/3]

void MOMENTUM_NAMESPACE::Vec3::set ( double  x,
double  y,
double  z 
)

Set the value of this vector with the specified elements.

◆ setLength()

double MOMENTUM_NAMESPACE::Vec3::setLength ( double  l)

Scale the vector so that is has the specified length.

Returns
the original length

◆ setX()

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

set the x element of this vector

◆ setY()

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

set the y element of this vector

◆ setZ()

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

set the z element of this vector

◆ x()

double MOMENTUM_NAMESPACE::Vec3::x ( ) const
Returns
the x element of this vector

◆ X_AXIS()

Vec3 MOMENTUM_NAMESPACE::Vec3::X_AXIS ( )
static
Returns
a vec3 defining a vector along the x-axis

◆ y()

double MOMENTUM_NAMESPACE::Vec3::y ( ) const
Returns
the y element of this vector

◆ Y_AXIS()

Vec3 MOMENTUM_NAMESPACE::Vec3::Y_AXIS ( )
static
Returns
a vec3 defining a vector along the y-axis

◆ z()

double MOMENTUM_NAMESPACE::Vec3::z ( ) const
Returns
the z element of this vector

◆ Z_AXIS()

Vec3 MOMENTUM_NAMESPACE::Vec3::Z_AXIS ( )
static
Returns
a vec3 defining a vector along the z-axis