de.cau.cs.kieler.core.model.gmf.util
Class SplineUtilities

java.lang.Object
  extended by de.cau.cs.kieler.core.model.gmf.util.SplineUtilities

public final class SplineUtilities
extends Object

Helper methods for handling splines. TODO implement missing functions from this class into KielerMath

Rating red

Method Summary
static PointList approximateSpline(PointList control)
          Approximates a spline based on the control list.
static PointList calcRoundedCornersPolyline(PointList points, int r,  rForBendpoint, boolean calculateAppoxPoints)
           
static double distanceFromSpline(Point start, Point c, Point end, Point needle)
          Calculate the distance from quadratic spline curve to point needle.
static double distanceFromSpline(Point start, Point c1, Point c2, Point end, Point needle)
          Calculate the distance from cubic spline curve to point needle.
static double nearestPointOnSpline(Point start, Point c, Point end, Point needle, Point nearest)
          Calculate the distance from quadratic spline curve to point needle and set nearest to the point on the curve closest to needle.
static double nearestPointOnSpline(Point start, Point c1, Point c2, Point end, Point needle, Point nearest)
          Return the distance from cubic spline curve to point needle and set location of nearest to nearest point on the spline curve.
static Point sourceReferencePoint(PointList points, int distance)
          Calculate reference Point for source RotatableDecoration.
static Point targetReferencePoint(PointList points, int distance)
          Calculate reference Point for target RotatableDecoration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

approximateSpline

public static PointList approximateSpline(PointList control)
Approximates a spline based on the control list.

Parameters:
control - list of control points
Returns:
approximated bend points

sourceReferencePoint

public static Point sourceReferencePoint(PointList points,
                                         int distance)
Calculate reference Point for source RotatableDecoration.

Parameters:
points - line segment
distance - distance from source
Returns:
reference point

targetReferencePoint

public static Point targetReferencePoint(PointList points,
                                         int distance)
Calculate reference Point for target RotatableDecoration.

Parameters:
points - line segment
distance - distance from target
Returns:
reference point

distanceFromSpline

public static double distanceFromSpline(Point start,
                                        Point c,
                                        Point end,
                                        Point needle)
Calculate the distance from quadratic spline curve to point needle.

Parameters:
start - Starting point
c - Control point
end - End point
needle - Point to look for
Returns:
distance from needle to curve

nearestPointOnSpline

public static double nearestPointOnSpline(Point start,
                                          Point c,
                                          Point end,
                                          Point needle,
                                          Point nearest)
Calculate the distance from quadratic spline curve to point needle and set nearest to the point on the curve closest to needle.

Parameters:
start - Starting point
c - Control point
end - End point
needle - Point to look for
nearest - Container for point on curve nearest to needle
Returns:
distance from needle to curve

distanceFromSpline

public static double distanceFromSpline(Point start,
                                        Point c1,
                                        Point c2,
                                        Point end,
                                        Point needle)
Calculate the distance from cubic spline curve to point needle.

Parameters:
start - Starting point
c1 - Control point 1
c2 - Control point 2
end - End point
needle - Point to look for
Returns:
distance from needle to curve

nearestPointOnSpline

public static double nearestPointOnSpline(Point start,
                                          Point c1,
                                          Point c2,
                                          Point end,
                                          Point needle,
                                          Point nearest)
Return the distance from cubic spline curve to point needle and set location of nearest to nearest point on the spline curve. Calculations come from: "Solving the Nearest Point-on-Curve Problem" and "A Bezier Curve-Based Root-Finder" by Philip J. Schneider from "Graphics Gems", Academic Press, 1990.

Parameters:
start - Starting Point
c1 - Control point 1
c2 - Control point 2
end - End point
needle - Point to look for
nearest - Container for point on curve nearest to needle
Returns:
distance from needle to curve

calcRoundedCornersPolyline

public static PointList calcRoundedCornersPolyline(PointList points,
                                                   int r,
                                                    rForBendpoint,
                                                   boolean calculateAppoxPoints)