TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nasaworldwind/worldwindjava/llms.txt
Use this file to discover all available pages before exploring further.
gov.nasa.worldwind.geom package provides the foundational geometric primitives used throughout the WorldWind Java SDK. All of the core types — Angle, LatLon, Position, Sector, Vec4, Matrix, Line, Extent, and Intersection — are immutable value objects, making them safe to share across threads and ideal for use in rendering pipelines, spatial queries, and terrain calculations. Understanding these types is essential before working with globes, layers, or any spatial operation in WorldWind.
Angle
gov.nasa.worldwind.geom.Angle represents an immutable geometric angle stored internally as both degrees and radians. Because both representations are precomputed at construction time, switching between them incurs no runtime cost.
Factory Methods
| Method | Description |
|---|---|
Angle.fromDegrees(double degrees) | Creates an Angle from a value in degrees |
Angle.fromRadians(double radians) | Creates an Angle from a value in radians |
Angle.fromDMS(int degrees, int minutes, int seconds) | Creates an Angle from integer degrees, minutes, and seconds |
Angle.fromDMdS(int degrees, double minutes) | Creates an Angle from integer degrees and decimal minutes |
Angle.fromDMS(String dmsString) | Parses a DMS-formatted string such as "45 12 30 N" |
Angle.fromXY(double x, double y) | Creates an angle using atan2(y, x) |
Angle.fromDegreesLatitude(double degrees) | Creates a latitude-clamped angle (−90 to +90) |
Angle.fromDegreesLongitude(double degrees) | Creates a longitude-clamped angle (−180 to +180) |
Key Accessors
Reading Angle values
Arithmetic
All arithmetic methods return a newAngle — the original is never modified.
| Method | Signature | Description |
|---|---|---|
add | Angle add(Angle angle) | Returns the sum of this angle and another |
subtract | Angle subtract(Angle angle) | Returns this angle minus another |
multiply | Angle multiply(double multiplier) | Scales this angle by a scalar |
divide | Angle divide(double divisor) | Divides this angle by a scalar |
divide | double divide(Angle angle) | Returns this angle’s degrees divided by another’s degrees |
addDegrees | Angle addDegrees(double degrees) | Adds a raw degree value |
subtractDegrees | Angle subtractDegrees(double degrees) | Subtracts a raw degree value |
angularDistanceTo | Angle angularDistanceTo(Angle angle) | Shortest angular distance between two angles (handles wrap-around) |
Trigonometry
Trigonometric convenience methods
Constants
| Constant | Value |
|---|---|
Angle.ZERO | 0° |
Angle.POS90 | +90° |
Angle.NEG90 | −90° |
Angle.POS180 | +180° |
Angle.NEG180 | −180° |
Angle.POS360 | +360° |
Angle.MINUTE | 1/60° |
Angle.SECOND | 1/3600° |
Normalization and Utilities
Normalization helpers
Angle.fromDMS(int, int, int) requires that degrees >= 0 and 0 <= minutes < 60 and 0 <= seconds < 60. For negative angles, multiply the result: Angle.fromDMS(45, 12, 30).multiply(-1).LatLon
gov.nasa.worldwind.geom.LatLon is an immutable pair of Angle values representing a geographic location on the surface of a globe. Latitude ranges from −90° to +90° (south to north), and longitude from −180° to +180° (west to east).
Factory Methods and Fields
Creating LatLon instances
Distance Methods
All distance methods use a spherical model (not ellipsoidal). Multiply the returned angular distance by the globe radius (meters) to get a meter-distance.| Method | Signature | Description |
|---|---|---|
greatCircleDistance | static Angle greatCircleDistance(LatLon p1, LatLon p2) | Angular distance along the great circle (Haversine formula) |
rhumbDistance | static Angle rhumbDistance(LatLon p1, LatLon p2) | Angular distance along a rhumb (constant-heading) line |
linearDistance | static Angle linearDistance(LatLon p1, LatLon p2) | Simple Euclidean angular distance treating lat/lon as 2D |
pathDistance | static Angle pathDistance(String pathType, LatLon p1, LatLon p2) | Distance using AVKey.GREAT_CIRCLE, RHUMB_LINE, or default |
ellipsoidalDistance | static double ellipsoidalDistance(LatLon p1, LatLon p2, double equatorialRadius, double polarRadius) | Vincenty iterative distance in meters |
Computing great-circle distance in meters
Azimuth and End-Position
Great circle arc and rhumb navigation
Interpolation
Interpolating along paths
Constant
| Constant | Value |
|---|---|
LatLon.ZERO | (0°, 0°) — origin, where the prime meridian meets the equator |
Position
gov.nasa.worldwind.geom.Position extends LatLon by adding an elevation component (in meters above or below mean sea level). It is the standard type for specifying 3D positions in WorldWind.
Factory Methods and Fields
Creating Position instances
Interpolation
Elevation is always interpolated linearly, regardless of the path type used for the lat/lon component.Interpolating 3D positions
Arithmetic
Adding and subtracting positions
Constant
| Constant | Value |
|---|---|
Position.ZERO | (0°, 0°, 0.0) |
Position.fromDegrees(double lat, double lon) without elevation defaults the elevation to 0.0. This is equivalent to a surface position at sea level.Sector
gov.nasa.worldwind.geom.Sector represents an immutable axis-aligned bounding rectangle on the surface of a globe, defined by minimum/maximum latitude and minimum/maximum longitude. It implements Cacheable and Comparable<Sector> and also implements Iterable<LatLon> (iterating over its four corner vertices).
Factory Methods
Creating Sector instances
Accessors
| Method | Return Type | Description |
|---|---|---|
getMinLatitude() | Angle | Southern boundary |
getMaxLatitude() | Angle | Northern boundary |
getMinLongitude() | Angle | Western boundary |
getMaxLongitude() | Angle | Eastern boundary |
getDeltaLat() | Angle | Latitudinal extent |
getDeltaLon() | Angle | Longitudinal extent |
getDeltaLatDegrees() | double | Latitudinal extent in degrees |
getDeltaLonDegrees() | double | Longitudinal extent in degrees |
Spatial Operations
Sector spatial queries
Subdivision
Subdividing a Sector
Center
Getting the center of a Sector
Constants
| Constant | Value |
|---|---|
Sector.FULL_SPHERE | (−90°, +90°, −180°, +180°) — the entire globe |
Sector.EMPTY_SECTOR | (0°, 0°, 0°, 0°) — degenerate zero-area sector |
Vec4
gov.nasa.worldwind.geom.Vec4 is an immutable 4-component vector with public double fields x, y, z, and w. It is used for Cartesian 3D points, directions, and homogeneous coordinates in OpenGL-style transformations. The default w component is 1.0 for points and 0.0 for directions/normals.
Construction
Creating Vec4 instances
Arithmetic Operations
All methods operate on the 3-component (x, y, z) subspace; thew component is handled separately.
| Method | Signature | Description |
|---|---|---|
add3 | Vec4 add3(Vec4 vec4) | Component-wise addition of x, y, z |
add3 | Vec4 add3(double x, double y, double z) | Add raw components |
subtract3 | Vec4 subtract3(Vec4 vec4) | Component-wise subtraction |
subtract3 | Vec4 subtract3(double x, double y, double z) | Subtract raw components |
dot3 | double dot3(Vec4 vec4) | Dot product of the x, y, z components |
cross3 | Vec4 cross3(Vec4 vec4) | Cross product (returns direction vector with w=0) |
normalize3 | Vec4 normalize3() | Unit vector in the same direction |
getLength3 | double getLength3() | Euclidean length of the x, y, z components |
distanceTo3 | double distanceTo3(Vec4 vec4) | Euclidean distance between two points |
Vec4 vector operations
Predefined Constants
| Constant | Value |
|---|---|
Vec4.ZERO | (0, 0, 0, 1) |
Vec4.ONE | (1, 1, 1, 1) |
Vec4.UNIT_X | (1, 0, 0, 0) |
Vec4.UNIT_Y | (0, 1, 0, 0) |
Vec4.UNIT_Z | (0, 0, 1, 0) |
Vec4.UNIT_NEGATIVE_X | (-1, 0, 0, 0) |
Vec4.INFINITY | (+∞, +∞, +∞, 0) |
Matrix
gov.nasa.worldwind.geom.Matrix is an immutable 4×4 row-major transformation matrix. Its 16 components are exposed as public double fields named m11 through m44. It is used for affine transformations, model/view/projection matrices, and coordinate-system transforms.
Factory Methods
Constructing Matrix instances
Multiplication and Inverse
Multiplying and inverting matrices
Extracting Rotation Angles
Decomposing a rotation matrix
Surface Orientation
Computing a local coordinate frame on the globe surface
Line
gov.nasa.worldwind.geom.Line is an immutable ray defined by an origin point (Vec4) and a direction vector (Vec4). It models a ray with infinite extent in the positive direction and is used primarily for picking, intersection tests, and terrain queries.
Construction
Creating Line instances
Accessors and Point Evaluation
Querying a Line
Nearest-Point Calculations
| Method | Signature | Description |
|---|---|---|
nearestPointTo | Vec4 nearestPointTo(Vec4 p) | Closest point on this ray to an arbitrary point p |
nearestPointOnSegment | static Vec4 nearestPointOnSegment(Vec4 p0, Vec4 p1, Vec4 p) | Closest point on a finite segment [p0, p1] to point p |
nearestIntersectionPoint | Vec4 nearestIntersectionPoint(Intersection[] intersections) | Among multiple intersections, returns the closest to the ray origin |
Finding the nearest intersection
Line has no intersectWithTriangle method directly. Triangle-ray intersections are handled by Globe.intersect(Triangle, double) and by HighResolutionTerrain, which tests against the tessellated terrain mesh. The Line class itself provides the ray and nearest-point utilities.Extent and Intersection
Extent
gov.nasa.worldwind.geom.Extent is an interface representing a volume that encloses one or more objects. Implementations include Sphere, Box, and Cylinder. It is primarily used for visibility culling (frustum tests) and ray intersection tests.
Key Methods
| Method | Signature | Description |
|---|---|---|
getCenter | Vec4 getCenter() | Center of the bounding volume |
getRadius | double getRadius() | Bounding radius |
getDiameter | double getDiameter() | Bounding diameter |
intersects(Frustum) | boolean intersects(Frustum frustum) | Tests if this extent overlaps a view frustum |
intersects(Line) | boolean intersects(Line line) | Tests if an infinite line passes through this volume |
intersect(Line) | Intersection[] intersect(Line line) | Returns all intersection points with a line |
intersects(Plane) | boolean intersects(Plane plane) | Tests if a plane cuts this volume |
getEffectiveRadius(Plane) | double getEffectiveRadius(Plane plane) | Effective extent radius relative to a plane |
getProjectedArea(View) | double getProjectedArea(View view) | Screen-space projected area (pixels²) |
Using Extent for frustum culling
Intersection
gov.nasa.worldwind.geom.Intersection is an immutable record of a single intersection point between a ray (or line) and a surface. It carries the Cartesian point, an optional Position, a tangency flag, and an optional parametric distance along the intersecting geometry.
Constructors
Intersection constructors
Key Methods
| Method | Return Type | Description |
|---|---|---|
getIntersectionPoint() | Vec4 | The Cartesian intersection point |
getIntersectionPosition() | Position | The geographic position (if set) |
getIntersectionLength() | Double | Parametric distance along the intersecting line (may be null) |
isTangent() | boolean | True if the ray is tangent to the surface at this point |
getObject() | Object | Associated renderable or data object |
setIntersectionPosition(Position) | void | Set the geographic position after creation |
sort(Vec4, List, List) | static Queue<Intersection> | Merge and sort two intersection lists by distance from a reference point |
Working with terrain intersections