net.sf.j3d.threeD.raytracer.primitives
Class Sphere

java.lang.Object
  extended by net.sf.j3d.threeD.raytracer.engine.AbstractSurface
      extended by net.sf.j3d.threeD.raytracer.primitives.Sphere
All Implemented Interfaces:
Surface
Direct Known Subclasses:
Sphere, SphericalLight

public class Sphere
extends AbstractSurface

A Sphere object represents a primitive sphere in 3d space.


Constructor Summary
Sphere()
          Constructs a Sphere object that represents a unit sphere centered at the origin that is black.
Sphere(Vector location, double radius)
          Constructs a Sphere object that represents a sphere with the specified center location and radius that is black.
Sphere(Vector location, double radius, RGB color)
          Constructs a Sphere object that represents a sphere with the specified center location, radius, and color.
 
Method Summary
 double getIndexOfRefraction(Vector p)
           
 Vector getNormalAt(Vector point)
          Returns a Vector object that represents the vector normal to this sphere at the point represented by the specified Vector object.
 boolean intersect(Ray ray)
          Returns true if the ray represented by the specified Ray object intersects the sphere represented by this Sphere object in real space.
 Intersection intersectAt(Ray ray)
          Returns an Intersection object representing the points along the ray represented by the specified Ray object that intersection between the ray and the sphere represented by this Sphere object occurs.
 Mesh triangulate()
           
 
Methods inherited from class net.sf.j3d.threeD.raytracer.engine.AbstractSurface
addShader, addTexture, addTransform, calculateTransform, getColor, getColorAt, getColorAt, getIndexOfRefraction, getLocation, getParent, getReflectedPercentage, getReflectedPercentage, getRefractedPercentage, getRefractedPercentage, getRotationCoefficients, getScaleCoefficients, getShadeBack, getShadeFront, getShaderSet, getSize, getTexture, getTextures, getTextureSet, getTransform, getTransform, getTransforms, removeTexture, removeTransform, setColor, setIndexOfRefraction, setLocation, setParent, setReflectedPercentage, setRefractedPercentage, setRotationCoefficients, setScaleCoefficients, setShadeBack, setShadeFront, setShaders, setShaders, setSize, setTexture, setTextures, setTransform, setTransforms, shade
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sphere

public Sphere()
Constructs a Sphere object that represents a unit sphere centered at the origin that is black.


Sphere

public Sphere(Vector location,
              double radius)
Constructs a Sphere object that represents a sphere with the specified center location and radius that is black.


Sphere

public Sphere(Vector location,
              double radius,
              RGB color)
Constructs a Sphere object that represents a sphere with the specified center location, radius, and color.

Method Detail

triangulate

public Mesh triangulate()
Overrides:
triangulate in class AbstractSurface
Returns:
A Mesh object with location, size, color, scale coefficients, rotation coefficients, and transformations as this AbstractSurface.

getIndexOfRefraction

public double getIndexOfRefraction(Vector p)
Overrides:
getIndexOfRefraction in class AbstractSurface

getNormalAt

public Vector getNormalAt(Vector point)
Returns a Vector object that represents the vector normal to this sphere at the point represented by the specified Vector object.


intersect

public boolean intersect(Ray ray)
Returns true if the ray represented by the specified Ray object intersects the sphere represented by this Sphere object in real space.


intersectAt

public Intersection intersectAt(Ray ray)
Returns an Intersection object representing the points along the ray represented by the specified Ray object that intersection between the ray and the sphere represented by this Sphere object occurs.