physics3d
Class Sphere

java.lang.Object
  extended by physics3d.Sphere
All Implemented Interfaces:
PhysicsShape

public class Sphere
extends Object
implements PhysicsShape

Sphere represents a sphere in 3 space

Specification Fields

Constructor Summary
Sphere(double cx, double cy, double cz, double r, String texture)
           
Sphere(Vect3 center, double r)
           
Sphere(Vect3 center, double r, String texture)
           
 
Method Summary
 boolean containsPoint(Vect3 p)
           
 Vect3 getCenter()
           
 double getRadius()
           
 ShapeClassification getShapeClassification()
           
 String getTexture()
           
 double minDistanceToObjectFromP(Vect3 p)
           
 Sphere rotateAboutCwithAxisAandAngleT(Vect3 center, Vect3 axis, Angle tAngle)
           
 String toString()
           
 Sphere translateByT(Vect3 t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sphere

public Sphere(Vect3 center,
              double r,
              String texture)
Parameters:
center - the center point of the circle
r - the radius of the circle
Requires:
r >= 0, center != null, texture != null
Effects:
Creates a new circle with the specified size and location.

Sphere

public Sphere(Vect3 center,
              double r)
Parameters:
center - the center point of the circle
r - the radius of the circle
Requires:
r >= 0, center != null
Effects:
Creates a new circle with the specified size and location.

Sphere

public Sphere(double cx,
              double cy,
              double cz,
              double r,
              String texture)
Parameters:
cx - the x coordinate of the center point of the circle
cy - the y coordinate of the center point of the circle
cz - the z coordinate of the center point of the circle
r - the radius of the circle
Requires:
r >= 0
Effects:
Creates a new circle with the specified size and location.
Method Detail

getCenter

public Vect3 getCenter()
Returns:
the center point of this circle.

getRadius

public double getRadius()
Returns:
the radius of this circle.

getTexture

public String getTexture()
Returns:
texture of this object

containsPoint

public boolean containsPoint(Vect3 p)
Specified by:
containsPoint in interface PhysicsShape
Returns:
true if Vect3.isAbout(this.minDistanceToObjectFromP(p),0), false otherwise
Requires:
p != null

minDistanceToObjectFromP

public double minDistanceToObjectFromP(Vect3 p)
Specified by:
minDistanceToObjectFromP in interface PhysicsShape
Returns:
the minimum distance between p and this
Requires:
p is not null

rotateAboutCwithAxisAandAngleT

public Sphere rotateAboutCwithAxisAandAngleT(Vect3 center,
                                             Vect3 axis,
                                             Angle tAngle)
Specified by:
rotateAboutCwithAxisAandAngleT in interface PhysicsShape
Returns:
A Sphere rotated about the line created by center and axis counterclockwise by an amount tAngle with same texture.
Requires:
center != null, axis != null, axis.rho() > 0, tAngle != null.

translateByT

public Sphere translateByT(Vect3 t)
Specified by:
translateByT in interface PhysicsShape
Returns:
A Sphere translated by t with same texture
Requires:
t != null

toString

public String toString()
Overrides:
toString in class Object

getShapeClassification

public ShapeClassification getShapeClassification()
Specified by:
getShapeClassification in interface PhysicsShape