Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.port80.graph.dot.impl
Class RouteSpline  view RouteSpline download RouteSpline.java

java.lang.Object
  extended bycom.port80.graph.dot.impl.RouteSpline

public class RouteSpline
extends java.lang.Object

Spline generation and fitting.


Nested Class Summary
(package private) static class RouteSpline.BezierPt
           
 
Field Summary
(package private)  RouteSpline.BezierPt[] cpts
           
static boolean DEBUG
           
static double EPSILON0
           
static double EPSILON1
           
static double EPSILON2
           
static RouteSpline instance
           
private static java.lang.String NAME
           
static boolean VERBOSE
           
 
Constructor Summary
RouteSpline()
           
 
Method Summary
private  DotPoint add(DotPoint p1, DotPoint p2)
           
private  int addroot(double[] roots, int rootn, double root)
           
private  double B0(double t)
           
private  double B01(double t)
           
private  double B1(double t)
           
private  double B2(double t)
           
private  double B23(double t)
           
private  double B3(double t)
           
private  double dist(DotPoint p1, DotPoint p2)
           
private  double distsq(DotPoint p1, DotPoint p2)
           
private  double dot(DotPoint p1, DotPoint p2)
           
static RouteSpline getInstance()
           
private  double lineLength(DotPoint[] p, int start, int size)
          Determine total length of polyline p[istart]..p[istart+n].
static void main(java.lang.String[] args)
           
private  com.port80.util.struct.DoublePair makeSpline(DotPoint[] ipts, int istart, int isize, RouteSpline.BezierPt[] cpts)
          Interpolate the two middle control points of the Bezier curve.
private  DotPoint normalize(DotPoint v)
          Normalize vector to 'v' to unit length.
private  void points2coeff(double v0, double v1, double v2, double v3, double[] coeff)
           
 boolean routeSpline(DotPolyline ret, DotPolyline bound, DotPolyline input, DotPoint tangent0, DotPoint tangent3)
          Route spline to approx.
private  boolean routeSpline1(DotPolyline ret, DotPolyline bound, DotPoint[] ipts, int istart, int isize, DotPoint tangent0, DotPoint tangent1)
          Route spline with recursive splitting.
private  DotPoint scale(DotPoint p, double c)
           
private  boolean splineFits(DotPolyline ret, DotPolyline bound, DotPoint[] ipts, int istart, int isize, DotPoint p0, DotPoint tan0, DotPoint p3, DotPoint tan3)
          Check if spline given by 'p0','v0','p3','v3' fit inside the bounding polygon with 4/3,2/3 and 0 curvature.
private  int splineIntersectsLine(DotPoint[] pts, DotLine line, double[] roots)
           
private  boolean splineIsInside(DotPolyline bound, DotPoint[] pts)
          Check if spline given by 'pts' lies inside the bounding polygon by looking for intersections of the spline with the polygon.
private  void sprintBound(java.lang.StringBuffer ret, DotPolyline bounds)
          Print bounding polygon as GeneralPath code.
private  void sprintCurve(java.lang.StringBuffer ret, DotPolyline spline)
           
private  void sprintPath(java.lang.StringBuffer ret, DotPolyline path)
          Print path to be approximated.
private  DotPoint sub(DotPoint p1, DotPoint p2)
           
 void test()
           
 void test1()
          A simple test with single curve.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values

EPSILON0

public static final double EPSILON0
See Also:
Constant Field Values

EPSILON1

public static final double EPSILON1
See Also:
Constant Field Values

EPSILON2

public static final double EPSILON2
See Also:
Constant Field Values

DEBUG

public static final boolean DEBUG
See Also:
Constant Field Values

VERBOSE

public static final boolean VERBOSE
See Also:
Constant Field Values

instance

public static RouteSpline instance

cpts

RouteSpline.BezierPt[] cpts
Constructor Detail

RouteSpline

public RouteSpline()
Method Detail

getInstance

public static RouteSpline getInstance()

routeSpline

public boolean routeSpline(DotPolyline ret,
                           DotPolyline bound,
                           DotPolyline input,
                           DotPoint tangent0,
                           DotPoint tangent3)
Route spline to approx. the polyline 'input' within the bounding polygon 'bound'.


routeSpline1

private boolean routeSpline1(DotPolyline ret,
                             DotPolyline bound,
                             DotPoint[] ipts,
                             int istart,
                             int isize,
                             DotPoint tangent0,
                             DotPoint tangent1)
Route spline with recursive splitting.


makeSpline

private com.port80.util.struct.DoublePair makeSpline(DotPoint[] ipts,
                                                     int istart,
                                                     int isize,
                                                     RouteSpline.BezierPt[] cpts)
Interpolate the two middle control points of the Bezier curve.


splineFits

private boolean splineFits(DotPolyline ret,
                           DotPolyline bound,
                           DotPoint[] ipts,
                           int istart,
                           int isize,
                           DotPoint p0,
                           DotPoint tan0,
                           DotPoint p3,
                           DotPoint tan3)
Check if spline given by 'p0','v0','p3','v3' fit inside the bounding polygon with 4/3,2/3 and 0 curvature.


splineIsInside

private boolean splineIsInside(DotPolyline bound,
                               DotPoint[] pts)
Check if spline given by 'pts' lies inside the bounding polygon by looking for intersections of the spline with the polygon. There are any intersections besides the vertices of the bounding polygon, then the spline crossed the boundary and considered not inside the bounds.


splineIntersectsLine

private int splineIntersectsLine(DotPoint[] pts,
                                 DotLine line,
                                 double[] roots)

lineLength

private double lineLength(DotPoint[] p,
                          int start,
                          int size)
Determine total length of polyline p[istart]..p[istart+n].


points2coeff

private void points2coeff(double v0,
                          double v1,
                          double v2,
                          double v3,
                          double[] coeff)

addroot

private int addroot(double[] roots,
                    int rootn,
                    double root)

normalize

private DotPoint normalize(DotPoint v)
Normalize vector to 'v' to unit length.


add

private DotPoint add(DotPoint p1,
                     DotPoint p2)

sub

private DotPoint sub(DotPoint p1,
                     DotPoint p2)

scale

private DotPoint scale(DotPoint p,
                       double c)

distsq

private double distsq(DotPoint p1,
                      DotPoint p2)

dist

private double dist(DotPoint p1,
                    DotPoint p2)

dot

private double dot(DotPoint p1,
                   DotPoint p2)

B0

private double B0(double t)

B1

private double B1(double t)

B2

private double B2(double t)

B3

private double B3(double t)

B01

private double B01(double t)

B23

private double B23(double t)

main

public static void main(java.lang.String[] args)

test

public void test()

test1

public void test1()
A simple test with single curve.


sprintBound

private void sprintBound(java.lang.StringBuffer ret,
                         DotPolyline bounds)
Print bounding polygon as GeneralPath code.


sprintPath

private void sprintPath(java.lang.StringBuffer ret,
                        DotPolyline path)
Print path to be approximated.


sprintCurve

private void sprintCurve(java.lang.StringBuffer ret,
                         DotPolyline spline)