Hello, forum!
I’m working with Rhino 4 and Rhino.net plug-in sdk (.net 2.0) in c#. I’m not able to define a nurbs properly, when I do it the behavior is unexpected.
I want to draw a very simple nurbs defined by 3 points (p1, p2 and p3), being tangent to p0-p1 and p1-p2 at the ends, and control the proximity of the curve to p1 by its weight, w1.
My code is:
On4dPoint p0 = new On4dPoint(2, 1, 0, 1);
On4dPoint p1 = new On4dPoint(4, 3, 0, 1);
On4dPoint p2 = new On4dPoint(5, 2, 0, 1);
OnNurbsCurve nc0 = new OnNurbsCurve(3, true, 3, 3);
nc0.SetKnot(0, 0);
nc0.SetKnot(1, 0);
nc0.SetKnot(2, 1);
nc0.SetKnot(3, 1);
bool p00OK = nc0.SetCV(0, p0);
bool p10OK = nc0.SetCV(1, p1);
bool p20OK = nc0.SetCV(2, p2);
bool w00OK = nc0.SetWeight(0, 1.0);
bool w10OK = nc0.SetWeight(1, 1.0);
bool w20OK = nc0.SetWeight(2, 1.0);
OnNurbsCurve nc1 = new OnNurbsCurve(3, true, 3, 3);
nc1.SetKnot(0, 0);
nc1.SetKnot(1, 0);
nc1.SetKnot(2, 1);
nc1.SetKnot(3, 1);
bool p01OK = nc1.SetCV(0, p0);
bool p11OK = nc1.SetCV(1, p1);
bool p21OK = nc1.SetCV(2, p2);
bool w01OK = nc1.SetWeight(0, 1.0);
bool w11OK = nc1.SetWeight(1, 0.5);
bool w21OK = nc1.SetWeight(2, 1.0);
Which means that the first curve (white) has all weights equal to 1 and it is visually correct. The second (red) has w1=0.6, then it should have basically the basic shape and tangent properties of the white one but should be less close to p1 vertex.
The problem is that what I see is not what I was expecting. The red curve is no longer tangent to p0-p1 and p1-p2 and its convexity is no longer “attracted” by p1.
I’ve read that Rhino uses a shorter knot notation, in fact in this case the classical “Piegl, Tiller, The nurbs book” knot vector should be [0,0,0,1,1,1], but Rhino apparently doesn’t need both end values and then I used [0,0,1,1] by analyzing the properties of similar curves drawn by hand. Is the problem around here?
Thanks. L