Ray Tracer  2020
Public Member Functions | List of all members
Cube Class Reference

Class for Cube objects. More...

#include <Cube.h>

Inheritance diagram for Cube:
Object

Public Member Functions

 Cube ()
 Cube default constructor. More...
 
 Cube (const Cube &cube)
 Cube copy constructor.
More...
 
 ~Cube ()
 Cube destructor. More...
 
Cubeoperator= (const Cube &cube)
 Cube assignment operator. More...
 
std::vector< RayIntersectionintersect (const Ray &ray) const
 Cube-Ray intersection computation. More...
 

Additional Inherited Members

- Public Attributes inherited from Object
Transform transform
 A 3D transformation to apply to this Object. More...
 
Material material
 The colour and reflectance properties of the Object. More...
 
- Protected Member Functions inherited from Object
 Object ()
 Object default constructor. More...
 
 Object (const Object &object)
 Object copy constructor. More...
 
virtual ~Object ()
 Object destructor. More...
 
Objectoperator= (const Object &object)
 Object assignment operator. More...
 

Detailed Description

Class for Cube objects.

This class provides an Object which is a Cube at the origin with "radius" 1. That is, a Cube that extends from \(-1\) to \(+1\) along each axis, as illustrated below:

Note that the Cube provided in the skeleton code is not complete and returns no RayIntersections from intersect(). This method needs to be implemented correctly as part of the labs/assignment.

Constructor & Destructor Documentation

◆ Cube() [1/2]

Cube::Cube ( )

Cube default constructor.

A newly constructed Cube extending from \(-1\) to \(+1\) along each axis. It may be moved, rotated, and scaled through its transform member.

◆ Cube() [2/2]

Cube::Cube ( const Cube cube)

Cube copy constructor.

Parameters
cubeThe Cube to copy.

◆ ~Cube()

Cube::~Cube ( )

Cube destructor.

Member Function Documentation

◆ intersect()

std::vector< RayIntersection > Cube::intersect ( const Ray ray) const
virtual

Cube-Ray intersection computation.

Todo:
The Cube-Ray intersection needs to be implemented as part of the assignment.

Intersection with a Cube can be seen as six instances of intersection with a Plane. However, these planes are oriented to align to different pairs of axes, and do not pass through the origin.

Parameters
rayThe Ray to intersect with this Cube.
Returns
A list (std::vector) of intersections, which may be empty.

Implements Object.

◆ operator=()

Cube & Cube::operator= ( const Cube cube)

Cube assignment operator.

Parameters
cubeThe Cube to assign to this.
Returns
A reference to this to allow for chaining of assignment.

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