love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
5.05k stars 401 forks source link

Would BezierCurve:getControlPointCount be better than BezierCurve:getDegree? #764

Closed slime73 closed 11 years ago

slime73 commented 11 years ago

Original report by hahawoo (Bitbucket: hahawoo, GitHub: hahawoo).


As always I have no idea what I'm talking about, but would getControlPointCount be better than getDegree?

getControlPointCount - 1 is the degree of the BezierCurve.

getControlPointCount is the number of control points in the BezierCurve.

is maybe kind of easier to understand than

getDegree is the degree of the BezierCurve.

getDegree + 1 is the number of control points in the BezierCurve.

slime73 commented 11 years ago

Original comment by Matthias Richter (Bitbucket: vrld, GitHub: vrld).


The degree is a defining characteristic of a Bezier curve (see here). It just so happens that degree is number-of-control-points - 1.

Other kinds of (piecewise) polynomial curves may have different relationships, e.g. B-Spline curves, where the number of control points is (almost) not related to the degree of the curve.

slime73 commented 11 years ago

Original comment by Alex Szpakowski (Bitbucket: slime73, GitHub: slime73).


Maybe it would be a good idea to add getControlPointCount (even though it's a bit of a mouthful) without removing getDegree?

LÖVE's API tends to consistently provide something like:

#!Lua

for i=1, Foo:getBarCount() do
    Foo:setBar(i, ...)
end

which getControlPointCount fits in with - but getDegree also has meaning beyond just the number of control points.

slime73 commented 11 years ago

Original comment by Alex Szpakowski (Bitbucket: slime73, GitHub: slime73).


Added BezierCurve:getControlPointCount (resolves #764)