Skip to content
ExamplesOpen editor ↗

mothalokgomiBezier

→ bezierTangent()

Returns one coordinate on the line that touches a Bézier curve.

mothalokgomiBezier(a, b, c, d, t)

A tangent is a line that touches a curve without crossing it — it runs the way the curve is running at that point. mothalokgomiBezier(a, b, c, d, t) gives you one coordinate of that line, in the same way as magarengBezier.

What comes back is not a point on the canvas — it is a direction. To draw a tangent, take the point from magarengBezier and add and subtract the direction you were given, as in the example below.

The name is built, and it can be seen. Setswana has no word for tangent in any reachable source, except one South African maths dictionary that gives molakgomi — mola (line) and kgoma (to touch). Bopa uses mothalo, which is its own word for a line, so the name is mothalokgomi: the line that touches.

Note that tan stays English — it is a different thing entirely: a ratio, not a line.

NameTypeDescription
apaloCoordinate of the first anchor point.
bpaloCoordinate of the first control point.
cpaloCoordinate of the second control point.
dpaloCoordinate of the second anchor point.
tpaloHow far along the curve, between 0 and 1.
Lines touching the curve
tiro setaLoeto() {
  thalaKanefase(400, 240);
  bokamorago(245);

  metlha ax = 40;
  metlha ay = 200;
  metlha bx = 100;
  metlha by = 30;
  metlha cx = 300;
  metlha cy = 30;
  metlha dx = 360;
  metlha dy = 200;

  tlogelaGoTlatsa();
  mothaloMmala(30, 90, 170);
  boketeMothalo(3);
  thalaBezier(ax, ay, bx, by, cx, cy, dx, dy);

  mothaloMmala(220, 70, 90);
  boketeMothalo(2);
  gopheta (diri i = 0; i <= 4; i = i + 1) {
    metlha t = i / 4;
    metlha x = magarengBezier(ax, bx, cx, dx, t);
    metlha y = magarengBezier(ay, by, cy, dy, t);
    metlha tx = mothalokgomiBezier(ax, bx, cx, dx, t) * 0.12;
    metlha ty = mothalokgomiBezier(ay, by, cy, dy, t) * 0.12;
    thalaMothalo(x - tx, y - ty, x + tx, y + ty);
  }

  tlhalosa('Konego ya botala jwa loapi e e nang le mela e mekhutshwane e mehlano e mekhibidu e e e kgomang mo mafelong a a lekanang.');
}

thalaBezier, magarengBezier, mothalokgomiKonego, thalaMothalo