NASA World Wind

gov.nasa.worldwind.view
Class ViewUtil

java.lang.Object
  extended by gov.nasa.worldwind.view.ViewUtil

public class ViewUtil
extends Object


Nested Class Summary
static class ViewUtil.ViewState
           
 
Constructor Summary
ViewUtil()
           
 
Method Summary
static double computeElevationAboveSurface(DrawContext dc, Position position)
           
static Angle computeHeading(Matrix headingPitchZoomTransform)
           
static double computeHorizonDistance(Globe globe, double elevation)
           
static ViewUtil.ViewState computeModelCoordinates(Globe globe, Matrix modelTransform, Vec4 centerPoint, Vec4 eyePoint)
           
static Matrix computeModelViewMatrix(Globe globe, Vec4 eyePoint, Vec4 centerPoint, Vec4 up)
           
static double computePerspectiveNearDistance(Angle fieldOfView, double distanceToObject)
          Computes the maximum near clip distance for a perspective projection that avoids clipping an object at a given distance from the eye point.
static double computePerspectiveNearDistance(double farDistance, double farResolution, int depthBits)
          Computes the near clip distance that corresponds to a specified far clip distance and a resolution at the far clip distance.
static Angle computePitch(Matrix transform)
           
static double computePixelSizeAtDistance(double distance, Angle fieldOfView, Rectangle viewport)
           
static Position computePosition(Globe globe, Matrix transform)
           
static Matrix computePositionTransform(Globe globe, Position center)
           
static Line computeRayFromScreenPoint(View view, double x, double y, Matrix modelview, Matrix projection, Rectangle viewport)
           
static Angle computeRoll(Matrix transform)
           
static Matrix computeTransformMatrix(Globe globe, Position position, Angle heading, Angle pitch, Angle roll)
           
static Angle computeVerticalFieldOfView(Angle horizontalFieldOfView, Rectangle viewport)
          Computes a View's vertical field-of-view given a View's horizontal field-of-view and the viewport window dimensions.
static ViewUtil.ViewState computeViewState(Globe globe, Vec4 eyePoint, Vec4 centerPoint, Vec4 up)
           
static PositionAnimator createEyePositionAnimator(View view, long timeToMove, Position begin, Position end)
           
static AngleAnimator createHeadingAnimator(View view, Angle begin, Angle end)
          Create an animator to animate heading.
static CompoundAnimator createHeadingPitchRollAnimator(View view, Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch, Angle beginRoll, Angle endRoll)
          Create an animator to animate heading, pitch, and roll.
static AngleAnimator createPitchAnimator(View view, Angle begin, Angle end)
          Create an animator to animate pitch.
static AngleAnimator createRollAnimator(View view, Angle begin, Angle end)
          Create an animator to animate roll.
static Vec4 getUpVector(Globe globe, Vec4 lookAtPoint)
           
static Position normalizedEyePosition(Position unnormalizedPosition)
           
static Angle normalizedHeading(Angle unnormalizedHeading)
           
static Angle normalizedPitch(Angle unnormalizedPitch)
           
static Angle normalizedRoll(Angle unnormalizedRoll)
           
static Vec4 project(Vec4 modelPoint, Matrix modelview, Matrix projection, Rectangle viewport)
          Transforms a point in model coordinates to a point in screen coordinates.
static Point subtract(Point a, Point b)
           
static Vec4 unProject(Vec4 windowPoint, Matrix modelview, Matrix projection, Rectangle viewport)
          Transforms a point in screen coordinates to a point in model coordinates.
static boolean validateViewState(ViewUtil.ViewState viewState)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewUtil

public ViewUtil()
Method Detail

computeElevationAboveSurface

public static double computeElevationAboveSurface(DrawContext dc,
                                                  Position position)

computeHeading

public static Angle computeHeading(Matrix headingPitchZoomTransform)

computeHorizonDistance

public static double computeHorizonDistance(Globe globe,
                                            double elevation)

computeModelCoordinates

public static ViewUtil.ViewState computeModelCoordinates(Globe globe,
                                                         Matrix modelTransform,
                                                         Vec4 centerPoint,
                                                         Vec4 eyePoint)

computeModelViewMatrix

public static Matrix computeModelViewMatrix(Globe globe,
                                            Vec4 eyePoint,
                                            Vec4 centerPoint,
                                            Vec4 up)

computePerspectiveNearDistance

public static double computePerspectiveNearDistance(Angle fieldOfView,
                                                    double distanceToObject)
Computes the maximum near clip distance for a perspective projection that avoids clipping an object at a given distance from the eye point. The given distance should specify the smallest distance between the eye and the object being viewed, but may be an approximation if an exact clip distance is not required.

Parameters:
fieldOfView - The viewport rectangle, in OpenGL screen coordinates.
distanceToObject - The distance from the perspective eye point to the nearest object, in model coordinates.
Returns:
The maximum near clip distance, in model coordinates.
Throws:
IllegalArgumentException - if the field of view is null, or if the distance is negative.

computePerspectiveNearDistance

public static double computePerspectiveNearDistance(double farDistance,
                                                    double farResolution,
                                                    int depthBits)
Computes the near clip distance that corresponds to a specified far clip distance and a resolution at the far clip distance. This returns zero if either the distance or the resolution are zero.

Parameters:
farDistance - The far clip distance, in model coordinates.
farResolution - The depth resolution at the far clip plane, in model coordinates.
depthBits - The number of bitplanes in the depth buffer. This is typically 16, 24, or 32 for OpenGL depth buffers.
Returns:
The near clip distance, in model coordinates.
Throws:
IllegalArgumentException - if either the distance or the resolution are negative, or if the depthBits is less than one.

