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

PinholeCamera class. More...

#include <PinholeCamera.h>

Inheritance diagram for PinholeCamera:
Camera

Public Member Functions

 PinholeCamera (double f=1)
 PinholeCamera constructor. More...
 
 PinholeCamera (const PinholeCamera &camera)
 PinholeCamera copy constructor. More...
 
 ~PinholeCamera ()
 PinholeCamera destructor. More...
 
PinholeCameraoperator= (const PinholeCamera &camera)
 PinholeCamera assignment operator. More...
 
Ray castRay (double x, double y) const
 Generate a ray for a given image plane co-ordinate. More...
 

Public Attributes

double focalLength
 The distance from the camera centre to the image plane. More...
 
- Public Attributes inherited from Camera
Transform transform
 Transformation to apply to the Camera. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Camera
 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

PinholeCamera class.

PinholeCamera implements a common Camera model that gives ideal perspective projections. The camera is defined by a point (the camera centre) and an image plane at some distance along the Z-axis (the focal distance). The projection of a 3D point into the image is the intersection of the line from the camera centre to the 3D point with the image plane.

Constructor & Destructor Documentation

◆ PinholeCamera() [1/2]

PinholeCamera::PinholeCamera ( double  f = 1)

PinholeCamera constructor.

This creates a new PinholeCamera with the camera centre at the origin, looking along the positive Z-axis. The focal length is provided as a parameter (default: 1 unit). The position and orientation of a Camera can be altered via its transform member.

Parameters
fThe focalLength of the new camera.

◆ PinholeCamera() [2/2]

PinholeCamera::PinholeCamera ( const PinholeCamera camera)

PinholeCamera copy constructor.

Parameters
cameraThe PinholeCamera to copy to this.

◆ ~PinholeCamera()

PinholeCamera::~PinholeCamera ( )

PinholeCamera destructor.

Member Function Documentation

◆ castRay()

Ray PinholeCamera::castRay ( double  x,
double  y 
) const
virtual

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

For a untransformed PinholeCamera the ray starts at the origin and passes through (x, y, focalLength).

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

Implements Camera.

◆ operator=()

PinholeCamera & PinholeCamera::operator= ( const PinholeCamera camera)

PinholeCamera assignment operator.

Parameters
cameraThe PinholeCamera to assign to this.
Returns
A reference to this to allow for chaining of assignments.

Member Data Documentation

◆ focalLength

double PinholeCamera::focalLength

The distance from the camera centre to the image plane.


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