Path Tracer
Functions
DoubleVec3D.cpp File Reference
#include "DoubleVec3D.h"
Include dependency graph for DoubleVec3D.cpp:

Functions

DoubleVec3D operator+ (const DoubleVec3D &vec1, const DoubleVec3D &vec2)
 Sum operator. More...
 
DoubleVec3D operator- (const DoubleVec3D &vec)
 Unary minus operator. More...
 
DoubleVec3D operator- (const DoubleVec3D &vec1, const DoubleVec3D &vec2)
 Difference operator. More...
 
DoubleVec3D operator* (const DoubleVec3D &vec, const double &val)
 Multiplication by a scalar operator (commutative). More...
 
DoubleVec3D operator* (const double &val, const DoubleVec3D &vec)
 Multiplication by a scalar operator (commutative). More...
 
DoubleVec3D operator/ (const DoubleVec3D &vec, const double &val)
 Division by a scalar operator. More...
 
std::ostream & operator<< (std::ostream &stream, const DoubleVec3D &vec)
 Ostream operator. More...
 
DoubleVec3D crossProd (const DoubleVec3D &vec1, const DoubleVec3D &vec2)
 Cross product. More...
 
double dotProd (const DoubleVec3D &vec1, const DoubleVec3D &vec2)
 Dot product. More...
 
double length (const DoubleVec3D &vec)
 Gives the norm of the vector. More...
 
void to_json (json &j, const DoubleVec3D &vec)
 Conversion to json. More...
 
void from_json (const json &j, DoubleVec3D &vec)
 Conversion from json. More...
 

Function Documentation

◆ crossProd()

DoubleVec3D crossProd ( const DoubleVec3D vec1,
const DoubleVec3D vec2 
)

Cross product.

A cross prodct gives a third vector, orthogonal to the two previous. Its length is given by the area of the parallelogram drawn by vec1 and vec2.

Parameters
vec1The first vector for the product.
vec2The second vector for the product.
Returns
The cross product between vec1 and vec2.

◆ dotProd()

double dotProd ( const DoubleVec3D vec1,
const DoubleVec3D vec2 
)

Dot product.

A dot product gives the product of the norm of each vector, multiplied by the cosine of the angle between the two vectors.

Parameters
vec1The first vector for the product.
vec2The second vector for the product.
Returns
The dot product between vec1 and vec2.
See also
length()

◆ from_json()

void from_json ( const json j,
DoubleVec3D vec 
)

Conversion from json.

Used for the .get<DoubleVec3D>() function.

Parameters
jJson input.
vecThe output vector.

◆ length()

double length ( const DoubleVec3D vec)

Gives the norm of the vector.

Uses the dotProd() method.

Parameters
vecThe vector from which the norm will be computed.
Returns
The norm of this vector.
See also
dotProd()

◆ operator*() [1/2]

DoubleVec3D operator* ( const double &  val,
const DoubleVec3D vec 
)

Multiplication by a scalar operator (commutative).

Uses the DoubleVec3D::operator*=() method.

Parameters
vecThe vector that will get multiplied.
valThe scalar that will multiply the vector.
Returns
The vector multiplied by the scalar.
See also
DoubleVec3D::operator*=(), operator*(const DoubleVec3D& vec, const double& val)

◆ operator*() [2/2]

DoubleVec3D operator* ( const DoubleVec3D vec,
const double &  val 
)

Multiplication by a scalar operator (commutative).

Uses the DoubleVec3D::operator*=() method.

Parameters
vecThe vector that will get multiplied.
valThe scalar that will multiply the vector.
Returns
The vector multiplied by the scalar.
See also
DoubleVec3D::operator*=(), operator*(const double& val, const DoubleVec3D& vec)

◆ operator+()

DoubleVec3D operator+ ( const DoubleVec3D vec1,
const DoubleVec3D vec2 
)

Sum operator.

Uses the DoubleVec3D::operator+=() method.

Parameters
vec1The first vector for the sum.
vec2The second vector for the sum.
Returns
The sum of the two vectors.
See also
DoubleVec3D::operator+=()

◆ operator-() [1/2]

DoubleVec3D operator- ( const DoubleVec3D vec)

Unary minus operator.

Uses the DoubleVec3D::operator*=() method.

Parameters
vecThe vector that will be inversed.
Returns
The inverse of vec.
See also
DoubleVec3D::operator*=(), DoubleVec3D::operator-=(), operator-(const DoubleVec3D& vec1, const DoubleVec3D& vec2)

◆ operator-() [2/2]

DoubleVec3D operator- ( const DoubleVec3D vec1,
const DoubleVec3D vec2 
)

Difference operator.

Uses the DoubleVec3D::operator-=() method.

Parameters
vec1The first vector for the difference.
vec2The second vector for the difference.
Returns
The difference between vec1 and vec2.
See also
DoubleVec3D::operator-=(), operator-(const DoubleVec3D& vec)

◆ operator/()

DoubleVec3D operator/ ( const DoubleVec3D vec,
const double &  val 
)

Division by a scalar operator.

Uses the DoubleVec3D::operator/=() method.

Parameters
vecThe vector that will get divided.
valThe scalar that will divide the vector.
Returns
The vector divided by the scalar.
See also
DoubleVec3D::operator/=()

◆ operator<<()

std::ostream & operator<< ( std::ostream &  stream,
const DoubleVec3D vec 
)

Ostream operator.

Displays vectors under the form "(x, y, z)"

Parameters
streamThe ostream before.
vecThe vector that will be added to the stream.
Returns
The stream with the vector added.

◆ to_json()

void to_json ( json j,
const DoubleVec3D vec 
)

Conversion to json.

Parameters
jJson output.
vecThe vector that will be converted.