Safe Haskell | Safe-Inferred |
---|

A `Camera`

represents a coordinate frame into which 3D points may
be transformed. For rendering purposes, it is often helpful to
combine a transformation matrix computed from a `Camera`

by
`camMatrix`

-- that transforms points into the camera's coordinate
frame -- with a perspective projection matrix, as created by
`projectionMatrix`

.

- data Camera a = Camera {
- forward :: V3 a
- upward :: V3 a
- rightward :: V3 a
- orientation :: Quaternion a
- location :: V3 a

- panRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a
- pan :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a
- tiltRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a
- tilt :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a
- rollRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a
- roll :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a
- dolly :: (Conjugate a, Epsilon a, RealFloat a) => V3 a -> Camera a -> Camera a
- rosCamera :: (Epsilon a, RealFloat a) => Camera a
- fpsCamera :: (Epsilon a, RealFloat a) => Camera a
- projectionMatrix :: (Conjugate a, Epsilon a, RealFloat a) => a -> a -> a -> a -> M44 a
- camMatrix :: (Conjugate a, Epsilon a, RealFloat a) => Camera a -> M44 a
- deg2rad :: RealFloat a => a -> a

# Camera movement

A `Camera`

may be translated and rotated to provide a coordinate
frame into which 3D points may be transformed.

panRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera aSource

Pan a camera view (turn side-to-side) by an angle given in
radians. Panning is about the world's up-axis as captured by the
initial camera state (e.g. the positive Y axis for `fpsCamera`

).

pan :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera aSource

Pan a camera view (turn side-to-side) by an angle given in
degrees. Panning is about the world's up-axis as captured by the
initial camera state (e.g. the positive Y axis for `fpsCamera`

).

tiltRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera aSource

Tilt a camera view (up-and-down) by an angle given in
radians. Tilting is about the camera's horizontal axis (e.g. the
positive X axis for `fpsCamera`

).

tilt :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera aSource

Tilt a camera view (up-and-down) by an angle given in degrees.
Tilting is about the camera's horizontal axis (e.g. the positive X
axis for `fpsCamera`

).

rollRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera aSource

Roll a camera view about its view direction by an angle given in
radians. Rolling is about the camera's forward axis (e.g. the
negative Z axis for `fpsCamera`

).

roll :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera aSource

Roll a camera view about its view direction by an angle given in
degrees. Rolling is about the camera's forward axis (e.g. the
negative Z axis for `fpsCamera`

).

dolly :: (Conjugate a, Epsilon a, RealFloat a) => V3 a -> Camera a -> Camera aSource

Translate a camera's position by the given vector.

# Camera initialization

rosCamera :: (Epsilon a, RealFloat a) => Camera aSource

A camera at the origin with its up-axis coincident with the positive Z axis. This is the convention used by the ROS robotics platform.

fpsCamera :: (Epsilon a, RealFloat a) => Camera aSource

A camera at the origin with its up-axis coincident with the positive Y axis. This is the convention used by first-person shooter (fps) video games.

# Matrices

projectionMatrix :: (Conjugate a, Epsilon a, RealFloat a) => a -> a -> a -> a -> M44 aSource

`projectionMatrix fov aspect near far`

produces a perspective
projection matrix with the specified vertical field of view (FOV),
given in radians, aspect ratio, and near and far clipping planes.

camMatrix :: (Conjugate a, Epsilon a, RealFloat a) => Camera a -> M44 aSource

Produce a transformation matrix from a `Camera`

. This matrix
transforms homogenous points into the camera's coordinate frame.