Aether3D
Game Engine
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Vec3 Struct Reference

3-component vector. More...

#include <Vec3.hpp>

Public Member Functions

 Vec3 (const Vec3 &other)=default
 Copy constructor.
 
 Vec3 ()
 Constructor.
 
 Vec3 (float ax, float ay, float az)
 
bool IsAlmost (const Vec3 &v) const
 
Vec3 operator/ (float f) const
 
Vec3 operator/ (const Vec3 &v) const
 
Vec3 operator- () const
 
Vec3 operator- (const Vec3 &v) const
 
Vec3 operator+ (const Vec3 &v) const
 
Vec3 operator+ (float f) const
 
bool operator== (const Vec3 &v) const
 
bool operator!= (const Vec3 &v) const
 
Vec3operator-= (const Vec3 &v)
 
Vec3operator+= (const Vec3 &v)
 
Vec3operator*= (float f)
 
Vec3operator/= (float f)
 
Vec3operator*= (const Vec3 &v)
 
Vec3operator= (const Vec3 &v)
 
Vec3 operator* (const Vec3 &v) const
 
Vec3 operator* (float f) const
 
Vec3 Normalized () const
 
float Length () const
 
void Zero ()
 Resets this vector's values to 0.
 

Static Public Member Functions

static Vec3 Cross (const Vec3 &v1, const Vec3 &v2)
 Cross product. More...
 
static float Distance (const Vec3 &v1, const Vec3 &v2)
 
static float DistanceSquared (const Vec3 &v1, const Vec3 &v2)
 
static float Dot (const Vec3 &v1, const Vec3 &v2)
 
static Vec3 Min2 (const Vec3 &v1, const Vec3 &v2)
 
static Vec3 Max2 (const Vec3 &v1, const Vec3 &v2)
 
static Vec3 Reflect (const Vec3 &vec, const Vec3 &normal)
 

Public Attributes

float x
 
float y
 
float z
 

Detailed Description

3-component vector.

Aether3D's coordinate system is right-handed: up: 0, 1, 0 forward: 0, 0, -1 right: 1, 0, 0

Constructor & Destructor Documentation

◆ Vec3()

Vec3::Vec3 ( float  ax,
float  ay,
float  az 
)
inline

Constructor.

Parameters
axX-coordinate.
ayY-coordinate.
azZ-coordinate.

Member Function Documentation

◆ Cross()

static Vec3 Vec3::Cross ( const Vec3 v1,
const Vec3 v2 
)
inlinestatic

Cross product.

Parameters
v1Vector.
v2Another vector.
Returns
Cross product of this vector and v.

◆ Distance()

static float Vec3::Distance ( const Vec3 v1,
const Vec3 v2 
)
inlinestatic

Solves distance between two vectors.

Parameters
v1Vector.
v2Other vector.
Returns
Distance.
See also
DistanceSquared()

◆ DistanceSquared()

static float Vec3::DistanceSquared ( const Vec3 v1,
const Vec3 v2 
)
inlinestatic

Solves squared distance between two vectors.

Parameters
v1Vector.
v2Other vector.
Returns
Squared distance.
See also
Distance()

◆ Dot()

static float Vec3::Dot ( const Vec3 v1,
const Vec3 v2 
)
inlinestatic

Dot product.

Parameters
v1Vector.
v2Other vector.
Returns
Dot product of vectors v1 and v2.

◆ IsAlmost()

bool Vec3::IsAlmost ( const Vec3 v) const
inline

Almost equality.

Parameters
vanother vector.
Returns
true, if vectors are equal.

◆ Length()

float Vec3::Length ( ) const
inline
Returns
length.

◆ Max2()

static Vec3 Vec3::Max2 ( const Vec3 v1,
const Vec3 v2 
)
inlinestatic

Gets maximum components and creates a new vector from them. Example: v1( 1, 0, 2 ), v2( 2, 1, 1 ) -> result( 2, 1, 2 ).

Parameters
v1Vector.
v2Other vector.
Returns
Vector that has v1's and v2's maximum components.

