Common Lisp Package: COM.ELBENO.CURVE

README:

Curve

This is com.elbeno.curve, a library for modulating various kinds of curves.

This library depends on com.elbeno.vector and vecto.

The following curves are supported:

  • Circles
  • Ellipses
  • Cubic Bézier curves
  • Cubic Bézier splines
  • Line segments
  • "Polylines" i.e. sequences of line segments

Each curve type may be modulated onto each other curve type (e.g. modulate a "wave" Bézier curve onto a circle to produce a circle with a wavy edge). C1 continuity is preserved.

Arbitrary elliptical arcs are approximated with cubic Bézier curves using the method in Luc Maisonobe's paper "Drawing an elliptical arc using polylines, quadratic or cubic Bézier curves" (which can be found at http:// www.spaceroots.org/documents/ellipse/elliptical-arc.pdf).

Sample usage/output can be seen from the file test.lisp or by invoking (runtests).

FUNCTION

Public

APPROXIMATE-ELLIPTICAL-ARC (CX CY A B THETA ETA1 ETA2 &OPTIONAL (DA/DETA 0) (DB/DETA 0) (ERR 0.5))

Approximate an elliptical arc with a cubic bezier spline. Requirement: eta1 < eta2.

Undocumented

RUNTESTS

Private

Undocumented

APPROXIMATE-ARC (CX CY A B THETA ETA1 ETA2 DA/DETA DB/DETA ERR)

APPROXIMATE-ARC-SINGLE (CX CY A B THETA ETA1 ETA2 DA/DETA DB/DETA)

BEZIER-DECASTELJAU (BEZ K)

BEZIER-ERROR (A B ETA1 ETA2)

CALC-C-TERM (I B/A ETASUM ARR)

DECASTELJAU (P0 P1 P2 P3 K)

DRAW-BEZIER-NO-MOVE (C)

DRAW-LINE-NO-MOVE (C)

ELLIPSE-DERIV-VAL (A B THETA ETA)

ELLIPSE-VAL (CX CY A B THETA ETA)

FIND-CURVE-PARAM (PT-ARRAY DISTANCE &OPTIONAL (START 0) (END (LENGTH PT-ARRAY)))

INTERP-CURVE-PARAM (PT-ARRAY IDX DISTANCE)

POLYLINE-SAMPLE (LINE-LIST K)

REVERSE-BEZ-CURVE (C)

REVERSE-SPLINE (C)

SAFE-ADD (A B)

SAMPLE-CURVE (SAMPLER-FN N)

SPLINE-DECASTELJAU (BEZIER-LIST K)

TEST-ARC-APPROX

TEST-ELLIPSE (FILENAME)

TEST-MOD-ARC1 (FILENAME)

TEST-MOD-ARC2 (FILENAME)

TEST-MOD-BEZIER (FILENAME)

TEST-MOD-CIRCLE (FILENAME)

TEST-MOD-CURVE (FILENAME C0 C1)

TEST-MOD-ELLIPSE (FILENAME)

TEST-MOD-LINE (FILENAME)

TEST-MOD-POLYLINE (FILENAME)

TEST-MOD-SPLINE (FILENAME)

TEST-SPIRALS

TRANS-BEZ-CURVE (C START END LEN)

TRANS-SPLINE (C START-PARAM END-PARAM LEN SAMPLER)

TRANSFORM-POLYLINE (C START-PARAM END-PARAM LEN SAMPLER)

TRANSFORM-SPLINE (C START-PARAM END-PARAM LEN SAMPLER)

X-FRACS (PTLIST)

GENERIC-FUNCTION

Public

DRAW (C)

Draw the curve with vecto, first moving.

MODULATE (C0 C1 N)

Modulate a curve c1 onto a base curve c0 n times.

Private

MAKE-LENGTH-SAMPLER (C N)

Make a sampler function for the curve (by length) between 0 and 1. The expected number of samples is n.

MAKE-PARAM-SAMPLER (C)

Make a sampler function for the curve parameterised between 0 and 1.

TRANSFORM-CURVE (C START END LEN)

Transform c given start point, end point, and length of segment.

SLOT-ACCESSOR

Private

Undocumented

A (OBJECT)

SETFA (NEW-VALUE OBJECT)

B (OBJECT)

SETFB (NEW-VALUE OBJECT)

BEZIER-LIST (OBJECT)

SETFBEZIER-LIST (NEW-VALUE OBJECT)

CENTER (OBJECT)

SETFCENTER (NEW-VALUE OBJECT)

LINE-LIST (OBJECT)

SETFLINE-LIST (NEW-VALUE OBJECT)

O (OBJECT)

SETFO (NEW-VALUE OBJECT)

P0 (OBJECT)

SETFP0 (NEW-VALUE OBJECT)

P1 (OBJECT)

SETFP1 (NEW-VALUE OBJECT)

P2 (OBJECT)

SETFP2 (NEW-VALUE OBJECT)

P3 (OBJECT)

SETFP3 (NEW-VALUE OBJECT)

R (OBJECT)

SETFR (NEW-VALUE OBJECT)

VARIABLE

Private

Undocumented

*BEZIER*

*CIRCLE*

*ELLIPSE*

*LINE*

*POLYLINE*

*SPLINE*

+CUBIC-ERROR-COEFFS-0+

+CUBIC-ERROR-COEFFS-1+

CLASS

Public

Undocumented

BEZIER

CIRCLE

ELLIPSE

LINE

POLYLINE

SPLINE

Private

Undocumented

CURVE