Sphere
Package Class Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD Class Sphere
java.lang.Object
|
+--Object
|
+--Sphere
public class Sphere extends Object Sphere represents a spherical object Field Summary Point Centre Holds the point that defines the sphere centre double Radius Holds the radius of the sphere Fields inherited from class Object SurfaceMaterial Constructor Summary Sphere() Create a default sphere Sphere(Material n, Point p, double r) Create a sphere with the given material, centre and radius Note values are referenced not copied in the new object Method Summary double intersect(Ray ray) Find the intersection of the plane and a given ray. Vector normal(Point p) Find the normal of an object at the given point on its surface. void print(SceneWriter os) Print a human readable version of the sphere definition to the given destination void read(SceneReader is) Read the sphere from the given source void write(SceneWriter os) Write the sphere to the given destination Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Field Detail Centre
public Point Centre Holds the point that defines the sphere centre Radius
public double Radius Holds the radius of the sphere Constructor Detail Sphere
public Sphere() Create a default sphere Sphere
public Sphere(Material n,
Point p,
double r) Create a sphere with the given material, centre and radius Note values are referenced not copied in the new object Parameters: n - the material for the plane p - the centre of the sphere r - the radius of the sphere Method Detail normal
public Vector normal(Point p) Find the normal of an object at the given point on its surface. Note that a new Vector is created on each call. Specified by: normal in class Object Parameters: p - the surface point to find the normal at Returns: a reference to the fixed normal of the plane intersect
public double intersect(Ray ray) Find the intersection of the plane and a given ray. The return value is positive is the intersection is found and this value gives the distance along the ray. Negative values imply that the intersection was either not successful or the intersection point was before the origin. This value can be used with the pointAt method of the Ray class (@see Ray#pointAt) Specified by: intersect in class Object Parameters: ray - the ray to intersect with Returns: a double value that gives the distance along the ray. read
public void read(SceneReader is)
throws java.io.IOException,
java.lang.NumberFormatException Read the sphere from the given source Specified by: read in class Object Parameters: is - the source to read from Throws: java.io.IOException - if the light can not be read java.io.NumberFormatException - if there a number format error is encountered java.lang.NumberFormatException write
public void write(SceneWriter os)
throws java.io.IOException Write the sphere to the given destination Specified by: write in class Object Parameters: os - the destination to write to Throws: java.io.IOException - if the write fails. print
public void print(SceneWriter os)
throws java.io.IOException Print a human readable version of the sphere definition to the given destination Specified by: print in class Object Parameters: os - the destination to write to Throws: java.io.IOException - if the write fails. Package Class Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD