I’ve written a java class (which interfaces to a C library via JNI) and which I’d like to use in a sketch.
//**** bezier/BezFit.java
package bezier;
public class BezFit {
static { System.loadLibrary("bezier"); }
public static native void fitCurve(double[] result, int n, double delta, double[] d);
}
and I can use this from java like this:
//**** Tst.java
import bezier.BezFit;
public class Tst {
public static void main(String[] args) {
double[] data = {0.01, 0.01, 0.3, 1.0, 0.7, 2.0, 1.0, 2.4, 2.0, 3.0, 3.0, 3.6, 3.4, 4.0, 3.8, 5.0, 4.0, 6.0};
double[] bez = new double[8];
BezFit.fitCurve(bez, 9, 0.5, data);
System.out.println("control pt 1: " + bez[2] + ", " + bez[3]);
}
}
Now, what is the simplest way of using BezFit in a single sketch? Do I absolutely have to create a library? I don’t use Eclipse. I use vi and javac
I had a look at https://forum.processing.org/two/discussion/21049/creating-a-library where it says: “Firstly - are you clear about how Java works, and what happens in Processing under the hood?”
No, I’m not a java programmer and no, I don’t know what happens under the hood :-/