RayTracer 1.0
Ray tracing is a technique used to generate realistic digital images by simulating the inverse path of light. Our goal is to create a program able to generate an image from a file describing the scene.
 
Loading...
Searching...
No Matches
RayTracer::Plane Class Reference

#include <Plane.hpp>

Inheritance diagram for RayTracer::Plane:
RayTracer::IPrimitive

Public Member Functions

 Plane (const Math::Point3D &point, const Math::Vector3D &normal, std::shared_ptr< IMaterial > material)
 
 ~Plane () override=default
 
void translate (const Math::Vector3D &v) override
 
void rotate (const Math::Vector3D &axis, double angleDegrees) override
 
std::shared_ptr< IMaterialgetMaterial () const override
 
bool intersect (const Ray &ray, double &t, Math::Point3D &hitPoint, Math::Vector3D &normal) const override
 
- Public Member Functions inherited from RayTracer::IPrimitive
virtual ~IPrimitive ()=default
 
Color getBaseColor () const
 

Private Attributes

Math::Point3D _point
 
Math::Vector3D _normal
 
std::shared_ptr< IMaterial_material
 

Detailed Description

Definition at line 13 of file Plane.hpp.

Constructor & Destructor Documentation

◆ Plane()

RayTracer::Plane::Plane ( const Math::Point3D & point,
const Math::Vector3D & normal,
std::shared_ptr< IMaterial > material )

Definition at line 10 of file Plane.cpp.

11 : _point(point), _normal(normal), _material(std::move(material))
12{}
Math::Vector3D _normal
Definition Plane.hpp:26
Math::Point3D _point
Definition Plane.hpp:25
std::shared_ptr< IMaterial > _material
Definition Plane.hpp:27

References _material, _normal, and _point.

◆ ~Plane()

RayTracer::Plane::~Plane ( )
overridedefault

Member Function Documentation

◆ getMaterial()

std::shared_ptr< RayTracer::IMaterial > RayTracer::Plane::getMaterial ( ) const
overridevirtual

Implements RayTracer::IPrimitive.

Definition at line 24 of file Plane.cpp.

25{
26 return _material;
27}

References _material.

◆ intersect()

bool RayTracer::Plane::intersect ( const Ray & ray,
double & t,
Math::Point3D & hitPoint,
Math::Vector3D & normal ) const
overridevirtual

Implements RayTracer::IPrimitive.

Definition at line 29 of file Plane.cpp.

29 {
30 double denom = _normal.dot(ray.direction);
31
32 if (std::abs(denom) < 1e-6)
33 return false;
34
35 t = (_point - ray.origin).dot(_normal) / denom;
36
37 if (t < 0)
38 return false;
39
40 hitPoint = ray.origin + ray.direction * t;
41 normal = _normal;
42 return true;
43}

References _normal, _point, RayTracer::Ray::direction, and RayTracer::Ray::origin.

◆ rotate()

void RayTracer::Plane::rotate ( const Math::Vector3D & axis,
double angleDegrees )
overridevirtual

Implements RayTracer::IPrimitive.

Definition at line 19 of file Plane.cpp.

20{
21 _normal = Math::rotateVector(_normal, axis, angleDegrees);
22}
Vector3D rotateVector(const Vector3D &v, const Vector3D &axis, double angleDegrees)
Definition Math3D.cpp:90

References _normal, and Math::rotateVector().

◆ translate()

void RayTracer::Plane::translate ( const Math::Vector3D & v)
overridevirtual

Implements RayTracer::IPrimitive.

Definition at line 14 of file Plane.cpp.

15{
16 _point = _point + v;
17}

References _point.

Member Data Documentation

◆ _material

std::shared_ptr<IMaterial> RayTracer::Plane::_material
private

Definition at line 27 of file Plane.hpp.

◆ _normal

Math::Vector3D RayTracer::Plane::_normal
private

Definition at line 26 of file Plane.hpp.

◆ _point

Math::Point3D RayTracer::Plane::_point
private

Definition at line 25 of file Plane.hpp.


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