Ray Tracer  2020
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Camera Class Referenceabstract

Abstract base class for Cameras. More...

#include <Camera.h>

Inheritance diagram for Camera:
PinholeCamera

Public Member Functions

virtual Ray castRay (double x, double y) const =0
 Generate a ray for a given image plane co-ordinate. More...
 

Public Attributes

Transform transform
 Transformation to apply to the Camera. More...
 

Protected Member Functions

 Camera ()
 Camera default constructor. More...
 
 Camera (const Camera &camera)
 Camera copy constructor. More...
 
virtual ~Camera ()
 Camera destructor. More...
 
Cameraoperator= (const Camera &camera)
 Camera assignment operator. More...
 

Detailed Description

Abstract base class for Cameras.

Cameras are the primary source of rays in a scene. A camera is defined by its castRay() function, which generates a ray given image plane co-ordinates.

As an abstract base class, you cannot create a Camera directly. Instead one of its concrete subclasses must be created.

Constructor & Destructor Documentation

◆ Camera() [1/2]

Camera::Camera ( )
protected

Camera default constructor.

◆ Camera() [2/2]

Camera::Camera ( const Camera camera)
protected

Camera copy constructor.

Parameters
cameraThe Camera to copy.

◆ ~Camera()

Camera::~Camera ( )
protectedvirtual

Camera destructor.

Member Function Documentation

◆ castRay()

virtual Ray Camera::castRay ( double  x,
double  y 
) const
pure virtual

Generate a ray for a given image plane co-ordinate.

Given a point on a virtual image plane, this method generates a ray for a given camera model. Note that image plane co-ordinates are not the same as pixel co-ordinates. There are two main differences:

  • The origin of the image plane co-ordinates are in the centre of the image plane, while pixels usually count from the top left corner.
  • Image plane co-ordinates are continuous (real) values, wheras pixel values are discrete.

By convention, x-values are in the range [-1,1], and the range of y-values depends on the aspect ratio of the image. For wide (landscape) images y-values will lie in a narrower range, while for tall (portrait) images, y-values will exceed this range. This is, however, merely a convention so is neither required nor enforced.

Parameters
xthe horizontal location
ythe vertical location
Returns
The Ray that passes from the Camera through (x,y) in the image plane.

Implemented in PinholeCamera.

◆ operator=()

Camera & Camera::operator= ( const Camera camera)
protected

Camera assignment operator.

Parameters
cameraThe Camera to assign to this.
Returns
A reference to this to allow for chaining of assignment.

Member Data Documentation

◆ transform

Transform Camera::transform

Transformation to apply to the Camera.


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