Class Sphere

java.lang.Object
  extended by Shape
      extended by Sphere
All Implemented Interfaces:
CloneableEx, java.lang.Cloneable, Persistent

public class Sphere
extends Shape

A class representing a sphere. A sphere is specified by an origin and a radius.


Constructor Summary
Sphere()
          Constructs the unit sphere at the origin.
Sphere(javax.vecmath.Vector3d origin, double radius, SurfaceProperties sp)
          Constructs a sphere with the specified parameters.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of the object.
 javax.vecmath.Point3d getOrigin()
          Returns the sphere's origin.
 double getRadius()
          Returns the sphere's radius.
 void load(DataParser dataParser)
          Loads data using the DataParser object.
 double nearestIntersectionTime(Ray3d ray)
          Gets the nearest intersection time between the specified ray and the shape.
 void setOrigin(javax.vecmath.Point3d origin)
          Sets the sphere's origin.
 void setRadius(double radius)
          Sets the sphere's radius.
 javax.vecmath.Vector3d surfaceNormal(javax.vecmath.Point3d point)
          Gets the surface normal at the specified point on the shape.
 
Methods inherited from class Shape
getSurfaceProperties, setSurfaceProperties
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sphere

public Sphere()
Constructs the unit sphere at the origin.


Sphere

public Sphere(javax.vecmath.Vector3d origin,
              double radius,
              SurfaceProperties sp)
Constructs a sphere with the specified parameters.

Parameters:
origin - The origin of the sphere.
radius - The radius of the sphere.
sp - The surface properties of the sphere.
Method Detail

clone

public java.lang.Object clone()
Description copied from interface: CloneableEx
Returns a copy of the object.

Specified by:
clone in interface CloneableEx
Specified by:
clone in class Shape
Returns:
A copy of the object.

nearestIntersectionTime

public double nearestIntersectionTime(Ray3d ray)
Description copied from class: Shape
Gets the nearest intersection time between the specified ray and the shape.

Specified by:
nearestIntersectionTime in class Shape
Parameters:
ray - The ray to intersect with the shape.
Returns:
The nearest time of intersection.

surfaceNormal

public javax.vecmath.Vector3d surfaceNormal(javax.vecmath.Point3d point)
Description copied from class: Shape
Gets the surface normal at the specified point on the shape.

Specified by:
surfaceNormal in class Shape
Parameters:
point - The point on the surface of the shape.
Returns:
The surface normal of the point on the shape.

load

public void load(DataParser dataParser)
Description copied from interface: Persistent
Loads data using the DataParser object.

A class overrides this function to load data that has been parsed.

Specified by:
load in interface Persistent
Overrides:
load in class Shape
Parameters:
dataParser - The DataParser to load data from.

setOrigin

public void setOrigin(javax.vecmath.Point3d origin)
Sets the sphere's origin.

Parameters:
origin - The origin to set.

getOrigin

public javax.vecmath.Point3d getOrigin()
Returns the sphere's origin.

Returns:
The sphere's origin.

setRadius

public void setRadius(double radius)
Sets the sphere's radius.

Parameters:
radius - The radius to set.

getRadius

public double getRadius()
Returns the sphere's radius.

Returns:
The sphere's radius.