Skip to content

Defining interpolation across several knots.

March 17, 2006

Charles

Defining a curve segment is for a Nurbs, Cardinal or Bspline is not too hard. The key being the use of two knots and two tangents – these being derived for the cubic-bernstien-polynormials. Its defining these in the first place thats the key to the curve type.

For defining a value across several knots takes a bit more work. First we define the knots and tangents eg. knots:#(10,20,30,40) and tangents: #(#(15,18), #(23,27), #(33,38)). Next I assume a percentage value  for each knot eg. #(0,33.333,66.666,100) – This is derived from the knots count.

So we have our knots, there tangents and its percentages. Next we take our input (v) value eg. 55% and find which segment where in based off the percentage – so therefore 55% is in segment 33.333 – 66.666.  We’ll call these start_p and end_p.

Now we take end_p from start_p to get 33.333. So r = (end_p – start_p). We then take start_p away from our inital (v) value so (v-start_p) giving us 21.667.  Now we multiply (v-start_p) by r.

r*(v-start_p) giving us 722.222 and we then divide this value by 100 (our range) to give us 65.0. So now this is input value for our polynormial but it needs to be in a range of 1 so we divide by 100 giving us 0.65.

We know the knots now, using the start_p and end_p giving us 20 and 30. Now we need the tangents; all I do is have an array of each set inside a nested array eg. #(#(15,18), #(23,27), #(33,38)) – so now we use the start_p again which is 2, so nested array 2. Then all we use is [1] and [2] of this nested array array.

*There is one bug with this system. When the input value goes past 100, or 1 depending on your scale it then falls into a new segment. So i add a new value on the end of each array to compensate.

This example is for a bspline curve, when using Nurbs, Cardinal or even straight interpolation you dont need the tangent array. But more complex math to define these tangents from the inital knots is needed. – Plus the start and end knots use slightly different math as theres no opposite tangent to define. With Nurbs you need an array of weights too.

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: