INFO804 Introduction à l'informatique graphique
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
rt Namespace Reference

Namespace RayTracer. More...

Classes

struct  Color
 
struct  GraphicalObject
 
class  Image2D
 Classe générique pour représenter des images 2D. More...
 
class  Image2DWriter
 
class  Image2DWriter< Color >
 Specialization for color images. More...
 
class  Image2DWriter< unsigned char >
 Specialization for gray-level images. More...
 
struct  Light
 Lights are used to give lights in a scene. More...
 
struct  Material
 
struct  PointLight
 
struct  PointVector
 
struct  Ray
 
struct  Renderer
 This structure takes care of rendering a scene. More...
 
struct  Scene
 
struct  Sphere
 A sphere is a concrete GraphicalObject that represents a sphere in 3D space. More...
 
class  Viewer
 

Typedefs

typedef float Real
 the type for representing a real number.
 
typedef PointVector< Real, 2 > Vector2
 
typedef PointVector< Real, 2 > Point2
 
typedef PointVector< Real, 3 > Vector3
 The type for representing a 3d point.
 
typedef PointVector< Real, 3 > Point3
 The type for representing a 3d vector;.
 
typedef PointVector< Real, 4 > Vector4
 
typedef PointVector< Real, 4 > Point4
 

Functions

Color operator* (Real v, const Color &other)
 
Real distance (const Color &c1, const Color &c2)
 
template<typename T , std::size_t N>
std::ostream & operator<< (std::ostream &out, const PointVector< T, N > &PV)
 
template<typename T , std::size_t N>
PointVector< T, N > operator* (T val, const PointVector< T, N > &PV)
 
template<typename T , std::size_t N>
PointVector< T, N > operator* (const PointVector< T, N > &PV, T val)
 
template<typename T , std::size_t N>
PointVector< T, N > operator/ (T val, const PointVector< T, N > &PV)
 
template<typename T , std::size_t N>
PointVector< T, N > operator/ (const PointVector< T, N > &PV, T val)
 
template<typename T , std::size_t N>
distance2 (const PointVector< T, N > &p1, const PointVector< T, N > &p2)
 
template<typename T , std::size_t N>
distance (const PointVector< T, N > &p1, const PointVector< T, N > &p2)
 
void progressBar (std::ostream &output, const double currentValue, const double maximumValue)
 

Detailed Description

Namespace RayTracer.

Typedef Documentation

◆ Point2

typedef PointVector< Real, 2 > rt::Point2

Definition at line 208 of file PointVector.h.

◆ Point3

typedef PointVector< Real, 3 > rt::Point3

The type for representing a 3d vector;.

Definition at line 212 of file PointVector.h.

◆ Point4

typedef PointVector< Real, 4 > rt::Point4

Definition at line 214 of file PointVector.h.

◆ Real

typedef float rt::Real

the type for representing a real number.

Definition at line 206 of file PointVector.h.

◆ Vector2

typedef PointVector< Real, 2 > rt::Vector2

Definition at line 207 of file PointVector.h.

◆ Vector3

typedef PointVector< Real, 3 > rt::Vector3

The type for representing a 3d point.

Definition at line 210 of file PointVector.h.

◆ Vector4

typedef PointVector< Real, 4 > rt::Vector4

Definition at line 213 of file PointVector.h.

Function Documentation

◆ distance() [1/2]

Real rt::distance ( const Color c1,
const Color c2 
)
inline

Definition at line 149 of file Color.h.

150 {
151 return std::max( std::fabs( c1.r() - c2.r() ),
152 std::max( std::fabs( c1.g() - c2.g() ),
153 std::fabs( c1.b() - c2.b() ) ) );
154 }

◆ distance() [2/2]

template<typename T , std::size_t N>
T rt::distance ( const PointVector< T, N > &  p1,
const PointVector< T, N > &  p2 
)
inline

Definition at line 198 of file PointVector.h.

199 {
200 return sqrt( distance2( p1, p2 ) );
201 }

◆ distance2()

