BContour - a BContour is a sequences of connected Bezier curves.
A BContour is a sequences of connected Bezier curves. Aim of this package is to provide a method for splitting the contour in sub-curves with the same length. A BContour is built by appending contiguos Bezier curves (also called strokes); In order to be able to split the contour in uniform-length sub-curves, and also to be able to preserve its 'shape', this package introduces the notion of C1-continuity: if two contiguos strokes have, in their joining point, the same prime derivative, then the two strokes are grouped, so that they could be split better.
A BContour is built by first setting its initial point, then by repeatedly appending all the control-points of the Bezier curves, without repeating the control-points in common.
returns the (fully qualified) name of a new object representing a BContour. Object is created in the caller's namespace.
The following commands are possible for a BContour-object:
adds to the BContour a new Bezier curve, i.e all its control-points BUT the first (since it is already stored). All points of a BContour must have the same dimension.
# creates a new contour: set the initial point (this is a 2D contour)" set f [BContour::new {1 2} ] $f append {3 4} {5 6} ;# a degree:2 curve (Quadratic Bezier) $f append {20 0} ;# a degree:1 curve (straight segment) $f append {25 -9} {0 -15} {-1 33.3} {-15.32 3.0} ;# a degree:4 curve
destroys the object, including its storage space and associated command.
returns the list of control-points of the i-th stroke. Argument i can be a an integer, as well as "end", "end-1", ...
returns the list of all the strokes, i.e. a list of list of control-points.
returns the (approximated) length of the contour. Precision can be adjusted through the flatnesstolerance method.
gets/sets the flatness tolerance:
if val is positive, it is used as an absolute tolerance, if val is negative, a relative tolerance is applied to each stroke i.e the tolerance on each stroke is P*abs(flatnesstolerance) where P is the stroke's polylength
Flatness tolerance cannot be 0.0; it must be > 1e-9
splits the whole contour in sub-curves each having a curve-length of (about) dL. Note that the initial dL is internally 'rounded', so that it divides each sequence of curves with C1-continuity in N parts of length dL*
WARNING: the last point (t=1) is NOT returned.
Result depends on the kind parameter: For kind at,tangent_at,normal_at, result is a list of points and the last point is NOT returned.
For kind vtangent_at,vnormal_at, result is a list of segments (pairs of points), each of lenght dL/2
Bezier
Itcl, math
math
Copyright © 2014, by A.Buratti