NASA World Wind

gov.nasa.worldwind.geom
Class Frustum

java.lang.Object
  extended by gov.nasa.worldwind.geom.Frustum
Direct Known Subclasses:
PickPointFrustum

public class Frustum
extends java.lang.Object

Instances of Frustum are immutable.


Constructor Summary
Frustum()
          Create a default frustum with six Planes.
Frustum(Plane left, Plane right, Plane bottom, Plane top, Plane near, Plane far)
          Create a frustum from six Planes, which define its boundaries.
 
Method Summary
 boolean contains(Vec4 point)
          Returns true if the specified point is inside the space enclosed by all six of tihs Frustum's clipping planes, and false otherwise.
 boolean equals(java.lang.Object obj)
           
static Frustum fromPerspective(Angle horizontalFieldOfView, int viewportWidth, int viewportHeight, double near, double far)
          Creates a Frustum from a horizontal field-of-view, viewport aspect ratio and distance to near and far depth clipping planes.
static Frustum fromPerspective(double width, double height, double near, double far)
          Creates a Frustum from three sets of parallel clipping planes (a parallel projectionMatrix).
static Frustum fromPerspectiveVecs(Vec4 vTL, Vec4 vTR, Vec4 vBL, Vec4 vBR, double near, double far)
          Creates a Frustum from four edge vectors, viewport aspect ratio and distance to near and far depth clipping planes.
static Frustum fromProjectionMatrix(Matrix projectionMatrix)
           
 Plane[] getAllPlanes()
           
 Plane getBottom()
           
 Plane getFar()
           
 Plane getLeft()
           
 Plane getNear()
           
 Plane getRight()
           
 Plane getTop()
           
 int hashCode()
           
 boolean intersects(Extent extent)
          Returns true if the specified Extent intersects the space enclosed by all six of this Frustum's clipping planes, and false otherwise.
 java.lang.String toString()
           
 Frustum transformBy(Matrix matrix)
          Returns a copy of this Frustum which is transformed by the specified Matrix.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Frustum

public Frustum()
Create a default frustum with six Planes. This defines a box of dimension (2, 2, 2) centered at the origin.


Frustum

public Frustum(Plane left,
               Plane right,
               Plane bottom,
               Plane top,
               Plane near,
               Plane far)
Create a frustum from six Planes, which define its boundaries. Does not except null arguments.

Parameters:
near - the near plane
far - the far plane
left - the left side of the view frustum
right - the right side of the view frustm
top - the top of the view frustum
bottom - the bottom of the view frustum
Throws:
java.lang.IllegalArgumentException - if any argument is null
Method Detail

contains

public final boolean contains(Vec4 point)
Returns true if the specified point is inside the space enclosed by all six of tihs Frustum's clipping planes, and false otherwise.

Parameters:
point - the point to test.
Returns:
true if the specified point is inside the space enclosed by this Frustum, and false otherwise.
Throws:
java.lang.IllegalArgumentException - if the point is null.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

fromPerspective

public static Frustum fromPerspective(Angle horizontalFieldOfView,
                                      int viewportWidth,
                                      int viewportHeight,
                                      double near,
                                      double far)
Creates a Frustum from a horizontal field-of-view, viewport aspect ratio and distance to near and far depth clipping planes. The near plane must be closer than the far plane, and both planes must be a positive distance away.

Parameters:
horizontalFieldOfView - horizontal field-of-view angle in the range (0, 180)
viewportWidth - the width of the viewport in screen pixels
viewportHeight - the height of the viewport in screen pixels
near - distance to the near depth clipping plane
far - distance to far depth clipping plane
Returns:
Frustum configured from the specified perspective parameters.
Throws:
java.lang.IllegalArgumentException - if fov is not in the range (0, 180), if either near or far are negative, or near is greater than or equal to far

fromPerspective

public static Frustum fromPerspective(double width,
                                      double height,
                                      double near,
                                      double far)
Creates a Frustum from three sets of parallel clipping planes (a parallel projectionMatrix). In this case, the near and far depth clipping planes may be a negative distance away.

Parameters:
near - distance to the near depth clipping plane
far - distance to far depth clipping plane
width - horizontal dimension of the near clipping plane
height - vertical dimension of the near clipping plane
Returns:
a Frustum configured with the specified perspective parameters.
Throws:
java.lang.IllegalArgumentException - if the difference of any plane set (lright - left, top - bottom, far - near) is less than or equal to zero.

fromPerspectiveVecs

public static Frustum fromPerspectiveVecs(Vec4 vTL,
                                          Vec4 vTR,
                                          Vec4 vBL,
                                          Vec4 vBR,
                                          double near,
                                          double far)
Creates a Frustum from four edge vectors, viewport aspect ratio and distance to near and far depth clipping planes. The near plane must be closer than the far plane, and both planes must be a positive distance away.

Parameters:
vTL - vector defining the top-left of the frustum
vTR - vector defining the top-right of the frustum
vBL - vector defining the bottom-left of the frustum
vBR - vector defining the bottom-right of the frustum
near - distance to the near depth clipping plane
far - distance to far depth clipping plane
Returns:
Frustum that was created
Throws:
java.lang.IllegalArgumentException - if any of the vectors are null, if either near or far are negative, or near is greater than or equal to far

fromProjectionMatrix

public static Frustum fromProjectionMatrix(Matrix projectionMatrix)

getAllPlanes

public Plane[] getAllPlanes()

getBottom

public final Plane getBottom()

getFar

public final Plane getFar()

getLeft

public final Plane getLeft()

getNear

public final Plane getNear()

getRight

public final Plane getRight()

getTop

public final Plane getTop()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

intersects

public final boolean intersects(Extent extent)
Returns true if the specified Extent intersects the space enclosed by all six of this Frustum's clipping planes, and false otherwise.

Parameters:
extent - the Extent to test.
Returns:
true if the specified Extent intersects the space enclosed by this Frustum, and false otherwise.
Throws:
java.lang.IllegalArgumentException - if the extent is null.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

transformBy

public Frustum transformBy(Matrix matrix)
Returns a copy of this Frustum which is transformed by the specified Matrix.

Parameters:
matrix - the Matrix to transform this Frustum by.
Returns:
a copy of this Frustum, transformed by the specified Matrix.
Throws:
java.lang.IllegalArgumentException - if the matrix is null

NASA World Wind