Biarc Curve Fitting
Hakan Tiftikci Turkey hakan.tiftikci@yahoo.com.tr
Introduction
Biarc curve fitting, as the name implies, fits a curve consisting of two circular arcs through two points with specified tangents. For a given set points, biarc curve fitting may be applied for successive pairs of points with common given /computed tangent for each point, to generalize the curve fitting process. This worksheet demonstrates biarc curve fitting, following the work of Jaroslaw and Aristides[1]. Another source for biarc curves is Choi [2] which contains only 2D specific formulation with less freedom and thus limited compared to formulation of [1].
Initialization
In this part, auxiliary functions
dot
cross
norm2
Determination of circular arc parameters from arc end points and apex point
Biarc curve fitting, as described here, determines junction point and here-so-called apex points. Circular arc parameters (radius, angle, center, ...) from two end points and meeting point of tangents at are determined via following formulas
where
threepoint2circlearc := proc(A,B,C) description "determines the center, radius,angle extent and basis vectors for a arc end points 'A,B' and apex point 'C'"; local AB,BC,lAB,lBC,ab,bc,E1,E2,E3,cos2t,sin2t,cost,sint,tant,theta,r,bisector,center; AB := B-A; BC := C-B; lAB := norm2(AB); lBC := norm2(BC); ab := AB/lAB; bc := BC/lBC; E3 := cross(ab,bc); sin2t := norm2(E3); E3 := E3/sin2t; cos2t := dot(ab,bc); cost := sqrt((1+cos2t)/2); sint := sqrt((1-cos2t)/2); tant := sint/cost; theta := arctan(sin2t,cos2t)/2; r := lAB/tant; # tant (instead of tan(theta)) is intentially used since it is positive bisector := bc-ab; center := B + (r/cost)*bisector/norm2(bisector); E1 := A-center; E1 := E1/norm2(E1); E2 := cross(E3,E1); center,r,theta,E1,E2,E3; end proc:
Rational polynomial representation of circular arc
Although not necessary, rational representation of circular arc is employed here. A circular arc centered at origin and having angle sweep is defiend as
Following procedure generalizes this formula to general orientation by using basis vectors as input arguments
Test of routine "rationalArc"
Formulation (Jaroslaw and Aristides)
The figure below illustrates a a biarc curve passing through points with tangents together with the dimensions used to formulate the problem..
In this document, the intersection point of tangents for one of the arcs is called "apex". Apex points in the figure are given by
Junction point of two arcs is
Those points are subject to following length constraints
which yield, after some manipulation, the general equation as
If the ratio of lengths is specified as
then quadratic equation
is obtained. These formulas are implemented in "biarcBasic" and "biarc" procedures. Note that "biarc" procedure returns only positive solution if "sign" parameter is 0, otherwise sign should be (or may be left as a symbol to denote ) and the result will be dependent on the value of sign (for a generic solution)
Formulation (Choi)
Although not examplified, formulation given in Choi[2] is summarized here for completeness. Formulation given in Choi[2] has less freedom (as opposed to 2-parameter family of solutions of [1]) due to some geometric conditions imposed on the biarc curve. It is based on radii , instead of lengths . Also it is discriminated for unimodal and inflection curves. For unimodal curves with , radii are given by
For inflection biarc with equal radii, formula is
Examples
This section contains three examples of biarc curve fitting
Example-1 : Single 3D biarc curve segment
Example-2: Multiple biarc curve segments
In this example biarc curve fitting is performed on more than 2 points to yield more than 2 biarc curve segments. Computation of tangents is similar to that of Catmull-Rom splines, i.e.
same ratio is assumed for all segments. Not to exhaust the memory too much, results are returned in floating-point evaluated form.
Create sample points
Determine biarc curve fit and display results
Example-3 : Converting a parametric curve a sequence of circular arcs
In this example procedure "curve2arcs" samples parametric curve at given parameter values for position and tangent values and determines the sequence of biarc curve fits for the computed curve points and tangents. The procedure returns both rational arc representations and arc points as lists.
This procedure is applied to two curves
Resulting biarc curves are rendered below. Note that the result for the first curve shown below contains a segment which does not fit to original curve, which is possibly due to non-adaptive (uniform) sampling of curve and/or non-adaptive selection of length ratio . Biarc curve fit to second curve fits quite well
Conclusions
References
[1] Jaroslaw R.Rossignac, Aristides A.G. Requicha, "Piecewise circular curves for geometric modeling", , IBM J. RES. DEVELOP.VOL.3, NO.3 May 1987
[2] B.K. Choi, "Surface Modeling for CAD/CAM". Elsevier, Amsterdam, 1991
All worksheets must contain the following disclaimer:
Legal Notice: ? Maplesoft, a division of Waterloo Maple Inc. 2009. Maplesoft and Maple are trademarks of Waterloo Maple Inc. Neither Maplesoft nor the authors are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the authors for permission if you wish to use this application in for-profit activities.