I don't know how to use the weight vector in SurfaceSpline. I have tried to follow the very limited documentation but I can not make it work. I don't know if if there is a bug or (much more probable) something I am misunderstanding.
I have written a small test script:
function TestSurfaceSpline()
{
var x=[0, 1, 2, 0, 1, 2, 0, 1, 2];
var y=[0, 0, 0, 1, 1, 1, 2, 2, 2];
var z=[0, 0, 0, 0, 1, 0, 0, 0, 0];
var w=[1, 1, 1, 1, 0.5, 1, 1, 1, 1];
console.writeln("\nTest without weights:");
var spline1 = new SurfaceSpline();
spline1.smoothing = 0.25;
spline1.order = 2;
spline1.initialize(new Vector(x), new Vector(y), new Vector(z));
var val1=spline1.evaluate(new Point(1,1));
console.writeln("Val1: ", val1);
console.writeln("\nTest with weights:");
var spline2 = new SurfaceSpline();
spline2.smoothing = 0.25;
spline2.order = 2;
spline2.initialize(new Vector(x), new Vector(y), new Vector(z), new Vector(w));
var val2=spline2.evaluate(new Point(1,1));
console.writeln("Val2: ", val2);
}
TestSurfaceSpline();
The first spline without weights works well. However, the second spline, in which I add the weight vector, fails:
Test without weights:
Val1: 0.8039267991984922
Test with weights:
*** Error [000]: C:/Users/Andres/Documents/PCL/test.js, line 20: Error: SurfaceSplineGenerateD(): Low-level API function error
API error code = 69:
Singular matrix
What I am doing wrong?.