# `Cauldron3D.View`
[🔗](https://github.com/jaman/cauldron/blob/v0.2.2/cauldron_3d/lib/cauldron_3d/view.ex#L1)

A camera fitted to a picture: the projection from the world to pixels.

    view = Cauldron3D.View.new(camera, {320, 200})
    Cauldron3D.View.to_camera(view, point)

Pixel `{0, 0}` is the top left. `:pixel_aspect` is a pixel's height over its width,
1.0 for square pixels; a taller pixel squeezes the picture's height so circles stay
round.

A point in camera space is `{right, up, depth}`. Projected, it is
`{x, y, nearness, w}`: the pixel position, a value that grows toward the camera and
changes linearly across the picture (for comparing what is in front), and the factor
attributes are carried through by for perspective-correct interpolation (`1 / depth`
in perspective, `1.0` orthographic).

# `t`

```elixir
@type t() :: %Cauldron3D.View{
  camera: Cauldron3D.Camera.t(),
  center_x: float(),
  center_y: float(),
  forward: Cauldron3D.Vec.t(),
  height: pos_integer(),
  near: float(),
  origin: Cauldron3D.Vec.t(),
  perspective?: boolean(),
  right: Cauldron3D.Vec.t(),
  scale_x: float(),
  scale_y: float(),
  up: Cauldron3D.Vec.t(),
  width: pos_integer()
}
```

# `in_front?`

```elixir
@spec in_front?(t(), Cauldron3D.Vec.t()) :: boolean()
```

Whether a point in the world is in front of the camera's near plane.

# `new`

```elixir
@spec new(Cauldron3D.Camera.t(), {pos_integer(), pos_integer()}, keyword()) :: t()
```

The view of `camera` in a picture `{width, height}`. Takes `:pixel_aspect`, default 1.0.

# `project`

```elixir
@spec project(t(), Cauldron3D.Vec.t()) :: {float(), float(), float(), float()}
```

A camera-space point projected: `{x, y, nearness, w}`. The depth must be above zero in perspective.

# `ray`

```elixir
@spec ray(t(), number(), number()) :: Cauldron3D.Vec.t()
```

The direction from the camera through the centre of pixel `{x, y}`, in the world, not of length one.

# `to_camera`

```elixir
@spec to_camera(t(), Cauldron3D.Vec.t()) :: Cauldron3D.Vec.t()
```

A world point in camera space, `{right, up, depth}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
