Ray Tracer  2020
Public Member Functions | Private Attributes | List of all members
Tube Class Reference

Class for Tube objects. More...

#include <Tube.h>

Inheritance diagram for Tube:
Object

Public Member Functions

 Tube (double ratio=0.5)
 Tube default constructor. More...
 
 Tube (const Tube &tube)
 Tube copy constructor. More...
 
 ~Tube ()
 Tube destructor. More...
 
Tubeoperator= (const Tube &tube)
 Tube assignment operator. More...
 
std::vector< RayIntersectionintersect (const Ray &ray) const
 Tube-Ray intersection computation. More...
 

Private Attributes

double ratio_
 

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 Tube objects.

This class provides an Object which is a Tune centred at the origin with outer radius 1 and a user-specified inner radius in the range \((0,1)\), as shown below.

Note that the Tube 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 assignment.

Constructor & Destructor Documentation

◆ Tube() [1/2]

Tube::Tube ( double  ratio = 0.5)

Tube default constructor.

A newly constructed Octahedron is centred at the origin, and is aligned with the Z-axis It has outer radius 1, and an inner radius specified by the ratio parameter. It extends out to \(Z= \pm 1\) It may be moved, rotated, and scaled through its transform member.

Parameters
ratioThe ratio of the inner and outer radii of the Tube.

◆ Tube() [2/2]

Tube::Tube ( const Tube tube)

Tube copy constructor.

Parameters
tubeThe Tube to copy.

◆ ~Tube()

Tube::~Tube ( )

Tube destructor.

Member Function Documentation

◆ intersect()

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

Tube-Ray intersection computation.

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

The intersection of a Ray with an Tube is similar to that of a Cylinder, except:

  • There are two curved surfaces.
  • The top and bottom caps are rings rather than circles.
Parameters
rayThe Ray to intersect with this Tube.
Returns
A list (std::vector) of intersections, which may be empty.

Implements Object.

◆ operator=()

Tube & Tube::operator= ( const Tube tube)

Tube assignment operator.

Parameters
tubeThe Tube to assign to this.
Returns
A reference to this to allow for chaining of assignment.

Member Data Documentation

◆ ratio_

double Tube::ratio_
private

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