Overview | Package | Class | Use | Tree | Index | Help
| NASA World Wind
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gov.nasa.worldwind.geom
Class Sphere

    java.lang.Object
      gov.nasa.worldwind.geom.Sphere

All Implemented Interfaces:
  Extent, Renderable

    public final class Sphere

extends Object
implements Extent, Renderable

Represents a sphere in three dimensional space.

Instances of `Sphere` are immutable.

Field Summary
`static Sphere` | `UNIT_SPHERE`

Constructor Summary
`Sphere(Point center, double radius)` Creates a new `Sphere` from a given center and radius.

Method Summary
`static Sphere` | `createBoundingSphere(Point[] points)` Creates a sphere that completely contains a set of points.
`boolean` | `equals(Object o)`
`Point` | `getCenter()` Obtains the center of this `Sphere`.
`double` | `getDiameter()` Obtains the diameter of this `Sphere`.
`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)` tests for intersetion with a `Frustum`.
`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.
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### UNIT_SPHERE

    public static final Sphere UNIT_SPHERE

Constructor Detail

### Sphere

    public Sphere(Point center,
                  double radius)

  Creates a new `Sphere` from a given center and radius. `radius` must be positive (that is, greater than zero), and `center` may not be null.

  Parameters:
    `center` - the center of the new sphere
    `radius` - the radius of the new sphere
  Throws:
    `IllegalArgumentException` - if `center` is null or if `radius` is non-positive

Method Detail

### createBoundingSphere

    public static Sphere createBoundingSphere(Point[] points)

  Creates a sphere that completely contains a set of points.

  Parameters:
    `points` - the `Point`s to be enclosed by the new Sphere
  Returns:
    a `Sphere` encompassing the given array of `Point`s
  Throws:
    `IllegalArgumentException` - if `points` is null or empty

### equals

    public boolean equals(Object o)

  Overrides:
    `equals` in class `Object`

### getCenter

    public final Point getCenter()

  Obtains the center of this `Sphere`.

  Specified by:
    `getCenter` in interface `Extent`
  Returns:
    the `Point` situated at the center of this `Sphere`

### getDiameter

    public final double getDiameter()

  Obtains the diameter of this `Sphere`. The diameter is twice the radius.

  Specified by:
    `getDiameter` in interface `Extent`
  Returns:
    the diameter of this `Sphere`

### getRadius

    public final double getRadius()

  Obtains the radius of this `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`.

  Specified by:
    `getRadius` in interface `Extent`
  Returns:
    the radius of this sphere

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### intersect

    public final Intersection[] intersect(Line line)

  Obtains the intersections of this sphere with a line. The returned array may be either null or of zero length if no intersections are discovered. It does not contain null elements and will have a size of 2 at most. Tangential intersections are marked as such. `line` is considered to have infinite length in both directions.

  Specified by:
    `intersect` in interface `Extent`
  Parameters:
    `line` - the `Line` with which to intersect this `Sphere`
  Returns:
    an array containing all the intersections of this `Sphere` and `line`
  Throws:
    `IllegalArgumentException` - if `line` is null

### intersects

    public boolean intersects(Frustum frustum)

  tests for intersetion with a `Frustum`. This operation is commutative, so `someSphere.intersects(frustum)` and `frustum.intersects(someSphere)` are equivalent.

  Specified by:
    `intersects` in interface `Extent`
  Parameters:
    `frustum` - the `Frustum` with which to test for intersection
  Returns:
    true if either `frustum` or this `Sphere` wholly or partially contain the other, false otherwise.
  Throws:
    `IllegalArgumentException` - if `frustum` is null

### intersects

    public boolean intersects(Line line)

  Tests for intersection with a `Line`.

  Specified by:
    `intersects` in interface `Extent`
  Parameters:
    `line` - the `Line` with which to test for intersection
  Returns:
    true if `line` intersects or makes a tangent with the surface of this `Sphere`
  Throws:
    `IllegalArgumentException` - if `line` is null

### intersects

    public boolean intersects(Plane plane)

  Tests for intersection with a `Plane`.

  Specified by:
    `intersects` in interface `Extent`
  Parameters:
    `plane` - the `Plane` with which to test for intersection
  Returns:
    true if `plane` intersects or makes a tangent with the surface of this `Sphere`
  Throws:
    `IllegalArgumentException` - if `plane` is null

### render

    public void render(DrawContext dc)

  Causes this `Sphere` to render itself using the `DrawContext` provided. `dc` may not be null.

  Specified by:
    `render` in interface `Renderable`
  Parameters:
    `dc` - the `DrawContext` to be used
  Throws:
    `IllegalArgumentException` - if `dc` is null
  See Also:
    `DrawContext`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Index | Help
| NASA World Wind
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD