INFO804 Introduction à l'informatique graphique
Loading...
Searching...
No Matches
Ray.h
Go to the documentation of this file.
1/**
2@file Ray.h
3@author JOL
4*/
5#pragma once
6#ifndef _RAY_H_
7#define _RAY_H_
8
9#include "PointVector.h"
10
11// @see http://devernay.free.fr/cours/opengl/materials.html
12
13/// Namespace RayTracer
14namespace rt {
15
16 /// This structure stores a ray having an origin and a direction. It
17 /// also stores its depth.
18 struct Ray {
19 /// origin of the ray.
21 /// unit direction of the ray.
23 /// depth of the ray, i.e. the number of times it can bounce on an object.
24 int depth;
25
26 /// Default constructor
27 Ray() {}
28
29 /// Constructor from origin and vector. The vector may not be unitary.
30 Ray( const Point3& o, const Vector3& dir, int d = 1 )
31 : origin( o ), direction( dir ), depth( d )
32 {
33 Real l = direction.norm();
34 if ( l != 1.0f ) direction /= l;
35 }
36 };
37
38
39
40} // namespace rt
41
42#endif // #define _RAY_H_
Namespace RayTracer.
Definition Color.h:11
float Real
the type for representing a real number.
Definition Ray.h:18
Ray(const Point3 &o, const Vector3 &dir, int d=1)
Constructor from origin and vector. The vector may not be unitary.
Definition Ray.h:30
Point3 origin
origin of the ray.
Definition Ray.h:20
int depth
depth of the ray, i.e. the number of times it can bounce on an object.
Definition Ray.h:24
Vector3 direction
unit direction of the ray.
Definition Ray.h:22
Ray()
Default constructor.
Definition Ray.h:27