Package gov.nasa.worldwind.view
Class ViewUtil
- java.lang.Object
-
- gov.nasa.worldwind.view.ViewUtil
-
public class ViewUtil extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ViewUtil.ViewState
-
Constructor Summary
Constructors Constructor Description ViewUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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(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 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 Angle
computePitch(Matrix transform)
static double
computePixelSizeAtDistance(double distance, Angle fieldOfView, java.awt.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, java.awt.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, java.awt.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, java.awt.Rectangle viewport)
Transforms a point in model coordinates to a point in screen coordinates.static java.awt.Point
subtract(java.awt.Point a, java.awt.Point b)
static Vec4
unProject(Vec4 windowPoint, Matrix modelview, Matrix projection, java.awt.Rectangle viewport)
Transforms a point in screen coordinates to a point in model coordinates.static boolean
validateViewState(ViewUtil.ViewState viewState)
-
-
-
Method Detail
-
createHeadingAnimator
public static AngleAnimator createHeadingAnimator(View view, Angle begin, Angle end)
Create an animator to animate heading.- Parameters:
view
- View to animatebegin
- starting headingend
- final heading- Returns:
- An Animator to animate heading.
-
createPitchAnimator
public static AngleAnimator createPitchAnimator(View view, Angle begin, Angle end)
Create an animator to animate pitch.- Parameters:
view
- View to animatebegin
- starting pitchend
- 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 animatebegin
- starting rollend
- final roll- Returns:
- An Animator to animate roll.
-
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 animatebeginHeading
- staring headingendHeading
- final headingbeginPitch
- starting pitchendPitch
- final pitchbeginRoll
- starting rollendRoll
- final roll- Returns:
- A CompoundAnimator to animate heading, pitch, and roll.
-
createEyePositionAnimator
public static PositionAnimator createEyePositionAnimator(View view, long timeToMove, Position begin, Position end)
-
subtract
public static java.awt.Point subtract(java.awt.Point a, java.awt.Point b)
-
computeTransformMatrix
public static Matrix computeTransformMatrix(Globe globe, Position position, Angle heading, Angle pitch, Angle roll)
-
computePositionTransform
public static Matrix computePositionTransform(Globe globe, Position center)
-
computeModelViewMatrix
public static Matrix computeModelViewMatrix(Globe globe, Vec4 eyePoint, Vec4 centerPoint, Vec4 up)
-
computeViewState
public static ViewUtil.ViewState computeViewState(Globe globe, Vec4 eyePoint, Vec4 centerPoint, Vec4 up)
-
computeModelCoordinates
public static ViewUtil.ViewState computeModelCoordinates(Globe globe, Matrix modelTransform, Vec4 centerPoint, Vec4 eyePoint)
-
validateViewState
public static boolean validateViewState(ViewUtil.ViewState viewState)
-
computeRayFromScreenPoint
public static Line computeRayFromScreenPoint(View view, double x, double y, Matrix modelview, Matrix projection, java.awt.Rectangle viewport)
-
computePixelSizeAtDistance
public static double computePixelSizeAtDistance(double distance, Angle fieldOfView, java.awt.Rectangle viewport)
-
computeHorizonDistance
public static double computeHorizonDistance(Globe globe, double elevation)
-
computeVerticalFieldOfView
public static Angle computeVerticalFieldOfView(Angle horizontalFieldOfView, java.awt.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:
java.lang.IllegalArgumentException
- if the horitontal-field-of-view is null, or if the viewport rectangle is null.
-
computeElevationAboveSurface
public static double computeElevationAboveSurface(DrawContext dc, Position position)
-
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:
java.lang.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:
java.lang.IllegalArgumentException
- if either the distance or the resolution are negative, or if the depthBits is less than one.
-
project
public static Vec4 project(Vec4 modelPoint, Matrix modelview, Matrix projection, java.awt.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:
java.lang.IllegalArgumentException
- if any of the model point, modelview matrix, projection matrix, or viewport rectangle are null.
-
unProject
public static Vec4 unProject(Vec4 windowPoint, Matrix modelview, Matrix projection, java.awt.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:
java.lang.IllegalArgumentException
- if any of the model point, modelview matrix, projection matrix, or viewport rectangle are null.
-
-