CreateHermiteSpline bug: doc or code?

Doc for CreateHermiteSpline says this:

“nbPoints (integer) the wanted number of points in the curve”

but, code does this:

for (let i = 0; i <= nbPoints; i++) { …

one of these is wrong.

Pedantically you are correct @lowclouds and for correct drawing, the code is correct, so it would be the docs that need changing. Then the explanation in the docs becomes a little more complicated, eg

nbPoints should be one less than the number of points you want on the curve.

This would be important if you wanted a small number of points i.e 4 points on the curve but in this case why draw a Hermite spline. For a smooth curve with a largish number of points then I would say who is worried whether the number of points is, say, 51 rather than 50?

IMHO keep the docs explanation simple as it is.

I ran across this because I need either an odd number of points or 2n+2 points for a particular application and wasn’t getting what I expected. I’ll change the docs. FWIW, there’s no inherent reason for it to be one way or the other.

Craig

OK I understand. The best solution would be to change the docs since altering the code would be a breaking change.

I was thinking more along the lines of ‘nB the number of path segments or nB + 1 points’

Path segments sounds correct. Go with that. Both here

and with the code comments for the API.

1 Like