Atoms Crowd  7.0.0
Frustum< T > Class Template Reference

#include <ImathFrustum.h>

Public Member Functions

Constructors and Assignment
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Frustum () noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Frustum (const Frustum &) noexcept
 Copy constructor.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Frustum (T nearPlane, T farPlane, T left, T right, T top, T bottom, bool ortho=false) noexcept
 Initialize to specific values.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Frustum (T nearPlane, T farPlane, T fovx, T fovy, T aspect) noexcept
 Initialize with fov and aspect.
 
virtual ~Frustum () noexcept
 Destructor.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Frustumoperator= (const Frustum &) noexcept
 Component-wise assignment.
 
Comparison
constexpr ATOMSMATH_HOSTDEVICE bool operator== (const Frustum< T > &src) const noexcept
 Equality.
 
constexpr ATOMSMATH_HOSTDEVICE bool operator!= (const Frustum< T > &src) const noexcept
 Inequality.
 
Query
constexpr ATOMSMATH_HOSTDEVICE bool orthographic () const noexcept
 Return true if the frustum is orthographic, false if perspective.
 
constexpr ATOMSMATH_HOSTDEVICE T nearPlane () const noexcept
 Return the near clipping plane.
 
constexpr ATOMSMATH_HOSTDEVICE T hither () const noexcept
 Return the near clipping plane.
 
constexpr ATOMSMATH_HOSTDEVICE T farPlane () const noexcept
 Return the far clipping plane.
 
constexpr ATOMSMATH_HOSTDEVICE T yon () const noexcept
 Return the far clipping plane.
 
constexpr ATOMSMATH_HOSTDEVICE T left () const noexcept
 Return the left of the frustum.
 
constexpr ATOMSMATH_HOSTDEVICE T right () const noexcept
 Return the right of the frustum.
 
constexpr ATOMSMATH_HOSTDEVICE T bottom () const noexcept
 Return the bottom of the frustum.
 
constexpr ATOMSMATH_HOSTDEVICE T top () const noexcept
 Return the top of the frustum.
 
constexpr ATOMSMATH_HOSTDEVICE T fovx () const noexcept
 Return the field of view in X.
 
constexpr ATOMSMATH_HOSTDEVICE T fovy () const noexcept
 Return the field of view in Y.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T aspect () const noexcept
 Return the aspect ratio.
 
ATOMSMATH_CONSTEXPR14 T aspectExc () const
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44< T > projectionMatrix () const noexcept
 Return the project matrix that the frustum defines.
 
ATOMSMATH_CONSTEXPR14 Matrix44< T > projectionMatrixExc () const
 
constexpr ATOMSMATH_HOSTDEVICE bool degenerate () const noexcept
 Return true if the frustum is degenerate.
 
Set Value
ATOMSMATH_HOSTDEVICE void set (T nearPlane, T farPlane, T left, T right, T top, T bottom, bool ortho=false) noexcept
 Set functions change the entire state of the Frustum.
 
ATOMSMATH_HOSTDEVICE void set (T nearPlane, T farPlane, T fovx, T fovy, T aspect) noexcept
 
void setExc (T nearPlane, T farPlane, T fovx, T fovy, T aspect)
 
ATOMSMATH_HOSTDEVICE void modifyNearAndFar (T nearPlane, T farPlane) noexcept
 Set the near and far clipping planes.
 
ATOMSMATH_HOSTDEVICE void setOrthographic (bool) noexcept
 Set the ortographic state.
 
ATOMSMATH_HOSTDEVICE void planes (Plane3< T > p[6]) const noexcept
 
ATOMSMATH_HOSTDEVICE void planes (Plane3< T > p[6], const Matrix44< T > &M) const noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 ATOMSMATH_HOSTDEVICE Frustum< T > window (T left, T right, T top, T bottom) const noexcept
 
Utility Methods
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Line3< T > projectScreenToRay (const Vec2< T > &) const noexcept
 Project a point in screen spaced to 3d ray.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Vec2< T > projectPointToScreen (const Vec3< T > &) const noexcept
 Project a 3D point into screen coordinates.
 
ATOMSMATH_CONSTEXPR14 Vec2< T > projectPointToScreenExc (const Vec3< T > &) const
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T ZToDepth (long zval, long min, long max) const noexcept
 Map a z value to its depth in the frustum.
 
ATOMSMATH_CONSTEXPR14 T ZToDepthExc (long zval, long min, long max) const
 Map a z value to its depth in the frustum.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T normalizedZToDepth (T zval) const noexcept
 Map a normalized z value to its depth in the frustum.
 
ATOMSMATH_CONSTEXPR14 T normalizedZToDepthExc (T zval) const
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 long DepthToZ (T depth, long zmin, long zmax) const noexcept
 Map depth to z value.
 
