public final class Sphere extends java.lang.Object implements Extent, Renderable
Sphere
are immutable. Modifier and Type | Field and Description |
---|---|
protected Vec4 |
center |
protected double |
radius |
static Sphere |
UNIT_SPHERE |
Constructor and Description |
---|
Sphere(Vec4 center,
double radius)
Creates a new
Sphere from a given center and radius. |
Modifier and Type | Method and Description |
---|---|
static Sphere |
createBoundingSphere(BufferWrapper buffer)
Creates a sphere that completely contains a set of points.
|
static Sphere |
createBoundingSphere(java.lang.Iterable<? extends Extent> extents)
Creates a sphere that completely contains a set of Extents.
|
static Sphere |
createBoundingSphere(Vec4[] points)
Creates a sphere that completely contains a set of points.
|
boolean |
equals(java.lang.Object o) |
Vec4 |
getCenter()
Obtains the center of this
Sphere . |
double |
getDiameter()
Obtains the diameter of this
Sphere . |
double |
getEffectiveRadius(Plane plane)
Computes the effective radius of the extent relative to a specified plane.
|
Vec4 |
getPointOnSphere(LatLon location)
Computes a point on the sphere corresponding to a specified location.
|
double |
getProjectedArea(View view)
Computes the area in square pixels of this
Extent after it is projected into the specified
view's viewport. |
double |
getRadius()
Obtains the radius of this
Sphere . |
int |
hashCode() |
Intersection[] |
intersect(Line line)
Obtains the intersections of this sphere with a line.
|
boolean |
intersects(Frustum frustum)
Indicates whether a specified
Frustum intersects this sphere. |
boolean |
intersects(Line line)
Tests for intersection with a
Line . |
boolean |
intersects(Plane plane)
Tests for intersection with a
Plane . |
void |
render(DrawContext dc)
Causes this
Sphere to render itself using the DrawContext provided. |
java.lang.String |
toString() |
protected final Vec4 center
protected final double radius
public static final Sphere UNIT_SPHERE
public Sphere(Vec4 center, double radius)
Sphere
from a given center and radius. radius
must be positive (that is,
greater than zero), and center
may not be null.center
- the center of the new sphereradius
- the radius of the new spherejava.lang.IllegalArgumentException
- if center
is null or if radius
is non-positivepublic static Sphere createBoundingSphere(BufferWrapper buffer)
buffer
- the Cartesian coordinates to be enclosed by the new Sphere.Sphere
encompassing the given coordinates.java.lang.IllegalArgumentException
- if buffer
is null or contains fewer than three values.public static Sphere createBoundingSphere(java.lang.Iterable<? extends Extent> extents)
extents
- the extends to be enclosed by the new Sphere.java.lang.IllegalArgumentException
- if the Iterable is null.public static Sphere createBoundingSphere(Vec4[] points)
points
- the Vec4
s to be enclosed by the new SphereSphere
encompassing the given array of Vec4
sjava.lang.IllegalArgumentException
- if points
is null or emptypublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public final Vec4 getCenter()
Sphere
.public final double getDiameter()
Sphere
. The diameter is twice the radius.getDiameter
in interface Extent
Sphere
public double getEffectiveRadius(Plane plane)
getEffectiveRadius
in interface Extent
plane
- the plane.public Vec4 getPointOnSphere(LatLon location)
location
- the location to compute the point for.java.lang.IllegalArgumentException
- if the location is null.public double getProjectedArea(View view)
Extent
after it is projected into the specified
view's
viewport. The returned value is the screen area that this Extent
covers in the
infinite plane defined by the view's
viewport. This area is not limited to the size of the
view's
viewport, and portions of this Extent
are not clipped by the view's
frustum.
This returns Double.POSITIVE_INFINITY
if the view's
eye point is inside this
Extent
, or if any portion of this Extent
is behind the eye point. In either case, this
Extent
has no finite projection on the view
.getProjectedArea
in interface Extent
view
- the View
for which to compute a projected screen area.Extent
in square pixels, or
Double.POSITIVE_INFINITY
if the view's
eye point is inside this
Extent
or part of this Extent
is behind the view's
eye point.public final double getRadius()
Sphere
. The radus is the distance from the center to the surface. If an
object's distance to this sphere's center is less than or equal to the radius, then that object is at least
partially within this Sphere
.public int hashCode()
hashCode
in class java.lang.Object
public final Intersection[] intersect(Line line)
line
is considered to have infinite length in both directions.public final boolean intersects(Frustum frustum)
Frustum
intersects this sphere.intersects
in interface Extent
frustum
- the frustum to test.java.lang.IllegalArgumentException
- if the frustum is null.public boolean intersects(Line line)
Line
.intersects
in interface Extent
line
- the Line
with which to test for intersectionline
intersects or makes a tangent with the surface of this Sphere
java.lang.IllegalArgumentException
- if line
is nullpublic boolean intersects(Plane plane)
Plane
.intersects
in interface Extent
plane
- the Plane
with which to test for intersectionplane
intersects or makes a tangent with the surface of this Sphere
java.lang.IllegalArgumentException
- if plane
is nullpublic void render(DrawContext dc)
Sphere
to render itself using the DrawContext
provided. dc
may
not be null.render
in interface Renderable
dc
- the DrawContext
to be usedjava.lang.IllegalArgumentException
- if dc
is nullDrawContext
public java.lang.String toString()
toString
in class java.lang.Object