Skip to main content

Bezier Curve

A free-form curve shaped by control points — for organic outlines, cams and anything a circular arc cannot follow.

In the viewport

  1. Click Bezier on the sketch toolbar.
  2. Click the poles in order: the start, the control points, then the end. Each click adds one point to the statement, and the curve preview updates as you go.
  3. Esc ends the curve.

A pole that snaps onto an existing vertex gets a coincident written for it.

Half a vase silhouette, its side a cubic bezier

The code behind it
plate.part.js
import { sketch, bezier, line } from 'fluidcad/core';
import { coincident, fix, horizontal, vertical, distance } from 'fluidcad/constraints';

sketch("xz", () => {
// Half a vase silhouette, ready to be revolved about its centreline.
const base = line([0, 0], [30, 0]);
// A cubic bezier: start, two control points, end. Every literal pole is
// a solver point — .point(1) and .point(2) are the control points, and
// .start() / .end() are .point(0) / .point(3).
const side = bezier([30, 0], [60, 40], [5, 70], [20, 110]);
const rim = line([20, 110], [0, 110]);
const centerline = line([0, 110], [0, 0]);
// Join the curve to the lines so the profile closes; the curve itself is
// not a solver entity, only its poles are.
coincident(base.end(), side.start());
coincident(side.end(), rim.start());
coincident(rim.end(), centerline.start());
coincident(centerline.end(), base.start());
horizontal(base);
horizontal(rim);
vertical(centerline);
fix(base.start(), [0, 0]);
distance(centerline.start(), centerline.end(), 110);
})

By hand

bezier(p0, p1, ..., pn)

The first point is the start and the last the end; the points between are control points. The number of points sets the degree:

PointsCurve
2A straight line
3Quadratic (one control point)
4Cubic (two control points)

A control point can also be another entity's accessor (l.end()), in which case the curve rides that point.

Accessors

AccessorMeaning
b.point(i)The i-th pole, 0-based — point(0) is the start
b.start()Same as point(0)
b.end()The last pole
note

The curve itself is not a solver entity. Its poles are: constrain b.point(i), b.start() and b.end() and the solve reshapes the curve. tangent, distance and the other entity-level constraints do not accept a bezier.