physics3d
Class Sphere
java.lang.Object
physics3d.Sphere
- All Implemented Interfaces:
- PhysicsShape
public class Sphere
- extends Object
- implements PhysicsShape
Sphere represents a sphere in 3 space
- Specification Fields
-
-
centerPoint
: Vect3 // point of center of sphere
-
radius
: double // radius of sphere
-
texture
: String // texture of this object
Sphere
public Sphere(Vect3 center,
double r,
String texture)
- Parameters:
center
- the center point of the circler
- 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 circler
- 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 circlecy
- the y coordinate of the center point of the circlecz
- the z coordinate of the center point of the circler
- the radius of the circle- Requires:
r
>= 0
- Effects:
- Creates a new circle with the specified size and location.
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