computePitch

public static Angle computePitch(Matrix transform)

computePixelSizeAtDistance

public static double computePixelSizeAtDistance(double distance,
                                                Angle fieldOfView,
                                                Rectangle viewport)

computePosition

public static Position computePosition(Globe globe,
                                       Matrix transform)

computePositionTransform

public static Matrix computePositionTransform(Globe globe,
                                              Position center)

computeRayFromScreenPoint

public static Line computeRayFromScreenPoint(View view,
                                             double x,
                                             double y,
                                             Matrix modelview,
                                             Matrix projection,
                                             Rectangle viewport)

computeRoll

public static Angle computeRoll(Matrix transform)

computeTransformMatrix

public static Matrix computeTransformMatrix(Globe globe,
                                            Position position,
                                            Angle heading,
                                            Angle pitch,
                                            Angle roll)

computeVerticalFieldOfView

public static Angle computeVerticalFieldOfView(Angle horizontalFieldOfView,
                                               Rectangle viewport)
Computes a View's vertical field-of-view given a View's horizontal field-of-view and the viewport window dimensions.

Parameters:
horizontalFieldOfView - the angle between the view frustum's left and right clipping planes.
viewport - the viewport dimensions, in window coordinates (screen pixels).
Returns:
the angle between the view frustum's bottom and top clipping planes.
Throws:
IllegalArgumentException - if the horitontal-field-of-view is null, or if the viewport rectangle is null.

computeViewState

public static ViewUtil.ViewState computeViewState(Globe globe,
                                                  Vec4 eyePoint,
                                                  Vec4 centerPoint,
                                                  Vec4 up)

createEyePositionAnimator

public static PositionAnimator createEyePositionAnimator(View view,
                                                         long timeToMove,
                                                         Position begin,
                                                         Position end)

createHeadingAnimator

public static AngleAnimator createHeadingAnimator(View view,
                                                  Angle begin,
                                                  Angle end)
Create an animator to animate heading.

Parameters:
view - View to animate
begin - starting heading
end - final heading
Returns:
An Animator to animate heading.

createHeadingPitchRollAnimator

public static CompoundAnimator createHeadingPitchRollAnimator(View view,
                                                              Angle beginHeading,
                                                              Angle endHeading,
                                                              Angle beginPitch,
                                                              Angle endPitch,
                                                              Angle beginRoll,
                                                              Angle endRoll)
Create an animator to animate heading, pitch, and roll.

Parameters:
view - View to animate
beginHeading - staring heading
endHeading - final heading
beginPitch - starting pitch
endPitch - final pitch
beginRoll - starting roll
endRoll - final roll
Returns:
A CompoundAnimator to animate heading, pitch, and roll.

createPitchAnimator

public static AngleAnimator createPitchAnimator(View view,
                                                Angle begin,
                                                Angle end)
Create an animator to animate pitch.

Parameters:
view - View to animate
begin - starting pitch
end - final pitch
Returns:
An Animator to animate pitch.

createRollAnimator

public static AngleAnimator createRollAnimator(View view,
                                               Angle begin,
                                               Angle end)
Create an animator to animate roll.

Parameters:
view - View to animate
begin - starting roll
end - final roll
Returns:
An Animator to animate roll.

getUpVector

public static Vec4 getUpVector(Globe globe,
                               Vec4 lookAtPoint)

normalizedEyePosition

public static Position normalizedEyePosition(Position unnormalizedPosition)

normalizedHeading

public static Angle normalizedHeading(Angle unnormalizedHeading)

normalizedPitch

public static Angle normalizedPitch(Angle unnormalizedPitch)

normalizedRoll

public static Angle normalizedRoll(Angle unnormalizedRoll)

project

public static Vec4 project(Vec4 modelPoint,
                           Matrix modelview,
                           Matrix projection,
                           Rectangle viewport)
Transforms a point in model coordinates to a point in screen coordinates. The returned x and y coordinates are relative to the screen's lower left hand screen corner, and the returned z coordinate defines the point's depth in screen coordinates (in the range [0, 1]). This returns null if the specified combination of modelview matrix, projection matrix, and viewport cannot produce a transformation.

Parameters:
modelPoint - the point in model coordinates to transform into window coordinates.
modelview - the modelview matrix.
projection - the projection matrix.
viewport - the viewport rectangle.
Returns:
the point in window coordinates, or null if the point cannot be transformed.
Throws:
IllegalArgumentException - if any of the model point, modelview matrix, projection matrix, or viewport rectangle are null.

subtract

public static Point subtract(Point a,
                             Point b)

unProject

public static Vec4 unProject(Vec4 windowPoint,
                             Matrix modelview,
                             Matrix projection,
                             Rectangle viewport)
Transforms a point in screen coordinates to a point in model coordinates. The input x and y are relative to the screen's lower left hand screen corner, while the z-value denotes the point's depth in screen coordinates (in the range [0, 1]). This returns null if the specified combination of modelview matrix, projection matrix, and viewport cannot produce a transformation.

Parameters:
windowPoint - the point in screen coordinates to transform into model coordinates.
modelview - the modelview matrix.
projection - the projection matrix.
viewport - the viewport rectangle.
Returns:
the point in model coordinates, or null if the point cannot be transformed.
Throws:
IllegalArgumentException - if any of the model point, modelview matrix, projection matrix, or viewport rectangle are null.

validateViewState

public static boolean validateViewState(ViewUtil.ViewState viewState)

NASA World Wind