JHotDraw 7.1

org.jhotdraw.geom
Class Bezier

java.lang.Object
  extended by org.jhotdraw.geom.Bezier

public class Bezier
extends java.lang.Object

Provides algorithms for fitting Bezier curves to a set of digitized points.

Source:
An Algorithm for Automatically Fitting Digitized Curves by Philip J. Schneider.
from "Graphics Gems", Academic Press, 1990
http://ftp.arl.mil/pub/Gems/original/FitDigitizedCurves.c

Version:
2.0.1 2006-06-14 Fit bezier curve must preserve closed state of fitted BezierPath object.
2.0 2006-01-14 Changed to support double precision coordinates.
1.0 March 14, 2004.
Author:
Werner Randelshofer

Method Summary
static BezierPath fitBezierCurve(BezierPath path, double error)
          Fit a Bezier curve to a set of digitized points.
static java.awt.geom.GeneralPath fitCurve(java.awt.geom.Point2D.Double[] d, double error)
          Fit a Bezier curve to a set of digitized points.
static java.awt.geom.GeneralPath fitCurve(java.awt.Polygon p, double error)
          Fit a Bezier curve to a set of digitized points.
static void main(java.lang.String[] args)
          Example of how to use the curve-fitting code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] args)
Example of how to use the curve-fitting code. Given an array of points and a tolerance (squared error between points and fitted curve), the algorithm will generate a piecewise cubic Bezier representation that approximates the points. When a cubic is generated, the routine "DrawBezierCurve" is called, which outputs the Bezier curve just created (arguments are the degree and the control points, respectively). Users will have to implement this function themselves ascii output, etc.


fitCurve

public static java.awt.geom.GeneralPath fitCurve(java.awt.Polygon p,
                                                 double error)
Fit a Bezier curve to a set of digitized points.

Parameters:
p - Polygon with a set of digitized points.
error - User-defined error squared.
Returns:
Returns a GeneralPath containing the bezier curves.

fitCurve

public static java.awt.geom.GeneralPath fitCurve(java.awt.geom.Point2D.Double[] d,
                                                 double error)
Fit a Bezier curve to a set of digitized points.

Parameters:
d - Array of digitized points.
error - User-defined error squared.
Returns:
Returns a GeneralPath containing the bezier curves.

fitBezierCurve

public static BezierPath fitBezierCurve(BezierPath path,
                                        double error)
Fit a Bezier curve to a set of digitized points.

Parameters:
path - The path onto which to fit a bezier curve.
error - User-defined error squared.
Returns:
Returns a BezierPath containing the bezier curves.

Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.