com.tensegrity.graphics
Class DistanceOperations

java.lang.Object
  extended bycom.tensegrity.graphics.DistanceOperations

public final class DistanceOperations
extends java.lang.Object

Implementations of various distance algorithms.

Notice that the method for computing the distance from a point to a line-segment will return the minimum distance of the two.

Version:
$Id: DistanceOperations.java,v 1.2 2003/12/11 15:47:02 AndreasEbbert Exp $
Author:
Stepan Rutz
See Also:
MathDynamicException

Method Summary
static double distancePointToLine(double x0, double y0, double x1, double y1, double x2, double y2)
          Computes the distance between a (infinite) line and a point.
static double distancePointToLineSegment(double x0, double y0, double x1, double y1, double x2, double y2)
          Computes the distance between a line segment and a point.
static double distancePointToPoint(Coordinate a, Coordinate b)
          Computes the distance between two Coordinates.
static double distancePointToPoint(double x1, double y1, double x2, double y2)
          Computes the distance between a line segment and a point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

distancePointToPoint

public static final double distancePointToPoint(double x1,
                                                double y1,
                                                double x2,
                                                double y2)
Computes the distance between a line segment and a point. The line must not have zero length. If it does a MathDynamicException is thrown.

Parameters:
x1 - the x component of the start point.
y1 - the y component of the start point.
x2 - the x component of the end point.
y2 - the y component of the end point.
Returns:
the distance between the line and the point.

distancePointToPoint

public static final double distancePointToPoint(Coordinate a,
                                                Coordinate b)
Computes the distance between two Coordinates. The two given Coordinates must have the same number of components.

Parameters:
a - the first coordinate.
b - the second coordinate.
Returns:
the distance between the coordinates.

distancePointToLine

public static final double distancePointToLine(double x0,
                                               double y0,
                                               double x1,
                                               double y1,
                                               double x2,
                                               double y2)
Computes the distance between a (infinite) line and a point. The line must not have zero length. If it does a MathDynamicException is thrown.

Parameters:
x0 - the x component of the point.
y0 - the y component of the point.
x1 - the x component of the start of the line.
y1 - the y component of the start of the line.
x2 - the x component of the end of the line.
y2 - the y component of the end of the line.
Returns:
the distance between the line and the point.
Throws:
MathDynamicException, - if x2-x1 or y2-y1 is zero.

distancePointToLineSegment

public static final double distancePointToLineSegment(double x0,
                                                      double y0,
                                                      double x1,
                                                      double y1,
                                                      double x2,
                                                      double y2)
Computes the distance between a line segment and a point. The line segment must not have zero length. If it does a MathDynamicException is thrown.

Parameters:
x0 - the x component of the point.
y0 - the y component of the point.
x1 - the x component of the start of the line segment.
y1 - the y component of the start of the line segment.
x2 - the x component of the end of the line segment.
y2 - the y component of the end of the line segment.
Returns:
the distance between the line and the point.
Throws:
MathDynamicException, - if x1-x0, x2-x1, y2-y1 or y1-y0 is zero.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.