jme.math
Class Distance

java.lang.Object
  extended byjme.math.Distance

public class Distance
extends java.lang.Object

Distance is a static class that provides commonly used math functions.

NOTE: See 3D Game Engine Design. David H. Eberly.

Author:
Mark Powell

Constructor Summary
Distance()
           
 
Method Summary
static float distanceLineLineSquared(Line line1, Line line2)
          distanceLineLineSquared calculates the distance squared between two lines.
static float distanceLineRaySquared(Line line, Line ray)
          distanceLineRaySquared calculates the squared distance between a line and a ray.
static float distanceLineSegmentSquared(Line line, Line seg)
          distanceLineSegementSquared calculates the distance squared between a line and a line segment.
static float distancePointLineSquared(Vector point, Line line)
          distancePointLineSquared calculates the distance squared between a point and a line.
static float distancePointPoint(Vector point1, Vector point2)
          distancePointPoint calculates the distance between two points.
static float distancePointPointSquared(Vector point1, Vector point2)
          distancePointPointSquared calculates the distance squared between two points.
static float distancePointRaySquared(Vector point, Line ray)
          distancePointRaySquared calculates the distance squared between a point and a ray.
static float distancePointRectangle(Vector point, Rectangle rect)
          distancePointRectangle calculates the distance squared between a point and a rectangle.
static float distancePointSegmentSquared(Vector point, Line seg)
          distancePointSegmentSquared calculates the distance squared between a point and a line segment.
static float distanceRayRaySquared(Line ray1, Line ray2)
          distanceRayRaySquared calculates the distance squared between two rays.
static float distanceRaySegmentSquared(Line ray, Line seg)
          distanceRaySegmentSquared calculates the distance squared between a ray and a line segment.
static float distanceSegmentSegmentSquared(Line seg1, Line seg2)
          distanceSegmentSegmentSquared calculates the distance squared between two line segments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Distance

public Distance()
Method Detail

distancePointPoint

public static float distancePointPoint(Vector point1,
                                       Vector point2)
distancePointPoint calculates the distance between two points. These points are described as a Vector object.

Parameters:
point1 - the first point.
point2 - the second point.
Returns:
the distance between point1 and point2.

distancePointPointSquared

public static float distancePointPointSquared(Vector point1,
                                              Vector point2)
distancePointPointSquared calculates the distance squared between two points. These points are described as a Vector object.

Parameters:
point1 - the first point.
point2 - the second point.
Returns:
the distance squared between point1 and point2.

distancePointLineSquared

public static float distancePointLineSquared(Vector point,
                                             Line line)
distancePointLineSquared calculates the distance squared between a point and a line.

Parameters:
point - the point to check.
line - the line to check.
Returns:
the distance squared between a point and line.

distancePointRaySquared

public static float distancePointRaySquared(Vector point,
                                            Line ray)
distancePointRaySquared calculates the distance squared between a point and a ray.

Parameters:
point - the point to check.
ray - the ray to check.
Returns:
the distance between a point and ray.

distancePointSegmentSquared

public static float distancePointSegmentSquared(Vector point,
                                                Line seg)
distancePointSegmentSquared calculates the distance squared between a point and a line segment.

Parameters:
point - the point to check.
seg - the line segment to check.
Returns:
the distance squared between a point and line segment.

distancePointRectangle

public static float distancePointRectangle(Vector point,
                                           Rectangle rect)
distancePointRectangle calculates the distance squared between a point and a rectangle.

Parameters:
point - the point to check.
rect - the rectangle to check.
Returns:
the distance between the point and the rectangle.

distanceLineLineSquared

public static float distanceLineLineSquared(Line line1,
                                            Line line2)
distanceLineLineSquared calculates the distance squared between two lines.

Parameters:
line1 - the first line to check.
line2 - the second line to check.
Returns:
the distance squared between two lines.

distanceLineRaySquared

public static float distanceLineRaySquared(Line line,
                                           Line ray)
distanceLineRaySquared calculates the squared distance between a line and a ray.

Parameters:
line - the line to check.
ray - the ray to check.
Returns:
the distance between the line and the ray.

distanceLineSegmentSquared

public static float distanceLineSegmentSquared(Line line,
                                               Line seg)
distanceLineSegementSquared calculates the distance squared between a line and a line segment.

Parameters:
line - the line to check.
seg - the line segment to check.
Returns:
the distance squared between a line and a line segment.

distanceRayRaySquared

public static float distanceRayRaySquared(Line ray1,
                                          Line ray2)
distanceRayRaySquared calculates the distance squared between two rays.

Parameters:
ray1 - the first ray to check.
ray2 - the second ray to check.
Returns:
the distance squared between the two rays.

distanceRaySegmentSquared

public static float distanceRaySegmentSquared(Line ray,
                                              Line seg)
distanceRaySegmentSquared calculates the distance squared between a ray and a line segment.

Parameters:
ray - the ray to check.
seg - the line segment to check.
Returns:
the distance between the ray and the line segment.

distanceSegmentSegmentSquared

public static float distanceSegmentSegmentSquared(Line seg1,
                                                  Line seg2)
distanceSegmentSegmentSquared calculates the distance squared between two line segments.

Parameters:
seg1 - the first line segment to check.
seg2 - the second line segment to check.
Returns:
the distance between two line segments.