com.sun.j3d.internal
Class Distance

java.lang.Object
  extended by com.sun.j3d.internal.Distance

public class Distance
extends java.lang.Object

Utility class used to calculate distance. Contains static methods used by picking method to determine intersections.


Constructor Summary
Distance()
           
 
Method Summary
static double pointToRay(Point3d pt, Point3d rayorig, Vector3d raydir)
          Minimum pt to ray distance.
static double pointToRay(Point3d pt, Point3d rayorig, Vector3d raydir, Point3d rayint, double[] param)
          Minimum pt to ray distance.
static double pointToSegment(Point3d pt, Point3d segstart, Point3d segend)
          Minimum pt to segment distance.
static double pointToSegment(Point3d pt, Point3d segstart, Point3d segend, Point3d segint, double[] param)
          Minimum pt to segment distance.
static double rayToRay(Point3d ray0orig, Vector3d ray0dir, Point3d ray1orig, Vector3d ray1dir)
          Minimum ray to ray distance.
static double rayToRay(Point3d ray0orig, Vector3d ray0dir, Point3d ray1orig, Vector3d ray1dir, Point3d ray0int, Point3d ray1int, double[] param)
          Minimum ray to ray distance.
static double rayToSegment(Point3d rayorig, Vector3d raydir, Point3d segstart, Point3d segend)
          Minimum ray to segment distance.
static double rayToSegment(Point3d rayorig, Vector3d raydir, Point3d segstart, Point3d segend, Point3d rayint, Point3d segint, double[] param)
          Minimum ray to segment distance.
static double segmentToSegment(Point3d seg0start, Point3d seg0end, Point3d seg1start, Point3d seg1end)
          Minimum segment to segment distance.
static double segmentToSegment(Point3d seg0start, Point3d seg0end, Point3d seg1start, Point3d seg1end, Point3d seg0int, Point3d seg1int, double[] param)
          Minimum segment to segment distance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Distance

public Distance()
Method Detail

rayToSegment

public static double rayToSegment(Point3d rayorig,
                                  Vector3d raydir,
                                  Point3d segstart,
                                  Point3d segend)
Minimum ray to segment distance.

Parameters:
rayorig - Origin of the ray
raydir - Direction of the ray
segstart - Segment start point
segend - Segment end point
Returns:
the square of the minimum distance from the ray to the segment

rayToSegment

public static double rayToSegment(Point3d rayorig,
                                  Vector3d raydir,
                                  Point3d segstart,
                                  Point3d segend,
                                  Point3d rayint,
                                  Point3d segint,
                                  double[] param)
Minimum ray to segment distance. Returns the square of the distance.

Parameters:
rayorig - Origin of the ray
raydir - Direction of the ray
segstart - Segment start point
segend - Segment end point
rayint - If non-null, will be filled with the coordinates of the point corresponding to the minimum distance on the ray.
segint - If non-null, will be filled with the coordinates of the point corresponding to the minimum distance on the segment.
param - An array of two doubles, will be filled with the parametric factors used to find the point of shortest distance on each primitive (ray = O +sD, with O=origin and D=direction). param[0] will contain the parameter for the ray, and param[1] the parameter for the segment.
Returns:
the square of the minimum distance from the ray to the segment

rayToRay

public static double rayToRay(Point3d ray0orig,
                              Vector3d ray0dir,
                              Point3d ray1orig,
                              Vector3d ray1dir)
Minimum ray to ray distance. Returns the square of the distance.

Parameters:
ray0orig - Origin of ray 0
ray0dir - Direction of ray 0
ray1orig - Origin of ray 1
ray1dir - Direction of ray 1
Returns:
the square of the minimum distance from the ray to the segment

rayToRay

public static double rayToRay(Point3d ray0orig,
                              Vector3d ray0dir,
                              Point3d ray1orig,
                              Vector3d ray1dir,
                              Point3d ray0int,
                              Point3d ray1int,
                              double[] param)
Minimum ray to ray distance. Returns the square of the distance.

Parameters:
ray0orig - Origin of ray 0
ray0dir - Direction of ray 0
ray1orig - Origin of ray 1
ray1dir - Direction of ray 1
ray0int - If non-null, will be filled with the coordinates of the point corresponding to the minimum distance on ray 0.
ray1int - If non-null, will be filled with the coordinates of the point corresponding to the minimum distance on ray 1.
param - An array of two doubles, will be filled with the parametric factors used to find the point of shortest distance on each primitive (ray = O +sD, with O=origin and D=direction). param[0] will contain the parameter for ray0, and param[1] the parameter for ray1.
Returns:
the square of the minimum distance from the ray to the segment

pointToRay

public static double pointToRay(Point3d pt,
                                Point3d rayorig,
                                Vector3d raydir)
Minimum pt to ray distance. Returns the square of the distance.

Parameters:
pt - The point
rayorig - Origin of the ray
raydir - Direction of the ray
Returns:
the square of the minimum distance between the point and the ray

pointToRay

public static double pointToRay(Point3d pt,
                                Point3d rayorig,
                                Vector3d raydir,
                                Point3d rayint,
                                double[] param)
Minimum pt to ray distance. Returns the square of the distance.

Parameters:
pt - The point
rayorig - Origin of the ray
raydir - Direction of the ray
rayint - If non-null, will be filled with the coordinates of the point corresponding to the minimum distance on the ray.
param - An array of one double, will be filled with the parametric factors used to find the point of shortest distance on the ray (ray = O +sD, with O=origin and D=direction). param[0] will contain the parameter for the ray.
Returns:
the square of the minimum distance between the point and the ray

pointToSegment

public static double pointToSegment(Point3d pt,
                                    Point3d segstart,
                                    Point3d segend)
Minimum pt to segment distance. Returns the square of the distance.


pointToSegment

public static double pointToSegment(Point3d pt,
                                    Point3d segstart,
                                    Point3d segend,
                                    Point3d segint,
                                    double[] param)
Minimum pt to segment distance. Returns the square of the distance.


segmentToSegment

public static double segmentToSegment(Point3d seg0start,
                                      Point3d seg0end,
                                      Point3d seg1start,
                                      Point3d seg1end)
Minimum segment to segment distance. Returns the square of the distance.

Parameters:
seg0start - the start of segment 0
seg0end - the end of segment 0
seg1start - the start of segment 1
seg1end - the end of segment 1
Returns:
the square of the minimum distance from segment to segment

segmentToSegment

public static double segmentToSegment(Point3d seg0start,
                                      Point3d seg0end,
                                      Point3d seg1start,
                                      Point3d seg1end,
                                      Point3d seg0int,
                                      Point3d seg1int,
                                      double[] param)
Minimum segment to segment distance. Returns the square of the distance.

Parameters:
seg0start - the start of segment 0
seg0end - the end of segment 0
seg1start - the start of segment 1
seg1end - the end of segment 1
seg0int - If non-null, will be filled with the coordinates of the point corresponding to the minimum distance on segment 0.
seg1int - If non-null, will be filled with the coordinates of the point corresponding to the minimum distance on segment 1.
param - An array of two doubles, will be filled with the parametric factors used to find the point of shortest distance on each primitive (segment = O +sD, with O=origin and D=direction). param[0] will contain the parameter for segment 0, and param[1] the parameter for segment 1.
Returns:
the square of the minimum distance from segment to segment