VRay SDK for C++
Loading...
Searching...
No Matches
VRay::Vector Struct Reference

General purpose vector in 3D space using float32. More...

#include <vraysdk.hpp>

Public Member Functions

 Vector (const Vector &) noexcept=default
 
template<typename T >
 Vector (T value) noexcept
 
template<typename T1 , typename T2 , typename T3 >
 Vector (T1 x, T2 y, T3 z) noexcept
 
 Vector (Vector &&) noexcept=default
 
float length (void) const noexcept
 Returns the length of the vector.
 
float lengthSqr (void) const noexcept
 Returns the squared length of the vector.
 
VectormakeZero (void) noexcept
 Sets the components of the vector.
 
Vectoroperator*= (double factor) noexcept
 Multiplies all components by the given number.
 
Vectoroperator*= (float factor) noexcept
 Multiplies all components by the given number.
 
Vectoroperator*= (int factor) noexcept
 Multiplies all components by the given number.
 
Vectoroperator+= (const Vector &other) noexcept
 Adds the components of the given vector.
 
Vector operator- (void) const noexcept
 Reverses the sign of all components.
 
Vectoroperator-= (const Vector &other) noexcept
 Subtracts the components of the given vector.
 
Vectoroperator/= (double divisor) noexcept
 Divides all components by the given number.
 
Vectoroperator/= (float divisor) noexcept
 Divides all components by the given number.
 
Vectoroperator/= (int divisor) noexcept
 Divides all components by the given number.
 
Vectoroperator= (const Vector &) noexcept=default
 
Vectoroperator= (Vector &&) noexcept=default
 
const float & operator[] (const int index) const noexcept
 Returns the i-th component (0 for x, 1 for y, 2 for z) as a const.
 
float & operator[] (const int index) noexcept
 Returns the i-th component (0 for x, 1 for y, 2 for z)
 
void rotate (const Vector &axis) noexcept
 Rotates the vector along the given axis. The length of the axis is the tangent of the angle of rotation.
 
template<typename T1 , typename T2 , typename T3 >
Vectorset (T1 x_, T2 y_, T3 z_) noexcept
 Sets the components of the vector.
 
std::string toString () const
 

Public Attributes

union {
   struct {
      float   x
 
      float   y
 
      float   z
 
   } 
 
   float   f [3]
 
}; 
 

Related Functions

(Note that these are not member functions.)

float length (const Vector &a) noexcept
 
float lengthSqr (const Vector &a) noexcept
 
double mixed (const Vector &a, const Vector &b, const Vector &c) noexcept
 
Vector mul (const Vector &a, const Vector &b) noexcept
 
Vector normalize (const Vector &a) noexcept
 
bool operator!= (const Vector &a, const Vector &b) noexcept
 
double operator* (const Vector &a, const Vector &b) noexcept
 
Vector operator* (const Vector &a, double factor) noexcept
 
Vector operator* (const Vector &a, float factor) noexcept
 
Vector operator* (const Vector &a, int factor) noexcept
 
Vector operator* (double factor, const Vector &a) noexcept
 
Vector operator* (float factor, const Vector &a) noexcept
 
Vector operator* (int factor, const Vector &a)
 
Vector operator+ (const Vector &a, const Vector &b) noexcept
 
Vector operator- (const Vector &a, const Vector &b) noexcept
 
Vector operator/ (const Vector &a, const Vector &b) noexcept
 
Vector operator/ (const Vector &a, double factor) noexcept
 
Vector operator/ (const Vector &a, float factor) noexcept
 
Vector operator/ (const Vector &a, int factor) noexcept
 
bool operator== (const Vector &a, const Vector &b) noexcept
 
Vector operator^ (const Vector &a, const Vector &b) noexcept
 
void rotate (const Vector &axis) noexcept
 
Vector rotate (const Vector &v, const Vector &axis) noexcept
 

Detailed Description

General purpose vector in 3D space using float32.

Friends And Related Function Documentation

◆ length()

float length ( const Vector a)
related

Returns the length of the given vector

◆ lengthSqr()

float lengthSqr ( const Vector a)
related

Returns the squared length of the given vector

◆ mixed()

double mixed ( const Vector a,
const Vector b,
const Vector c 
)
related

Returns the mixed product of the three vectors ((a^b)*c)

◆ mul()

Vector mul ( const Vector a,
const Vector b 
)
related

Mutiplies the components of the given vectors

◆ normalize()

Vector normalize ( const Vector a)
related

Returns a unit vector along the direction of the given one

◆ operator!=()

bool operator!= ( const Vector a,
const Vector b 
)
related

Checks two vectors for inequality

◆ operator*() [1/7]

double operator* ( const Vector a,
const Vector b 
)
related

Dot product of two vectors

◆ operator*() [2/7]

Vector operator* ( const Vector a,
double  factor 
)
related

Multiplies the given vector by the given number.

◆ operator*() [3/7]

Vector operator* ( const Vector a,
float  factor 
)
related

Multiplies the given vector by the given number.

◆ operator*() [4/7]

Vector operator* ( const Vector a,
int  factor 
)
related

Multiplies the given vector by the given number.

◆ operator*() [5/7]

Vector operator* ( double  factor,
const Vector a 
)
related

Multiplies all components of the given vector by the given number.

◆ operator*() [6/7]

Vector operator* ( float  factor,
const Vector a 
)
related

Multiplies all components of the given vector by the given number.

◆ operator*() [7/7]

Vector operator* ( int  factor,
const Vector a 
)
related

Multiplies all components of the given vector by the given number.

◆ operator+()

Vector operator+ ( const Vector a,
const Vector b 
)
related

Adds the components of the given vectors

◆ operator-()

Vector operator- ( const Vector a,
const Vector b 
)
related

Subtracts the components of the given vectors

◆ operator/() [1/4]

Vector operator/ ( const Vector a,
const Vector b 
)
related

Divides the components of the given vectors

◆ operator/() [2/4]

Vector operator/ ( const Vector a,
double  factor 
)
related

Divides all components of the given vector by the given number.

◆ operator/() [3/4]

Vector operator/ ( const Vector a,
float  factor 
)
related

Divides all components of the given vector by the given number.

◆ operator/() [4/4]

Vector operator/ ( const Vector a,
int  factor 
)
related

Divides all components of the given vector by the given number.

◆ operator==()

bool operator== ( const Vector a,
const Vector b 
)
related

Checks two vectors for exact equality NOTE: You may want to perform your own approximate comparison, element by element

◆ operator^()

Vector operator^ ( const Vector a,
const Vector b 
)
related

Returns the cross product of two vectors

◆ rotate() [1/2]

void rotate ( const Vector axis)
related

Rotates the vector along the given axis. The length of the axis is the tangent of the angle of rotation.

◆ rotate() [2/2]

Vector rotate ( const Vector v,
const Vector axis 
)
related

Rotates the vector along the given axis. The length of the axis is the tangent of the angle of rotation.


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