toxi.geom
Class SphereIntersectorReflector

java.lang.Object
  extended by toxi.geom.SphereIntersectorReflector
All Implemented Interfaces:
Intersector3D, Reflector3D

public class SphereIntersectorReflector
extends java.lang.Object
implements Intersector3D, Reflector3D


Constructor Summary
SphereIntersectorReflector(Sphere s)
           
SphereIntersectorReflector(Vec3D o, float r)
           
 
Method Summary
 IsectData3D getIntersectionData()
           
 ReadonlyVec3D getReflectedRayPointAtDistance(float dist)
          Returns the point on the reflected ray at given distance from the intersection point
 float getReflectionAngle()
           
 Sphere getSphere()
           
 float intersectRayDistance(Ray3D ray)
          Calculates the distance of the vector to the given sphere in the specified direction.
 boolean intersectsRay(Ray3D ray)
          Checks if entity intersects with the given ray.
 Ray3D reflectRay(Ray3D ray)
          Reflects given ray on the entity's surface
 void setSphere(Sphere sphere)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SphereIntersectorReflector

public SphereIntersectorReflector(Sphere s)

SphereIntersectorReflector

public SphereIntersectorReflector(Vec3D o,
                                  float r)
Method Detail

getIntersectionData

public IsectData3D getIntersectionData()
Specified by:
getIntersectionData in interface Intersector3D
Returns:
intersection data parcel

getReflectedRayPointAtDistance

public ReadonlyVec3D getReflectedRayPointAtDistance(float dist)
Description copied from interface: Reflector3D
Returns the point on the reflected ray at given distance from the intersection point

Specified by:
getReflectedRayPointAtDistance in interface Reflector3D
Parameters:
dist - distance from isect position
Returns:
point on reflected ray

getReflectionAngle

public float getReflectionAngle()
Specified by:
getReflectionAngle in interface Reflector3D
Returns:
angle between incident ray and surface normal

getSphere

public Sphere getSphere()
Returns:
the sphere

intersectRayDistance

public float intersectRayDistance(Ray3D ray)
Calculates the distance of the vector to the given sphere in the specified direction. A sphere is defined by a 3D point and a radius. Normalized directional vectors expected.

Parameters:
ray - intersection ray
Returns:
distance to sphere in world units, -1 if no intersection.

intersectsRay

public boolean intersectsRay(Ray3D ray)
Description copied from interface: Intersector3D
Checks if entity intersects with the given ray. Further intersection details can then be queried via the IsectData3D instance returned by Intersector3D.getIntersectionData().

Specified by:
intersectsRay in interface Intersector3D
Parameters:
ray - ray to check
Returns:
true, if ray hits the entity

reflectRay

public Ray3D reflectRay(Ray3D ray)
Description copied from interface: Reflector3D
Reflects given ray on the entity's surface

Specified by:
reflectRay in interface Reflector3D
Parameters:
ray - incident ray
Returns:
reflected ray starting from intersection point

setSphere

public void setSphere(Sphere sphere)
Parameters:
sphere - the sphere to set