Overview | Package | Class | Use | Tree | Index | Help
| Rings Version 0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## threeD.raytracer.engine
Class Camera

    java.lang.Object
      threeD.raytracer.engine.Camera

public class Camera
extends Object

A Camera object represents a camera in 3d. A Camera object stores the location, viewing direction, up direction, focal length, and projection dimensions which are used for rendering. When constructing a Camera object you must make these specifications carefully. The camera location is, as expected, the location from which the camera views, represented as a vector. This value is by default at the origin. The viewing direction is a vector that represents the direction the camera is viewing. This value is by default aligned to the positive z axis, or (0.0, 0.0, 1.0). The up direction is a vector that represents the orientation of the camera's "up." This value is by default aligned with the positive y axis or (0.0, 1.0, 0.0). The focal length of the camera can be thought of as the distance from the camera location to the projection. The focal length is also the tangent of half the vertical field of view. The projection dimensions are the dimensions of the projection that the camera will produce. By default the projection dimensions are set so that the horizontal field of view is approx. 120 degrees and the vertical field of view is approx. 90 degrees. A Camera object also stores three perpendicular vectors that describe a coordinate system. This is the camera coordinate system and is used for projection. These vectors are computed and updated automatically based on the viewing direction and up direction vectors.

Constructor Summary
`Camera()` Constructs a Camera object with all default values as described above.
`Camera(Vector location, Vector viewDirection, Vector upDirection)` Constructs a Camera object with the specified location, viewing direction, and up direction, but with default focal length and projection dimensions as specified above.
`Camera(Vector location, Vector viewDirection, Vector upDirection, double focalLength, double[] fov)` Constructs a Camera object with the specified location, viewing direction, up direction, and focal length.
`Camera(Vector location, Vector viewDirection, Vector upDirection, double focalLength, double projectionX, double projectionY)` Constructs a Camera object with the specified location, viewing direction, up direction, focal length, and projection dimensions.

Method Summary
`double` | `getFocalLength()` Returns the focal length of this Camera object as a double value.
`Vector` | `getLocation()` Returns the location of this Camera object as a Vector object.
`double` | `getProjectionHeight()` Returns the projection height of this Camera object as a double value.
`double` | `getProjectionWidth()` Returns the projection width of this Camera object as a double value.
`TransformMatrix` | `getRotationMatrix()`
`Vector` | `getUpDirection()` Returns the up direction of this Camera object as a Vector object.
`Vector` | `getViewDirection()` Calls the getViewingDirection() method and returns the result.
`Vector` | `getViewingDirection()` Returns the viewing direction of this Camera object as a Vector object.
`Ray` | `rayAt(double i, double j, int screenWidth, int screenHeight)` Returns a Ray object that represents a line of sight from the camera represented by this Camera object.
`void` | `setFocalLength(double focalLength)` Sets the focal length of this Camera object to the specified focal length.
`void` | `setLocation(Vector location)` Sets the location of this Camera object to the specified location.
`void` | `setProjectionDimensions(double projectionX, double projectionY)` Sets the projection dimensions to the specified projection dimensions.
`void` | `setProjectionHeight(double projectionY)` Sets the projection height of this Camera object to the specified projection height.
`void` | `setProjectionWidth(double projectionX)` Sets the projection width of this Camera object to the specified projection width.
`void` | `setUpDirection(Vector upDirection)` Sets the up direction of this Camera object to the specified up direction.
`void` | `setViewDirection(Vector viewDirection)` Calls the setViewingDirection() method.
`void` | `setViewingDirection(Vector viewDirection)` Sets the viewing direction of this Camera object to the specified viewing direction.
`void` | `updateUVW()` Updates the orthonormal vectors used to describe camera space for this Camera object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Camera

    public Camera()

  Constructs a Camera object with all default values as described above.

### Camera

    public Camera(Vector location,
                  Vector viewDirection,
                  Vector upDirection)

  Constructs a Camera object with the specified location, viewing direction, and up direction, but with default focal length and projection dimensions as specified above.

### Camera

    public Camera(Vector location,
                  Vector viewDirection,
                  Vector upDirection,
                  double focalLength,
                  double projectionX,
                  double projectionY)

  Constructs a Camera object with the specified location, viewing direction, up direction, focal length, and projection dimensions.

### Camera

    public Camera(Vector location,
                  Vector viewDirection,
                  Vector upDirection,
                  double focalLength,
                  double[] fov)

  Constructs a Camera object with the specified location, viewing direction, up direction, and focal length. Projection dimensions are determined using the specified fields of view.

Parameters:
  `location` - Camera location.
  `upDirection` - Camera up direction.
  `focalLength` - Camera focal length.
  `fov` - Camera fields of view (radians) {horizontal FOV, vertical FOV}.

Method Detail

### setLocation

    public void setLocation(Vector location)

  Sets the location of this Camera object to the specified location.

### setViewDirection

    public void setViewDirection(Vector viewDirection)

  Calls the setViewingDirection() method.

### setViewingDirection

    public void setViewingDirection(Vector viewDirection)

  Sets the viewing direction of this Camera object to the specified viewing direction. This method automatically updates the camera coordinate system vectors.

### setUpDirection

    public void setUpDirection(Vector upDirection)

  Sets the up direction of this Camera object to the specified up direction. This method automatically updates the camera coordinate system vectors.

### setFocalLength

    public void setFocalLength(double focalLength)

  Sets the focal length of this Camera object to the specified focal length.

### setProjectionDimensions

    public void setProjectionDimensions(double projectionX,
                                        double projectionY)

  Sets the projection dimensions to the specified projection dimensions.

### setProjectionWidth

    public void setProjectionWidth(double projectionX)

  Sets the projection width of this Camera object to the specified projection width.

### setProjectionHeight

    public void setProjectionHeight(double projectionY)

  Sets the projection height of this Camera object to the specified projection height.

### updateUVW

    public void updateUVW()

  Updates the orthonormal vectors used to describe camera space for this Camera object.

### getLocation

    public Vector getLocation()

  Returns the location of this Camera object as a Vector object.

### getViewDirection

    public Vector getViewDirection()

  Calls the getViewingDirection() method and returns the result.

### getViewingDirection

    public Vector getViewingDirection()

  Returns the viewing direction of this Camera object as a Vector object.

### getUpDirection

    public Vector getUpDirection()

  Returns the up direction of this Camera object as a Vector object.

### getFocalLength

    public double getFocalLength()

  Returns the focal length of this Camera object as a double value.

### getProjectionWidth

    public double getProjectionWidth()

  Returns the projection width of this Camera object as a double value.

### getProjectionHeight

    public double getProjectionHeight()

  Returns the projection height of this Camera object as a double value.

### getRotationMatrix

    public TransformMatrix getRotationMatrix()

  Returns:
    A TransformMatrix object that can be used to convert coordinates in the coordinate system described by this Camera object to the standard x, y, z coordinates.

### rayAt

    public Ray rayAt(double i,
                     double j,
                     int screenWidth,
                     int screenHeight)

  Returns a Ray object that represents a line of sight from the camera represented by this Camera object. The first two parameters are the coordinates across the Camera. These coordinates corespond to the pixels on the rendered image. The second two parameters specifiy the total integer width and height of the screen. Although the pixels on the screen must be in integer coordinates, this method provides the ability to create super high resolution images by allowing you to devote a single pixel to only a fraction of the theoretical camera surface. This effect can be used to produce large images from small scenes while retaining acuracy.

Overview | Package | Class | Use | Tree | Index | Help
| Rings Version 0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2003-05 Mike Murray