Ray Tracer  2020
Public Member Functions | List of all members
Direction Class Reference

Class for Direction Vectors. More...

#include <Direction.h>

Inheritance diagram for Direction:
Vector Matrix

Public Member Functions

 Direction ()
 Direction default constructor. More...
 
 Direction (double x, double y, double z)
 Direction X-Y-Z constructor. More...
 
 Direction (const Direction &direction)
 Direction copy constructor. More...
 
 Direction (const Vector &vector)
 Direction from Vector constructor. More...
 
 Direction (const Matrix &matrix)
 Direction from Matrix constructor. More...
 
- Public Member Functions inherited from Vector
 Vector (size_t size=1)
 Vector constructor. More...
 
 Vector (const Vector &vec)
 Vector copy constructor. More...
 
 Vector (const Matrix &mat)
 Vector from Matrix constructor. More...
 
virtual ~Vector ()
 Vector destructor. More...
 
Vectoroperator= (const Vector &vec)
 Vector assignment operator. More...
 
double & operator() (size_t ix)
 Vector element access. More...
 
const double & operator() (size_t ix) const
 Vector element access (const version). More...
 
Vector operator- () const
 Unary minus. More...
 
Vectoroperator+= (const Vector &vec)
 Vector addition-assignment operator. More...
 
Vectoroperator-= (const Vector &vec)
 Vector subtraction-assignment operator. More...
 
Vectoroperator*= (double s)
 Vector-scalar multiplication-assignment operator. More...
 
Vectoroperator/= (double s)
 Vector-scalar multiplication-assignment operator. More...
 
double dot (const Vector &vec) const
 Vector dot product. More...
 
Vector cross (const Vector &vec) const
 Vector cross product. More...
 
double norm () const
 Vector norm. More...
 
double squaredNorm () const
 SquaredVector norm. More...
 
- Public Member Functions inherited from Matrix
 Matrix (size_t size=1)
 Square Matrix constructor. More...
 
 Matrix (size_t rows, size_t cols)
 General Matrix constructor. More...
 
 Matrix (const Matrix &mat)
 Matrix copy constructor. More...
 
virtual ~Matrix ()
 Matrix destructor. More...
 
Matrixoperator= (const Matrix &mat)
 Matrix assignment operator. More...
 
double & operator() (size_t row, size_t col)
 Matrix element access. More...
 
const double & operator() (size_t row, size_t col) const
 Matrix element access (const version). More...
 
size_t numRows () const
 Number of rows in a Matrix. More...
 
size_t numCols () const
 Number of columns in a Matrix. More...
 
size_t numElements () const
 Number of elements in a Matrix. More...
 
Matrix operator- () const
 Unary minus. More...
 
Matrixoperator+= (const Matrix &mat)
 Matrix addition-assignment operator. More...
 
Matrixoperator-= (const Matrix &mat)
 Matrix subtraction-assignment operator. More...
 
Matrixoperator*= (double s)
 Matrix-scalar multiplication-assignment operator. More...
 
Matrixoperator/= (double s)
 Matrix-scalar multiplication-assignment operator. More...
 
Matrix transpose () const
 Matrix transpose. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Matrix
static Matrix identity (size_t rows, size_t cols)
 Factory method for Identity Matrices. More...
 
static Matrix zero (size_t rows, size_t cols)
 Factory method for Zero Matrices. More...
 
- Protected Attributes inherited from Matrix
size_t rows_
 Number of rows in the Matrix. More...
 
size_t cols_
 Number of columns in the Matrix. More...
 
std::vector< double > data_
 Storage for Matrix data elements. More...
 

Detailed Description

Class for Direction Vectors.

A Direction can be seen as either a 3-Vector or a homogeneous 4-Vector. In this implementation a Direction is a 3-Vector, and the Transform class deals with the homogeneous form. Direction is essentially a thin wrapper around Vector, which ensures that the Vector has 3 elements.

Having separate types for Point, Direction, and Normal, means that it is possible to distinguish them when passing them to Transform.apply() etc.

Constructor & Destructor Documentation

◆ Direction() [1/5]

Direction::Direction ( )

Direction default constructor.

◆ Direction() [2/5]

Direction::Direction ( double  x,
double  y,
double  z 
)

Direction X-Y-Z constructor.

This creates a Direction Vector with the specified X-, Y-, and Z-components.

Parameters
xThe X-component of the Direction Vector.
yThe Y-component of the Direction Vector.
zThe Z-component of the Direction Vector.

◆ Direction() [3/5]

Direction::Direction ( const Direction direction)

Direction copy constructor.

Parameters
directionThe Direction to copy to this.

◆ Direction() [4/5]

Direction::Direction ( const Vector vector)

Direction from Vector constructor.

Arithmetic operations on Direction objects use the Vector implementations. This means that the result is a Vector, and this allows them to be converted to Direction objects.

Parameters
vectorThe Vector to copy to this.

◆ Direction() [5/5]

Direction::Direction ( const Matrix matrix)

Direction from Matrix constructor.

Some operations on Direction objects use the Matrix implementations. This means that the result is a Matrix, and this allows them to be converted to Direction objects.

Parameters
matrixThe Matrix to copy to this.

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