Next: , Previous: , Up: Math   [Contents][Index]


2.2.8 Bezier Curves

The (chickadee math bezier) module provides an API for describing cubic Bezier curves in 2D space. These curves are notably used in font description, vector graphics programs, and when it comes to games: path building. With Bezier curves, it’s somewhat easy to create a smooth looking path for an enemy to move along, for example. Bezier curves become particularly interesting when they are chained together to form a Bezier “path”, where the end point of one curve becomes the starting point of the next.

Procedure: make-bezier-curve p0 p1 p2 p3

Return a new Bezier curve object whose starting point is p0, ending point is p3, and control points are p1 and p2. All points are 2D vectors.

Procedure: bezier-curve? obj

Return #t if obj is a Bezier curve.

Procedure: bezier-curve-p0 bezier

Return the starting point of bezier.

Procedure: bezier-curve-p1 bezier

Return the first control point of bezier.

Procedure: bezier-curve-p2 bezier

Return the second control point of bezier.

Procedure: bezier-curve-p3 bezier

Return the end point of bezier.

Procedure: bezier-path . control-points

Return a list of connected bezier curves defined by control-points. The first curve is defined by the first 4 arguments and every additional curve thereafter requires 3 additional arguments.

Procedure: bezier-curve-point-at bezier t

Return the coordinates for bezier at t (a value in the range [0, 1] representing how far from the start of the curve to check) as a 2D vector.

Procedure: bezier-curve-point-at! dest bezier t

Modify the 2D vector dest in-place to contain the coordinates for bezier at t.


Next: , Previous: , Up: Math   [Contents][Index]