Skip to content

Struct Frustum

Namespace: Apogee.Core.Numerics
Assembly: Apogee.Core.dll

The view volume of a perspective camera with an infinite far plane, as five planes (left, right, bottom, top, near) in the camera-relative space the renderer works in. A plane is (nx, ny, nz, d) and a point is inside when n·p + d >= 0 for all five. The four side planes pass through the camera, which is the origin, so their d is zero; moves the origin for a scene whose coordinates are relative to something else. The normals are not unit length (the side ones are forward * tan + right); the culling kernel takes that into account.

public readonly struct Frustum

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

Frustum(Vector4, Vector4, Vector4, Vector4, Vector4)

public Frustum(Vector4 left, Vector4 right, Vector4 bottom, Vector4 top, Vector4 near)

Parameters

left Vector4

right Vector4

bottom Vector4

top Vector4

near Vector4

Fields

PlaneCount

public const int PlaneCount = 5

Field Value

int

Properties

Bottom

public Vector4 Bottom { get; }

Property Value

Vector4

Left

public Vector4 Left { get; }

Property Value

Vector4

Near

public Vector4 Near { get; }

Property Value

Vector4

public Vector4 Right { get; }

Property Value

Vector4

Top

public Vector4 Top { get; }

Property Value

Vector4

this[int]

public Vector4 this[int plane] { get; }

Property Value

Vector4

Methods

FromCamera(Vector3, Vector3, Vector3, float, float, float)

The frustum of a camera at the origin looking along forward, from its basis (as in the rows of a view matrix). tanHalfFovY is the tangent of half the vertical field of view and aspect is width over height.

public static Frustum FromCamera(Vector3 right, Vector3 up, Vector3 forward, float tanHalfFovY, float aspect, float near)

Parameters

right Vector3

up Vector3

forward Vector3

tanHalfFovY float

aspect float

near float

Returns

Frustum

Intersects(Vector3, Vector3)

Whether a box (center and half extents along the axes) is at least partly inside. Exact for the planes, so a box near a corner can still be reported inside without being visible. The arithmetic is in the same order as 's vector kernels, which give the same answer.

public bool Intersects(Vector3 center, Vector3 extents)

Parameters

center Vector3

extents Vector3

Returns

bool

Offset(Vector3)

The same volume for boxes given relative to a point origin away from the camera: d absorbs n·origin.

public Frustum Offset(Vector3 origin)

Parameters

origin Vector3

Returns

Frustum