Phongo Clap RT  1.0
Simple Raytracing Renderer
Ray.cpp
Go to the documentation of this file.
1 
4 #include <ngl/Vec3.h>
5 #include "Ray.h"
6 
7 namespace geo
8 {
9 Ray::Ray(ngl::Vec3 _origin, ngl::Vec3 _direction)
10 {
11  m_origin = _origin;
12 
13  // check that it is unit length, if not, normalize
14  if (_direction.length() > 1.1 || _direction.length() < 0.9) {_direction.normalize();}
15  m_direction = _direction;
16 }
17 
18 Ray::Ray(ngl::Vec3 _A, ngl::Vec3 _B, bool _p)
19 {
20  m_origin = _A;
21 
22  ngl::Vec3 direction = _B - _A;
23  direction.normalize();
24 
25  m_direction = direction;
26 }
27 
28 Ray::~Ray() {;}
29 
30 void Ray::setOrigin(ngl::Vec3 _origin) {m_origin = _origin;}
31 
32 void Ray::setDirection(ngl::Vec3 _direction)
33 {
34  // check that it is unit length, if not, normalize
35  if (_direction.length() > 1.1 || _direction.length() < 0.9) {_direction.normalize();}
36  m_direction = _direction;
37 }
38 
39 ngl::Vec3 Ray::getOrigin()
40 {
41  return m_origin;
42 }
43 
44 ngl::Vec3 Ray::getDirection()
45 {
46  return m_direction;
47 }
48 }
void setDirection(ngl::Vec3 _direction)
Setter method for the direction.
Definition: Ray.cpp:32
ngl::Vec3 getOrigin()
Getter method for the origin.
Definition: Ray.cpp:39
ngl::Vec3 m_origin
Ray's origin class member.
Definition: Ray.h:67
~Ray()
Simple destructor. Frees memory.
Definition: Ray.cpp:28
void setOrigin(ngl::Vec3 _origin)
Setter method for the origin.
Definition: Ray.cpp:30
ngl::Vec3 m_direction
Ray's direction class member.
Definition: Ray.h:71
Ray(ngl::Vec3 _origin, ngl::Vec3 _direction)
First ray ctor, this takes an origin and a direction and passes them directly to the class members...
Definition: Ray.cpp:9
This class handles the implementation of ray: an object with an origin and a direction.
Definition: Plane.cpp:9
ngl::Vec3 getDirection()
Getter method for the direction.
Definition: Ray.cpp:44