Ray Tracer Common Project
Image rendering program based on the ray tracing technique.
Public Member Functions | Public Attributes | List of all members
rt::vector Struct Reference

3D vector More...

#include <vector.hpp>

Public Member Functions

 vector ()
 Null vector constructor.
 
 vector (double a, double b, double c)
 Construct a new vector from its coordinates.
 
const double & operator[] (int i) const
 
double & operator[] (int i)
 
bool operator== (const vector &other) const
 
vector operator+ (const vector &other) const
 
vector operator- (const vector &other) const
 
vector operator- () const
 
vector operator^ (const vector &other) const
 
double operator| (const vector &other) const
 
double norm () const
 
vector unit () const
 
double distance (const vector &) const
 

Public Attributes

double x
 
double y
 
double z
 

Detailed Description

3D vector

This structure describes a 3D vector, providing basic operations (addition, scalar product, etc.) by overloading common operators.

Member Function Documentation

◆ distance()

double rt::vector::distance ( const vector v) const
Returns
the distance between this vector and an other

◆ norm()

double rt::vector::norm ( ) const

Returns the norm of the vector

◆ operator+()

vector rt::vector::operator+ ( const vector other) const

Addition: \((a,b,c) + (d,e,f) = (a+d,b+e,c+f)\)

◆ operator-() [1/2]

vector rt::vector::operator- ( const vector other) const

Substraction \((a,b,c) - (d,e,f) = (a-d,b-e,c-f)\)

◆ operator-() [2/2]

vector rt::vector::operator- ( ) const

Uniary minus operator : \(-(a, b, c) = (-a, -b, -c)\)

◆ operator==()

bool rt::vector::operator== ( const vector other) const

Comparison

◆ operator[]() [1/2]

const double & rt::vector::operator[] ( int  i) const

Const array-like components access

◆ operator[]() [2/2]

double & rt::vector::operator[] ( int  i)

Array-like components access

◆ operator^()

vector rt::vector::operator^ ( const vector other) const

Vectorial product \((a,b,c) \times (d,e,f) = (bf-ce,cd-af,ae-bd)\)

◆ operator|()

double rt::vector::operator| ( const vector other) const

Scalar product \(((a,b,c) \dot (d,e,f)) = ad + be + cf\)

◆ unit()

vector rt::vector::unit ( ) const

return a vector of the same direction but of norm 1


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