template<typename T , std::size_t N>
T rt::distance2 ( const PointVector< T, N > &  p1,
const PointVector< T, N > &  p2 
)
inline

Definition at line 190 of file PointVector.h.

191 {
192 PointVector<T,N> tmp = p2 - p1;
193 return tmp.dot( tmp );
194 }
T dot(const Self &other) const
dot product (produit scalaire).

◆ operator*() [1/3]

template<typename T , std::size_t N>
PointVector< T, N > rt::operator* ( const PointVector< T, N > &  PV,
val 
)

Definition at line 162 of file PointVector.h.

163 {
164 typedef typename PointVector<T,N>::Size Size;
165 PointVector<T,N> result( PV );
166 for ( Size i = 0; i < N; ++i ) result[ i ] *= val;
167 return result;
168 }

◆ operator*() [2/3]

Color rt::operator* ( Real  v,
const Color other 
)
inline

Definition at line 143 of file Color.h.

144 {
145 Color tmp( other );
146 return tmp * v;
147 }

◆ operator*() [3/3]

template<typename T , std::size_t N>
PointVector< T, N > rt::operator* ( val,
const PointVector< T, N > &  PV 
)

Definition at line 153 of file PointVector.h.

154 {
155 typedef typename PointVector<T,N>::Size Size;
156 PointVector<T,N> result( PV );
157 for ( Size i = 0; i < N; ++i ) result[ i ] *= val;
158 return result;
159 }

◆ operator/() [1/2]

template<typename T , std::size_t N>
PointVector< T, N > rt::operator/ ( const PointVector< T, N > &  PV,
val 
)

Definition at line 180 of file PointVector.h.

181 {
182 typedef typename PointVector<T,N>::Size Size;
183 PointVector<T,N> result( PV );
184 for ( Size i = 0; i < N; ++i ) result[ i ] /= val;
185 return result;
186 }

◆ operator/() [2/2]

template<typename T , std::size_t N>
PointVector< T, N > rt::operator/ ( val,
const PointVector< T, N > &  PV 
)

Definition at line 171 of file PointVector.h.

172 {
173 typedef typename PointVector<T,N>::Size Size;
174 PointVector<T,N> result( PV );
175 for ( Size i = 0; i < N; ++i ) result[ i ] = val / result[ i ];
176 return result;
177 }

◆ operator<<()

template<typename T , std::size_t N>
std::ostream & rt::operator<< ( std::ostream &  out,
const PointVector< T, N > &  PV 
)

Definition at line 146 of file PointVector.h.

147 {
148 PV.selfDisplay( out );
149 return out;
150 }

◆ progressBar()

void rt::progressBar ( std::ostream &  output,
const double  currentValue,
const double  maximumValue 
)
inline

Definition at line 16 of file Renderer.h.

18 {
19 static const int PROGRESSBARWIDTH = 60;
20 static int myProgressBarRotation = 0;
21 static int myProgressBarCurrent = 0;
22 // how wide you want the progress meter to be
23 double fraction = currentValue /maximumValue;
24
25 // part of the progressmeter that's already "full"
26 int dotz = static_cast<int>(floor(fraction * PROGRESSBARWIDTH));
27 if (dotz > PROGRESSBARWIDTH) dotz = PROGRESSBARWIDTH;
28
29 // if the fullness hasn't changed skip display
30 if (dotz == myProgressBarCurrent) return;
31 myProgressBarCurrent = dotz;
32 myProgressBarRotation++;
33
34 // create the "meter"
35 int ii=0;
36 output << "[";
37 // part that's full already
38 for ( ; ii < dotz;ii++) output<< "#";
39 // remaining part (spaces)
40 for ( ; ii < PROGRESSBARWIDTH;ii++) output<< " ";
41 static const char* rotation_string = "|\\-/";
42 myProgressBarRotation %= 4;
43 output << "] " << rotation_string[myProgressBarRotation]
44 << " " << (int)(fraction*100)<<"/100\r";
45 output.flush();
46 }