Documentation
¶
Overview ¶
Package cameras provides various implementations of the camera interface tracer.Camera.
Projection type and view direction ¶
A camera implementation is characterized by
- the kind of projection (plane, spherical, isometric, ...)
- the camera position and view direction
Constructors return a camera located at position (0,0,0) and looking in the -Z direction. These can then be changed via the methods
Translate YawPitchRoll
Internally, projection and position are separated wrapping a transform (change in view direction and position) around an implementation that has a fixed view direction and only cares about the type of projection. All constructors return a pre-wrapped camera, which can be conveniently tranformed.
Axes and handedness ¶
The convention in this package is that the X axis points to the right of the screen, the Y axis points up, and the Z axis points towards the viewer.
This makes the coordinate system right-handed.
All implementations in this package assume the u axis (on the image sensor) corresponds to pointing to the right of the computer screen, and the V axis pointing up on the screen. Image samplers (package sampler) are responsible for following this convention.
Note that some graphics libraries use other conventions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WithTransform ¶
type WithTransform struct {
// contains filtered or unexported fields
}
WithTransform wraps an affine transformation around a camera, allowing for the camera position and view direction to be set.
func EnvironmentMap ¶
func EnvironmentMap() *WithTransform
EnvironmentMap returns a camera that records a 360 degree view of the entire environment around the camera using a spherical projection.
The camera's horizontal (U) axis spans 360 degrees in the horizontal (XZ) plane, with the center pixel looling along the -Z axis.
The camera's veritical (V) axis spans 180 degrees, from looking along the -Y axis to looking along the +Y axis.
The camera can be rotated and translated after construction, if desired.
func Isometric ¶
func Isometric(dir int, size float64) *WithTransform
Isometric returns a camera that performs an isometric projection (no perspective, sizes are conserved). dir is the view direction:
0:X 1:Y 2:Z
size is the horizontal viewport size.
func Projective ¶
func Projective(FOV float64) *WithTransform
Projective constructs a camera like ProjectiveAperture, but with zero aperture. I.e. a pinhole camera.
func ProjectiveAperture ¶
func ProjectiveAperture(FOV, aperture, focusDist float64) *WithTransform
A projective Camera projects onto a flat image sensor. FOV is the horizontal Field Of View, in radians.
This camera optionally has a finite-size lens aperture which creates depth of field. If a non-zero Aperture is set, focusDist should be set to the distance from the camera to focus on.
The camera is located at (0,0,0) and looks along the -Z direction. It can be rotated and translated if desired.
func Transform ¶
func Transform(c tracer.Camera, rotate geom.Matrix, translate Vec) *WithTransform
Transform wraps an affine transformation around a camera, allowing for the camera position and view direction to be set.
The original camera is not mutated.
Rotation is always with respect to the camera's current position. Thus, the rotation and translation are independent of each other. (they even commute). Note that this is different from affine transformations, who do not commute.
func (*WithTransform) RayFrom ¶
func (c *WithTransform) RayFrom(ctx *Ctx, u, v float64) *Ray
RayFrom implements tracer.Camera.
func (*WithTransform) Translate ¶
func (c *WithTransform) Translate(delta Vec) *WithTransform
Translate returns an instance of this camera whose position has been translated. The original is not affected. The delta is in absolute coordinates, unaffected by the camera's view direction.
func (*WithTransform) YawPitchRoll ¶
func (c *WithTransform) YawPitchRoll(yaw, pitch, roll float64) *WithTransform
YawPitchRoll returns an instance of this camera whose view direction has been rotated by yaw, pitch, roll radians around the Y, X, and Z axes respectively. Rotation is around the camera's own postition.