Artur
Artur

Reputation: 3282

Cubic B-spline curve in Java

I need to use a cubic B-spline curve but cannot find code for it anywhere. The only curves available in Java API are QuadCurve2D, Path2D and CubicCurve2D. I think they all are Bezier, but I'm not sure about it.

If you know where can I find code for cubic B-spline preferably that extends Java Shape class and supports contains(Point p) for onMouseOver please help.

Upvotes: 7

Views: 4059

Answers (2)

Jake Stevens-Haas
Jake Stevens-Haas

Reputation: 1696

Apache has a class to represent spline curves:

http://jmeter.apache.org/api/org/apache/jmeter/visualizers/Spline3.html

However, it doesn't extend Shape or support what you want. The class works by interpolating the curve between nodes with a cubic curve. For contains(Point P) You might be able to use the getPlots() method, compare its results to the x and y values of P.

Upvotes: 1

fakeaccount1
fakeaccount1

Reputation: 169

CubicCurve2D is a cubic B-spline.

However, this may or may not be what you need as there are other cubic B-splines.

That is, all CubicCurve2Ds are cubic B-splines. Not all cubic B-splines are CubicCurve2Ds.

Upvotes: 3

Related Questions