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

Light photon class. More...

#include <photon.hpp>

Public Member Functions

 photon ()
 Create a new null photon (with no energy).
 
 photon (const photon &)
 Copy constructor.
 
 photon (const rt::color &clr, double e=1.0)
 Create a photon from a color. More...
 
 photon (double r, double g, double b, double e=1.0)
 Create a photon from color components. More...
 
const rt::colorcolor () const
 Photon color.
 
double energy () const
 Photon energy. More...
 
void operator+= (const photon &)
 Additive synthesys with another photon.
 
photon operator+ (const photon &) const
 Additive synthesys with another photon. More...
 
void operator*= (const rt::color &)
 Make a color absorb a photon.
 
photon operator* (const rt::color &) const
 Make a color absorb a photon. More...
 
void operator*= (double f)
 Multiply the photon energy. More...
 
photon operator* (double f) const
 Multiply the photon energy. More...
 
 operator bool () const
 Boolean convertion. More...
 

Detailed Description

Light photon class.

A photon represent a light particle with a color and an energy. This class provides some basic operation for photon manipulations sush as additive synthese (operator+) with another photon and absorbtion (operator*) with a color.

Constructor & Destructor Documentation

◆ photon() [1/2]

rt::photon::photon ( const rt::color clr,
double  e = 1.0 
)

Create a photon from a color.

Parameters
clrA RGB color

◆ photon() [2/2]

rt::photon::photon ( double  r,
double  g,
double  b,
double  e = 1.0 
)

Create a photon from color components.

Parameters
rRed component.
gGreen component.
bBlue component.

Member Function Documentation

◆ energy()

double rt::photon::energy ( ) const

Photon energy.

Returns
The photon energy computed from its color as:

\[ p_{energy} = max(p_{red}, p_{green}, p_{blue}) \]

◆ operator bool()

rt::photon::operator bool ( ) const

Boolean convertion.

Returns
true if photon energy is not null.

◆ operator*() [1/2]

photon rt::photon::operator* ( const rt::color c) const

Make a color absorb a photon.

Returns
A new photon.

◆ operator*() [2/2]

photon rt::photon::operator* ( double  f) const

Multiply the photon energy.

Parameters
fenergy factor
Returns
A new photon.

◆ operator*=()

void rt::photon::operator*= ( double  f)

Multiply the photon energy.

Parameters
fenergy factor.

◆ operator+()

photon rt::photon::operator+ ( const photon p) const

Additive synthesys with another photon.

Returns
A new photon.

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