org.vizzini.math
Class Ellipsoid

java.lang.Object
  extended by org.vizzini.math.Ellipsoid
All Implemented Interfaces:
Serializable

public final class Ellipsoid
extends Object
implements Serializable

Provides an ellipsoid. The ellipsoid equation is x^2/A^2 + y^2/B^2 + z^2/C^2 = 1. This class assumes the ellipsoid is centered at (0,0,0) and A, B, and C are oriented along the X, Y, and Z axes respectively. Vector parameters must be expressed in this ellipsoid coordinate system. Note that if A == B == C, then the ellipsoid devolves into a sphere.

Since:
v0.2
Version:
v0.2
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Constructor Summary
Ellipsoid(double r)
          Construct this object as a sphere using the given parameter.
Ellipsoid(double a, double b, double c)
          Construct this object using the given parameters.
 
Method Summary
 boolean contains(Vector v)
          Return true if the given point is inside or on the surface of this ellipsoid.
 double ellipsoidEquation(Vector v)
          Return the result of using the given vector in the ellipsoid equation x^2/A^2 + y^2/B^2 + z^2/C^2.
 boolean equals(Object object)
          Return true if this ellipsoid equals the given object.
 boolean equals(Object object, double delta)
          Return true if this ellipsoid equals the given object.
 double getA()
          Return the A component.
 double getB()
          Return the B component.
 double getC()
          Return the C component.
 int hashCode()
          Return a hash code.
 double[] intersectionParameters(Vector v0, Vector v1)
          Return the intersection parameter(s) of the line described by the input vectors.
 double[] intersectionParameters(Vector v0, Vector v1, boolean beforeStart, boolean afterEnd)
          Return the intersection parameter(s) of the line described by the input vectors.
 Vector[] intersections(Ellipsoid other)
          Return the intersection point(s) of the given ellipsoid and this.
 Vector[] intersections(Vector v0, Vector v1)
          Return the intersection point(s) of the line described by the input vectors.
 Vector[] intersections(Vector v0, Vector v1, boolean beforeStart, boolean afterEnd)
          Return the intersection point(s) of the line described by the input vectors.
 boolean intersects(Ellipsoid other)
          Return true if the given ellipsoid intersects this.
 boolean intersects(Vector v0, Vector v1)
          Return true if the line described by the parameters intersects this ellipsoid.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ellipsoid

public Ellipsoid(double r)
Construct this object as a sphere using the given parameter.

Parameters:
r - Radius of sphere.
Since:
v0.2

Ellipsoid

public Ellipsoid(double a,
                 double b,
                 double c)
Construct this object using the given parameters.

Since:
v0.2
Method Detail

contains

public boolean contains(Vector v)
Return true if the given point is inside or on the surface of this ellipsoid.

Parameters:
v - Point of interest in ellipsoid coordinates.
Since:
v0.2

ellipsoidEquation

public double ellipsoidEquation(Vector v)
Return the result of using the given vector in the ellipsoid equation x^2/A^2 + y^2/B^2 + z^2/C^2. If the point is on the ellipsoid, the answer is 1.0. If the point is inside the ellipsoid, the answer is less than 1.0. Note that the answer can never be negative.

Parameters:
v - Point of interest in ellipsoid coordinates.
Since:
v0.2

equals

public boolean equals(Object object)
Return true if this ellipsoid equals the given object.

Overrides:
equals in class Object
Parameters:
object - Object to compare.
Since:
v0.2

equals

public boolean equals(Object object,
                      double delta)
Return true if this ellipsoid equals the given object.

Parameters:
object - Object to compare.
delta - Allowable difference in coordinates.
Since:
v0.2

getA

public double getA()
Return the A component.

Since:
v0.2

getB

public double getB()
Return the B component.

Since:
v0.2

getC

public double getC()
Return the C component.

Since:
v0.2

hashCode

public int hashCode()
Return a hash code.

Overrides:
hashCode in class Object
Since:
v0.2

intersectionParameters

public double[] intersectionParameters(Vector v0,
                                       Vector v1)
Return the intersection parameter(s) of the line described by the input vectors. The returned parameters may be outside of [0,1]. Clients need to interpret the parameters according to their needs.

Parameters:
v0 - Start of line in ellipsoid coordinates.
v1 - End of line in ellipsoid coordinates.
Returns:
Array of zero, one or two intersection parameters. The parameters are in increasing order.
Since:
v0.2
See Also:
intersectionParameters(Vector,Vector,boolean,boolean)

intersectionParameters

public double[] intersectionParameters(Vector v0,
                                       Vector v1,
                                       boolean beforeStart,
                                       boolean afterEnd)
Return the intersection parameter(s) of the line described by the input vectors. The returned parameters may be outside of [0,1]. Clients need to interpret the parameters according to their needs.

Parameters:
v0 - Start of line in ellipsoid coordinates.
v1 - End of line in ellipsoid coordinates.
beforeStart - Flag indicating whether to include intersection parameters before the start vector.
afterEnd - Flag indicating whether to include intersection parameters after the end vector.
Returns:
Array of zero, one or two intersection parameters. The parameters are in increasing order.
Since:
v0.2

intersections

public Vector[] intersections(Ellipsoid other)
Return the intersection point(s) of the given ellipsoid and this.

Parameters:
other - Other ellipsoid.
Returns:
Array of zero, one, two intersection points.
Since:
v0.2
See Also:
intersections(Vector,Vector,boolean,boolean)

intersections

public Vector[] intersections(Vector v0,
                              Vector v1)
Return the intersection point(s) of the line described by the input vectors. These intersections are NOT restricted to occur between v0 and v1. If another usage is needed, clients should use intersections(Vector,Vector,boolean,boolean).

Parameters:
v0 - Start of line in ellipsoid coordinates.
v1 - End of line in ellipsoid coordinates.
Returns:
Array of zero, one, or two intersection points.
Since:
v0.2
See Also:
intersections(Vector,Vector,boolean,boolean)

intersections

public Vector[] intersections(Vector v0,
                              Vector v1,
                              boolean beforeStart,
                              boolean afterEnd)
Return the intersection point(s) of the line described by the input vectors. The boolean flags restrict these intersections relative to v0 and v1.

Parameters:
v0 - Start of line in ellipsoid coordinates.
v1 - End of line in ellipsoid coordinates.
beforeStart - Flag indicating whether to include intersection parameters before the start vector.
afterEnd - Flag indicating whether to include intersection parameters after the end vector.
Returns:
Array of zero, one, or two intersection points.
Since:
v0.2

intersects

public boolean intersects(Ellipsoid other)
Return true if the given ellipsoid intersects this.

Parameters:
other - Other ellipsoid.
Since:
v0.2

intersects

public boolean intersects(Vector v0,
                          Vector v1)
Return true if the line described by the parameters intersects this ellipsoid. The intersections must occur between v0 and v1.

Parameters:
v0 - Start of line in ellipsoid coordinates.
v1 - End of line in ellipsoid coordinates.
Since:
v0.2

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Since:
v0.2


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02