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 classViewUtil.ViewState
-
Constructor Summary
Constructors Constructor Description ViewUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublecomputeElevationAboveSurface(DrawContext dc, Position position)static AnglecomputeHeading(Matrix headingPitchZoomTransform)static doublecomputeHorizonDistance(Globe globe, double elevation)static ViewUtil.ViewStatecomputeModelCoordinates(Globe globe, Matrix modelTransform, Vec4 centerPoint, Vec4 eyePoint)static MatrixcomputeModelViewMatrix(Globe globe, Vec4 eyePoint, Vec4 centerPoint, Vec4 up)static doublecomputePerspectiveNearDistance(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 doublecomputePerspectiveNearDistance(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 AnglecomputePitch(Matrix transform)static doublecomputePixelSizeAtDistance(double distance, Angle fieldOfView, java.awt.Rectangle viewport)static PositioncomputePosition(Globe globe, Matrix transform)static MatrixcomputePositionTransform(Globe globe, Position center)static LinecomputeRayFromScreenPoint(View view, double x, double y, Matrix modelview, Matrix projection, java.awt.Rectangle viewport)static AnglecomputeRoll(Matrix transform)static MatrixcomputeTransformMatrix(Globe globe, Position position, Angle heading, Angle pitch, Angle roll)static AnglecomputeVerticalFieldOfView(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.ViewStatecomputeViewState(Globe globe, Vec4 eyePoint, Vec4 centerPoint, Vec4 up)static PositionAnimatorcreateEyePositionAnimator(View view, long timeToMove, Position begin, Position end)static AngleAnimatorcreateHeadingAnimator(View view, Angle begin, Angle end)Create an animator to animate heading.static CompoundAnimatorcreateHeadingPitchRollAnimator(View view, Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch, Angle beginRoll, Angle endRoll)Create an animator to animate heading, pitch, and roll.static AngleAnimatorcreatePitchAnimator(View view, Angle begin, Angle end)Create an animator to animate pitch.static AngleAnimatorcreateRollAnimator(View view, Angle begin, Angle end)Create an animator to animate roll.static Vec4getUpVector(Globe globe, Vec4 lookAtPoint)static PositionnormalizedEyePosition(Position unnormalizedPosition)static AnglenormalizedHeading(Angle unnormalizedHeading)static AnglenormalizedPitch(Angle unnormalizedPitch)static AnglenormalizedRoll(Angle unnormalizedRoll)static Vec4project(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.Pointsubtract(java.awt.Point a, java.awt.Point b)static Vec4unProject(Vec4 windowPoint, Matrix modelview, Matrix projection, java.awt.Rectangle viewport)Transforms a point in screen coordinates to a point in model coordinates.static booleanvalidateViewState(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.
-
-