◆ Min2()

static Vec3 Vec3::Min2 ( const Vec3 v1,
const Vec3 v2 
)
inlinestatic

Gets minimum components and creates a new vector from them. Example:

v1( 1, 0, 2 ), v2( 2, 1, 1 ) -> result( 1, 0, 1 )

.

Parameters
v1Vector.
v2Other vector.
Returns
Vector that has v1's and v2's minimum components.
See also
Max2()

◆ Normalized()

Vec3 Vec3::Normalized ( ) const
inline

Returns a normalized vector

◆ operator!=()

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

Inequality operator

Parameters
vVector that is tested for equality.
Returns
True, if component-wise values are not equal, false otherwise.

◆ operator*() [1/2]

Vec3 Vec3::operator* ( const Vec3 v) const
inline

Multiplication operator.

Parameters
vA vector that is multiplied with this vector
Returns
A vector that is the product of this vector and v.

◆ operator*() [2/2]

Vec3 Vec3::operator* ( float  f) const
inline

Multiplication operator.

Parameters
fA value that is multiplied with this vector.
Returns
This vector multiplied by f.

◆ operator*=() [1/2]

Vec3& Vec3::operator*= ( const Vec3 v)
inline

Operator multiply and assign.

Parameters
vA value that is to be multiplied with this vector.
Returns
Reference to this vector.

◆ operator*=() [2/2]

Vec3& Vec3::operator*= ( float  f)
inline

Operator multiply and assign.

Parameters
fA value that is to be multiplied with this vector.
Returns
Reference to this vector.

◆ operator+() [1/2]

Vec3 Vec3::operator+ ( const Vec3 v) const
inline

Addition operator.

Parameters
va vector that is to be added to this vector.
Returns
A vector that is the sum of this vector and v.

◆ operator+() [2/2]

Vec3 Vec3::operator+ ( float  f) const
inline

Addition operator.

Parameters
fa value that is to be added to this vector.
Returns
A vector that is the sum of this vector and c.

◆ operator+=()

Vec3& Vec3::operator+= ( const Vec3 v)
inline

Operator add and assign.

Parameters
vVector that is to be added to this vector.
Returns
Reference to this vector.

◆ operator-() [1/2]

Vec3 Vec3::operator- ( ) const
inline

Negation operator.

Returns
a vector that has negative values.

◆ operator-() [2/2]

Vec3 Vec3::operator- ( const Vec3 v) const
inline

Subtraction operator.

Parameters
va vector that is to be subtracted from this vector.
Returns
result of the subtraction.

◆ operator-=()

Vec3& Vec3::operator-= ( const Vec3 v)
inline

Operator subtract and assign.

Parameters
vVector that is to be subtracted from this vector.
Returns
Reference to this vector.

◆ operator/() [1/2]

Vec3 Vec3::operator/ ( const Vec3 v) const
inline

Divides by a vector operator.

Parameters
vVector value.
Returns
a vector that has its values divided by v.

◆ operator/() [2/2]

Vec3 Vec3::operator/ ( float  f) const
inline

Divides by a scalar operator.

Parameters
fScalar value.
Returns
a vector that has its values divided by f.

◆ operator/=()

Vec3& Vec3::operator/= ( float  f)
inline

Operator divide and assign.

Parameters
fA value that is to be divided with this vector.
Returns
Reference to this vector.

◆ operator=()

Vec3& Vec3::operator= ( const Vec3 v)
inline

Assignment operator.

Parameters
va vector that is assigned to this vector.
Returns
Reference to this vector.

◆ operator==()

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

Equality operator

Parameters
vVector that is tested for equality.
Returns
True, if component-wise values are equal, false otherwise.

◆ Reflect()

static Vec3 Vec3::Reflect ( const Vec3 vec,
const Vec3 normal 
)
inlinestatic

Reflects a vector with normal.

Parameters
vecVector.
normalNormal.
Returns
Reflected vector.

The documentation for this struct was generated from the following file: