Table of Contents

Struct BoundingFrustum

Namespace
HelixToolkit.Maths
Assembly
HelixToolkit.Maths.dll

Defines a frustum which can be used in frustum culling, zoom to Extents (zoom to fit) operations, (matrix, frustum, camera) interchange, and many kind of intersection testing.

public struct BoundingFrustum : IEquatable<BoundingFrustum>
Implements
Inherited Members
Extension Methods

Constructors

BoundingFrustum(Matrix4x4)

Creates a new instance of BoundingFrustum.

public BoundingFrustum(Matrix4x4 matrix)

Parameters

matrix Matrix4x4

Combined matrix that usually takes view × projection matrix.

Properties

Bottom

Gets the bottom plane of the BoundingFrustum.

public readonly Plane Bottom { get; }

Property Value

Plane

Far

Gets the far plane of the BoundingFrustum.

public readonly Plane Far { get; }

Property Value

Plane

IsOrthographic

Indicate whether the current BoundingFrustrum is Orthographic.

public readonly bool IsOrthographic { get; }

Property Value

bool

true if the current BoundingFrustrum is Orthographic; otherwise, false.

Left

Gets the left plane of the BoundingFrustum.

public readonly Plane Left { get; }

Property Value

Plane

Matrix

Gets or sets the Matrix that describes this bounding frustum.

public Matrix4x4 Matrix { readonly get; set; }

Property Value

Matrix4x4

Near

Gets the near plane of the BoundingFrustum.

public readonly Plane Near { get; }

Property Value

Plane

Right

Gets the right plane of the BoundingFrustum.

public readonly Plane Right { get; }

Property Value

Plane

Top

Gets the top plane of the BoundingFrustum.

public readonly Plane Top { get; }

Property Value

Plane

Methods

Contains(BoundingBox)

Determines the intersection relationship between the frustum and a bounding box.

public readonly ContainmentType Contains(BoundingBox box)

Parameters

box BoundingBox

The box.

Returns

ContainmentType

Type of the containment

Contains(ref BoundingBox)

Determines the intersection relationship between the frustum and a bounding box.

public readonly ContainmentType Contains(ref BoundingBox box)

Parameters

box BoundingBox

The box.

Returns

ContainmentType

Type of the containment

Contains(ref BoundingBox, out ContainmentType)

Determines the intersection relationship between the frustum and a bounding box.

public readonly void Contains(ref BoundingBox box, out ContainmentType result)

Parameters

box BoundingBox

The box.

result ContainmentType

Type of the containment.

Contains(BoundingSphere)

Determines the intersection relationship between the frustum and a bounding sphere.

public readonly ContainmentType Contains(BoundingSphere sphere)

Parameters

sphere BoundingSphere

The sphere.

Returns

ContainmentType

Type of the containment

Contains(ref BoundingSphere)

Determines the intersection relationship between the frustum and a bounding sphere.

public readonly ContainmentType Contains(ref BoundingSphere sphere)

Parameters

sphere BoundingSphere

The sphere.

Returns

ContainmentType

Type of the containment

Contains(ref BoundingSphere, out ContainmentType)

Determines the intersection relationship between the frustum and a bounding sphere.

public readonly void Contains(ref BoundingSphere sphere, out ContainmentType result)

Parameters

sphere BoundingSphere

The sphere.

result ContainmentType

Type of the containment.

Contains(Vector3)

Checks whether a point lay inside, intersects or lay outside the frustum.

public readonly ContainmentType Contains(Vector3 point)

Parameters

point Vector3

The point.

Returns

ContainmentType

Type of the containment

Contains(ref Vector3)

Checks whether a point lay inside, intersects or lay outside the frustum.

public readonly ContainmentType Contains(ref Vector3 point)

Parameters

point Vector3

The point.

Returns

ContainmentType

Type of the containment

Equals(BoundingFrustum)

Determines whether the specified BoundingFrustum is equal to this instance.

public readonly bool Equals(BoundingFrustum other)

Parameters

other BoundingFrustum

The BoundingFrustum to compare with this instance.

Returns

bool

true if the specified BoundingFrustum is equal to this instance; otherwise, false.

Equals(ref BoundingFrustum)

Determines whether the specified BoundingFrustum is equal to this instance.

public readonly bool Equals(ref BoundingFrustum other)

Parameters

other BoundingFrustum

The BoundingFrustum to compare with this instance.

Returns

bool

true if the specified BoundingFrustum is equal to this instance; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to this instance.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

FromCamera(FrustumCameraParams)

Creates a new frustum relaying on perspective camera parameters

public static BoundingFrustum FromCamera(FrustumCameraParams cameraParams)

Parameters

cameraParams FrustumCameraParams

The camera params.

Returns

BoundingFrustum

The bounding frustum from camera params

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

Creates a new frustum relaying on perspective camera parameters

public static BoundingFrustum FromCamera(Vector3 cameraPos, Vector3 lookDir, Vector3 upDir, float fov, float znear, float zfar, float aspect)

Parameters

cameraPos Vector3

The camera pos.

lookDir Vector3

The look dir.

upDir Vector3

Up dir.

fov float

The fov.

znear float

The znear.

zfar float

The zfar.

aspect float

The aspect.

Returns

BoundingFrustum

The bounding frustum calculated from perspective camera

GetCameraParams()

Extracts perspective camera parameters from the frustum, doesn't work with orthographic frustums.

public FrustumCameraParams GetCameraParams()

Returns

FrustumCameraParams

Perspective camera parameters from the frustum

GetCorners()

Returns the 8 corners of the frustum, element0 is Near1 (near right down corner) , element1 is Near2 (near right top corner) , element2 is Near3 (near Left top corner) , element3 is Near4 (near Left down corner) , element4 is Far1 (far right down corner) , element5 is Far2 (far right top corner) , element6 is Far3 (far left top corner) , element7 is Far4 (far left down corner)

public Vector3[] GetCorners()

Returns

Vector3[]

The 8 corners of the frustum

GetCorners(Vector3[])

Returns the 8 corners of the frustum, element0 is Near1 (near right down corner) , element1 is Near2 (near right top corner) , element2 is Near3 (near Left top corner) , element3 is Near4 (near Left down corner) , element4 is Far1 (far right down corner) , element5 is Far2 (far right top corner) , element6 is Far3 (far left top corner) , element7 is Far4 (far left down corner)

public void GetCorners(Vector3[] corners)

Parameters

corners Vector3[]

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetHeightAtDepth(float)

Get the height of the frustum at specified depth.

public readonly float GetHeightAtDepth(float depth)

Parameters

depth float

the depth at which to calculate frustum height.

Returns

float

Height of the frustum at the specified depth

GetPlane(int)

Returns one of the 6 planes related to this frustum.

public readonly Plane GetPlane(int index)

Parameters

index int

Plane index where 0 fro Left, 1 for Right, 2 for Top, 3 for Bottom, 4 for Near, 5 for Far

Returns

Plane

GetWidthAtDepth(float)

Get the width of the frustum at specified depth.

public readonly float GetWidthAtDepth(float depth)

Parameters

depth float

the depth at which to calculate frustum width.

Returns

float

With of the frustum at the specified depth

GetZoomToExtentsShiftDistance(ref BoundingBox)

Get the distance which when added to camera position along the lookat direction will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view. if the returned value is positive, the camera will move toward the lookat direction (ZoomIn). if the returned value is negative, the camera will move in the reverse direction of the lookat direction (ZoomOut).

public readonly float GetZoomToExtentsShiftDistance(ref BoundingBox boundingBox)

Parameters

boundingBox BoundingBox

The bounding box.

Returns

float

The zoom to fit distance

GetZoomToExtentsShiftDistance(Vector3[])

Get the distance which when added to camera position along the lookat direction will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view. if the returned value is positive, the camera will move toward the lookat direction (ZoomIn). if the returned value is negative, the camera will move in the reverse direction of the lookat direction (ZoomOut).

public readonly float GetZoomToExtentsShiftDistance(Vector3[] points)

Parameters

points Vector3[]

The points.

Returns

float

The zoom to fit distance

GetZoomToExtentsShiftVector(ref BoundingBox)

Get the vector shift which when added to camera position will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view.

public readonly Vector3 GetZoomToExtentsShiftVector(ref BoundingBox boundingBox)

Parameters

boundingBox BoundingBox

The bounding box.

Returns

Vector3

The zoom to fit vector

GetZoomToExtentsShiftVector(Vector3[])

Get the vector shift which when added to camera position will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view.

public readonly Vector3 GetZoomToExtentsShiftVector(Vector3[] points)

Parameters

points Vector3[]

The points.

Returns

Vector3

The zoom to fit vector

Intersects(ref BoundingBox)

Checks whether the current BoundingFrustum intersects a BoundingBox.

public readonly bool Intersects(ref BoundingBox box)

Parameters

box BoundingBox

The box.

Returns

bool

true if the current BoundingFrustum intersects a BoundingSphere.

Intersects(ref BoundingBox, out bool)

Checks whether the current BoundingFrustum intersects a BoundingBox.

public readonly void Intersects(ref BoundingBox box, out bool result)

Parameters

box BoundingBox

The box.

result bool

true if the current BoundingFrustum intersects a BoundingSphere.

Intersects(ref BoundingSphere)

Checks whether the current BoundingFrustum intersects a BoundingSphere.

public readonly bool Intersects(ref BoundingSphere sphere)

Parameters

sphere BoundingSphere

The sphere.

Returns

bool

Type of the containment

Intersects(ref BoundingSphere, out bool)

Checks whether the current BoundingFrustum intersects a BoundingSphere.

public readonly void Intersects(ref BoundingSphere sphere, out bool result)

Parameters

sphere BoundingSphere

The sphere.

result bool

Set to true if the current BoundingFrustum intersects a BoundingSphere.

Intersects(ref Ray)

Checks whether the current BoundingFrustum intersects the specified Ray.

public readonly bool Intersects(ref Ray ray)

Parameters

ray Ray

The ray.

Returns

bool

true if the current BoundingFrustum intersects the specified Ray.

Intersects(ref Ray, out float?, out float?)

Checks whether the current BoundingFrustum intersects the specified Ray.

public readonly bool Intersects(ref Ray ray, out float? inDistance, out float? outDistance)

Parameters

ray Ray

The Ray to check for intersection with.

inDistance float?

The distance at which the ray enters the frustum if there is an intersection and the ray starts outside the frustum.

outDistance float?

The distance at which the ray exits the frustum if there is an intersection.

Returns

bool

true if the current BoundingFrustum intersects the specified Ray.

Intersects(ref Plane)

Checks whether the current BoundingFrustum intersects the specified Plane.

public PlaneIntersectionType Intersects(ref Plane plane)

Parameters

plane Plane

The plane.

Returns

PlaneIntersectionType

Plane intersection type.

Intersects(ref Plane, out PlaneIntersectionType)

Checks whether the current BoundingFrustum intersects the specified Plane.

public void Intersects(ref Plane plane, out PlaneIntersectionType result)

Parameters

plane Plane

The plane.

result PlaneIntersectionType

Plane intersection type.

Operators

operator ==(BoundingFrustum, BoundingFrustum)

Implements the operator ==.

public static bool operator ==(BoundingFrustum left, BoundingFrustum right)

Parameters

left BoundingFrustum

The left.

right BoundingFrustum

The right.

Returns

bool

The result of the operator.

operator !=(BoundingFrustum, BoundingFrustum)

Implements the operator !=.

public static bool operator !=(BoundingFrustum left, BoundingFrustum right)

Parameters

left BoundingFrustum

The left.

right BoundingFrustum

The right.

Returns

bool

The result of the operator.