curvePoint - any known bugs

edited January 2017 in Programming Questions

Hello all,

are there any known bugs with curvePoint?

are the anchor and control points swapped or so....?

Tagged:

Answers

  • edited January 2017

    maybe the documentation is wrong

    it says for curve

    The first and second parameters specify the beginning control point and the last two parameters specify the ending control point. The middle parameters specify the start and stop of the curve.

    (correct)

    but for curvePoint()

    a and d are points on the curve, and b and c are the control points.

    (wrong??????)

  • (url is wrong, being a link to your c drive!)

    curve looks right, according to this: https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline

    but, yes, curvePoint description looks like it's just been copied from bezierPoint

  • edited January 2017

    The latest documentation of curvePoint() online for 3.0+ is correct:

    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 points on the curve, and b and c are the control points. 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.

    In other words, curvePoint() is like lerp() or lerpColor() but for a curve along one single axis (x, y, or z).

    If you want a function that will return a point on a 2D curve, implement it with two calls to curvePoint(). Here is an example, based on the reference example:

    /**
     * Curve Point Function
     * 2017-01-30 Jeremy Douglass - Processing 3.2.3
     * forum.processing.org/two/discussion/20563/curvepoint-any-known-bugs
     */
    PVector p1, p2, p3, p4;
    void setup() {
      p1 = new PVector(-100, 70); // control A
      p2 = new PVector(  20, 20); // anchor A
      p3 = new PVector(  80, 80); // anchor B
      p4 = new PVector( 200, 30); // control B
    }
    void draw() {
      background(192);
      noFill();
      curve(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y);
      fill(255);
      ellipseMode(CENTER);
      int steps = 6;
      for (int i = 0; i <= steps; i++) {
        float t = i / float(steps);
        PVector pv = curvePV(p1, p2, p3, p4, t);
        ellipse(pv.x, pv.y, 5, 5);
      }
    }
    
    PVector curvePV(PVector p1, PVector p2, PVector p3, PVector p4, float amt) {
      float x = curvePoint(p1.x, p2.x, p3.x, p4.x, amt);
      float y = curvePoint(p1.y, p2.y, p3.y, p4.y, amt);
      return new PVector(x, y);
    }
    

    CurvePointFunction--screenshot

    Note also that curvePoint() uses "standard parameterization" so the dots are not equidistant along the curved line. For more on this, see:

    • Examples > Topics > Curves > ArcLengthParameterization.pde
  • edited January 2017

    But a and d are not points on the curve, that was Chrisir's point.

  • I still think they swapped ad and bc

  • Answer ✓

    I still think they just cut and pasted the bezier curve text 8)

  • Answer ✓

    have raised an issue on the processing-docs github

    https://github.com/processing/processing-docs/issues/518

  • edited January 2017 Answer ✓

    Ah, yes, they swapped ad and bc as per bezier. Didn't even see that somehow. @Chrisir, would you be willing to submit a fix request to Processing-Docs?

  • Koogs did that

    Thanks to all of you!

  • Was wondering if there is any bug concerning curves in 3D. I think that the fill overflows outside the shape..... Can't remember which curve caused the problem... Has anyone experienced something similar.

Sign In or Register to comment.