Name

curvePoint()

Description

Evaluates the curve at point t for points a, b, c, d. The parameter t may range from 0 (the start of the curve) and 1 (the end of the curve). a and d are the control points, and b and c are points on the curve. As seen in the example above, this can be used once with the x coordinates and a second time with the y coordinates to get the location of a curve at t.

Examples

  • size(400,400);
    
    noFill();
    curve(20, 104, 20, 104, 292, 96, 292, 244);
    curve(20, 104, 292, 96, 292, 244, 60, 260);
    
    fill(255);
    ellipseMode(CENTER);
    int steps = 6;
    for (int i = 0; i <= steps; i++) {
      float t = i / float(steps);
      float x = curvePoint(20, 20, 292, 292, t);
      float y = curvePoint(104, 104, 96, 244, t);
      ellipse(x, y, 10, 10);
      x = curvePoint(20, 292, 292, 60, t);
      y = curvePoint(104, 96, 244, 260, t);
      ellipse(x, y, 10, 10);
    }
    Image output for example 1

Syntax

  • curvePoint(a, b, c, d, t)

Parameters

  • a(float)coordinate of first control point
  • b(float)coordinate of first point on the curve
  • c(float)coordinate of second point on the curve
  • d(float)coordinate of second control point
  • t(float)value between 0 and 1

Return

  • float