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

Class to store the intersection of a Ray and an Object. More...

#include <RayIntersection.h>

Public Member Functions

bool operator< (const RayIntersection &ri)
 Less-than comparison for RayIntersection. More...
 

Public Attributes

Point point
 The Point at which a Ray intersects with an Object. More...
 
Normal normal
 The Normal at the Point of intersection. More...
 
Material material
 The Material of the Object that is hit. More...
 
double distance
 The distance along the Ray to the intersection Point. More...
 

Detailed Description

Class to store the intersection of a Ray and an Object.

The fundamental operation in ray-tracing is intersecting a Ray with an Object. A RayIntersection stores the information about this intersection. As well as the Point at which the intersection occurs, the Normal to the object at that location, the Material of the object, and the distance along the ray are all required.

RayInteresections can also be sorted on distance along the ray.

Member Function Documentation

◆ operator<()

bool RayIntersection::operator< ( const RayIntersection ri)
inline

Less-than comparison for RayIntersection.

In order to sort RayIntersection objects using the standard algorithms a less-than operator is required. This is defined in terms of the distance property, which provides a natural ordering for multipe Object intersections for a single Ray.

Parameters
riThe RayIntersection to compare to this
Returns
true if this.distance is less than ri.distance, false otherwise.

Member Data Documentation

◆ distance

double RayIntersection::distance

The distance along the Ray to the intersection Point.

◆ material

Material RayIntersection::material

The Material of the Object that is hit.

◆ normal

Normal RayIntersection::normal

The Normal at the Point of intersection.

◆ point

Point RayIntersection::point

The Point at which a Ray intersects with an Object.


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