Phongo Clap RT  1.0
Simple Raytracing Renderer
Public Member Functions | Private Attributes | List of all members
geo::Ray Class Reference

#include <Ray.h>

Collaboration diagram for geo::Ray:
Collaboration graph

Public Member Functions

 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. More...
 
 Ray (ngl::Vec3 _A, ngl::Vec3 _B, bool _p)
 Second ray ctor, this takes two points and creates the direction from them and takes the first as origin. More...
 
 ~Ray ()
 Simple destructor. Frees memory. More...
 
void setOrigin (ngl::Vec3 _origin)
 Setter method for the origin. More...
 
void setDirection (ngl::Vec3 _direction)
 Setter method for the direction. More...
 
ngl::Vec3 getOrigin ()
 Getter method for the origin. More...
 
ngl::Vec3 getDirection ()
 Getter method for the direction. More...
 

Private Attributes

ngl::Vec3 m_origin
 Ray's origin class member. More...
 
ngl::Vec3 m_direction
 Ray's direction class member. More...
 

Detailed Description

Definition at line 17 of file Ray.h.

Constructor & Destructor Documentation

Ray::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.

Parameters
[in]_originStarting point of the ray
[in]_directionVector in which the points lay on the line.

Definition at line 9 of file Ray.cpp.

References m_direction, and m_origin.

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 }
ngl::Vec3 m_origin
Ray's origin class member.
Definition: Ray.h:67
ngl::Vec3 m_direction
Ray's direction class member.
Definition: Ray.h:71
Ray::Ray ( ngl::Vec3  _A,
ngl::Vec3  _B,
bool  _p 
)

Second ray ctor, this takes two points and creates the direction from them and takes the first as origin.

Parameters
[in]_AStarting point of the ray
[in]_BAnother point which will be used to construct a vector which will act as direction for the ray.
[in]_pThis parameter discrimines between the previous ctor because they both accept two vectors as inputs and this cannot be overloaded.

Definition at line 18 of file Ray.cpp.

References m_direction, and m_origin.

19 {
20  m_origin = _A;
21 
22  ngl::Vec3 direction = _B - _A;
23  direction.normalize();
24 
25  m_direction = direction;
26 }
ngl::Vec3 m_origin
Ray's origin class member.
Definition: Ray.h:67
ngl::Vec3 m_direction
Ray's direction class member.
Definition: Ray.h:71
Ray::~Ray ( )

Simple destructor. Frees memory.

Definition at line 28 of file Ray.cpp.

28 {;}

Member Function Documentation

ngl::Vec3 Ray::getDirection ( )

Getter method for the direction.

Returns
The direction of the ray.

Definition at line 44 of file Ray.cpp.

References m_direction.

45 {
46  return m_direction;
47 }
ngl::Vec3 m_direction
Ray's direction class member.
Definition: Ray.h:71

Here is the caller graph for this function:

ngl::Vec3 Ray::getOrigin ( )

Getter method for the origin.

Returns
The origin of the ray.

Definition at line 39 of file Ray.cpp.

References m_origin.

40 {
41  return m_origin;
42 }
ngl::Vec3 m_origin
Ray's origin class member.
Definition: Ray.h:67

Here is the caller graph for this function:

void Ray::setDirection ( ngl::Vec3  _direction)

Setter method for the direction.

Parameters
[in]_directionSets the direction class member.

Definition at line 32 of file Ray.cpp.

References m_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 }
ngl::Vec3 m_direction
Ray's direction class member.
Definition: Ray.h:71
void Ray::setOrigin ( ngl::Vec3  _origin)

Setter method for the origin.

Parameters
[in]_originSets the origin class member.

Definition at line 30 of file Ray.cpp.

References m_origin.

30 {m_origin = _origin;}
ngl::Vec3 m_origin
Ray's origin class member.
Definition: Ray.h:67

Member Data Documentation

ngl::Vec3 geo::Ray::m_direction
private

Ray's direction class member.

Definition at line 71 of file Ray.h.

ngl::Vec3 geo::Ray::m_origin
private

Ray's origin class member.

Definition at line 67 of file Ray.h.


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