Voltray Engine Docs
Loading...
Searching...
No Matches
Vec3 Struct Reference

#include <Vec3.h>

Public Member Functions

 Vec3 ()
 Default constructor. Initializes all components to zero.
 
 Vec3 (float value)
 
 Vec3 (float x, float y, float z)
 
Vec3 operator+ (const Vec3 &other) const
 
Vec3 operator- (const Vec3 &other) const
 
Vec3 operator* (float scalar) const
 
Vec3 operator/ (float scalar) const
 
Vec3 operator- () const
 
float Length () const
 
Vec3 Normalize () const
 
float Dot (const Vec3 &other) const
 
Vec3 Cross (const Vec3 &other) const
 
Vec3operator+= (const Vec3 &other)
 Compound addition assignment.
 
Vec3operator-= (const Vec3 &other)
 Compound subtraction assignment.
 
Vec3operator*= (float scalar)
 Compound multiplication assignment.
 

Public Attributes

float x
 
float y
 
float z
 The x, y, and z components of the vector.
 

Constructor & Destructor Documentation

◆ Vec3() [1/3]

Vec3::Vec3 ( )

Default constructor. Initializes all components to zero.

◆ Vec3() [2/3]

Vec3::Vec3 ( float  value)
explicit

Constructs a vector with the same value for all components.

Parameters
valueThe value to set for all components.

◆ Vec3() [3/3]

Vec3::Vec3 ( float  x,
float  y,
float  z 
)

Constructs a vector with the given x, y, and z components.

Parameters
xThe x component.
yThe y component.
zThe z component.

Member Function Documentation

◆ Cross()

Vec3 Vec3::Cross ( const Vec3 other) const

Computes the cross product of this vector and another vector.

Parameters
otherThe other vector.
Returns
The cross product vector.

◆ Dot()

float Vec3::Dot ( const Vec3 other) const

Computes the dot product of this vector and another vector.

Parameters
otherThe other vector.
Returns
The dot product.

◆ Length()

float Vec3::Length ( ) const

Calculates the length (magnitude) of the vector.

Returns
The length of the vector.

◆ Normalize()

Vec3 Vec3::Normalize ( ) const

Returns a normalized (unit length) version of this vector.

Returns
The normalized vector.

◆ operator*()

Vec3 Vec3::operator* ( float  scalar) const

Multiplies this vector by a scalar.

Parameters
scalarThe scalar value to multiply by.
Returns
The result of scalar multiplication.

◆ operator*=()

Vec3 & Vec3::operator*= ( float  scalar)

Compound multiplication assignment.

◆ operator+()

Vec3 Vec3::operator+ ( const Vec3 other) const

Adds this vector to another vector.

Parameters
otherThe vector to add.
Returns
The result of vector addition.

◆ operator+=()

Vec3 & Vec3::operator+= ( const Vec3 other)

Compound addition assignment.

◆ operator-() [1/2]

Vec3 Vec3::operator- ( ) const

Negates the vector (flips the sign of all components).

Returns
The negated vector.

◆ operator-() [2/2]

Vec3 Vec3::operator- ( const Vec3 other) const

Subtracts another vector from this vector.

Parameters
otherThe vector to subtract.
Returns
The result of vector subtraction.

◆ operator-=()

Vec3 & Vec3::operator-= ( const Vec3 other)

Compound subtraction assignment.

◆ operator/()

Vec3 Vec3::operator/ ( float  scalar) const

Divides this vector by a scalar.

Parameters
scalarThe scalar value to divide by.
Returns
The result of scalar division.

Member Data Documentation

◆ x

float Vec3::x

◆ y

float Vec3::y

◆ z

float Vec3::z

The x, y, and z components of the vector.


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