ATOMSMATH_CONSTEXPR14 long DepthToZExc (T depth, long zmin, long zmax) const
 Map depth to z value. Throw an exception on error.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T worldRadius (const Vec3< T > &p, T radius) const noexcept
 Compute worldRadius.
 
ATOMSMATH_CONSTEXPR14 T worldRadiusExc (const Vec3< T > &p, T radius) const
 Compute worldRadius. Throw an exception on error.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T screenRadius (const Vec3< T > &p, T radius) const noexcept
 Compute screen radius.
 
ATOMSMATH_CONSTEXPR14 T screenRadiusExc (const Vec3< T > &p, T radius) const
 Compute screen radius. Throw an exception on error.
 

Protected Member Functions

constexpr ATOMSMATH_HOSTDEVICE Vec2< T > screenToLocal (const Vec2< T > &) const noexcept
 Map point from screen space to local space.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Vec2< T > localToScreen (const Vec2< T > &) const noexcept
 Map point from local space to screen space.
 
ATOMSMATH_CONSTEXPR14 Vec2< T > localToScreenExc (const Vec2< T > &) const
 

Detailed Description

template<class T>
class Frustum< T >

Template class Frustum<T>

The frustum is always located with the eye point at the origin facing down -Z. This makes the Frustum class compatable with OpenGL (or anything that assumes a camera looks down -Z, hence with a right-handed coordinate system) but not with RenderMan which assumes the camera looks down +Z. Additional functions are provided for conversion from and from various camera coordinate spaces.

nearPlane/farPlane: near/far are keywords used by Microsoft's compiler, so we use nearPlane/farPlane instead to avoid issues.

Constructor & Destructor Documentation

◆ Frustum()

template<class T >
ATOMSMATH_CONSTEXPR14 Frustum< T >::Frustum
inlinenoexcept

Initialize with default values: near=0.1, far=1000.0, left=-1.0, right=1.0, top=1.0, bottom=-1.0, ortho=false

Member Function Documentation

◆ aspectExc()

template<class T >
ATOMSMATH_CONSTEXPR14 T Frustum< T >::aspectExc
inline

Return the aspect ratio. Throw an exception if the aspect ratio is undefined.

◆ localToScreenExc()

template<class T >
ATOMSMATH_CONSTEXPR14 Vec2< T > Frustum< T >::localToScreenExc ( const Vec2< T > &  p) const
inlineprotected

Map point from local space to screen space. Throw an exception on error.

◆ normalizedZToDepthExc()

template<class T >
ATOMSMATH_CONSTEXPR14 T Frustum< T >::normalizedZToDepthExc ( zval) const

Map a normalized z value to its depth in the frustum. Throw an exception on error.

◆ planes() [1/2]

template<class T >
void Frustum< T >::planes ( Plane3< T >  p[6]) const
noexcept

Set the planes in p to be the six bounding planes of the frustum, in the following order: top, right, bottom, left, near, far. Note that the planes have normals that point out of the frustum.

◆ planes() [2/2]

template<class T >
void Frustum< T >::planes ( Plane3< T >  p[6],
const Matrix44< T > &  M 
) const
noexcept

Set the planes in p to be the six bounding planes of the frustum, in the following order: top, right, bottom, left, near, far. Note that the planes have normals that point out of the frustum. Apply the given matrix to transform the frustum before setting the planes.

◆ projectionMatrixExc()

template<class T >
ATOMSMATH_CONSTEXPR14 Matrix44< T > Frustum< T >::projectionMatrixExc
inline

Return the project matrix that the frustum defines. Throw an exception if the frustum is degenerate.

◆ projectPointToScreenExc()

template<class T >
ATOMSMATH_CONSTEXPR14 Vec2< T > Frustum< T >::projectPointToScreenExc ( const Vec3< T > &  point) const

Project a 3D point into screen coordinates. Throw an exception if the point cannot be projected.

◆ set()

template<class T >
void Frustum< T >::set ( nearPlane,
farPlane,
fovx,
fovy,
aspect 
)
inlinenoexcept

Set functions change the entire state of the Frustum using field of view and aspect ratio

◆ setExc()

template<class T >
void Frustum< T >::setExc ( nearPlane,
farPlane,
fovx,
fovy,
aspect 
)
inline

Set functions change the entire state of the Frustum using field of view and aspect ratio. Throw an exception if fovx and/or fovy are invalid.

◆ window()

template<class T >
ATOMSMATH_CONSTEXPR14 Frustum< T > Frustum< T >::window ( left,
right,
top,
bottom 
) const
inlinenoexcept

Takes a rectangle in the screen space (i.e., -1 <= left <= right <= 1 and -1 <= bottom <= top <= 1) of this Frustum, and returns a new Frustum whose near clipping-plane window is that rectangle in local space.


The documentation for this class was generated from the following file: