Cardinal Spline
joe
10/19/2006 2:49 PM
|
---|
I want to export a CARDINAL spline (same as used by gdi - drawcurve method) to dxf.
A bezier spline wouldn't be the right thing for me, because I have a given set of (control-) points which should be exactly located on the spline to export - and not been approximated...
How to do that?
grateful for any help...
|
Wout
10/19/2006 5:21 PM
|
---|
Hi Joe,
You'll have to do some math to turn them into cubic splines (use DxfSpline). Each piece of curve between 2 points of a cardinal spline is defined by those 2 points, and the tangets are defined by the neighbouring 2 points (the tension defines how far away the tangent points are put). So you can construct cubics of 4 points each and let them connect to eachother. You can merge those separate cubic splines into a single cubic spline by specifying the knots in the appropriate way (00003333 for a single cubic, 000033336666 for 2 connected cubics etc. Note that for a 2 piece cubic spline the second point is repeated, see the example I wrote below).
Thanks!
Wout
Here's an example of a cardinal spline going through points p0, p1 and p2:
C# Code: DxfSpline spline1 = new DxfSpline( |
joe
10/19/2006 8:46 PM
|
---|
first of all thank you very much for your fast reply, wout!
may I ask you some things that are not yet clear for me by commenting your code snippets?
C# Code: spline1. C# Code: spline1. |
Wout
10/19/2006 9:17 PM
|
---|
Hi,
It goes a bit too far to explain all of spline theory, it's goes pretty deep, but point 0, 3/4 and 7 are the points where the spline will go through.
Hmm, on second thought it seems I made a mistake: I don't think the 2 splines can be merged the way I did. In stead just create 2 splines in this case, each of 4 points. And the knot vector will just be 00003333 for each. Sorry for the confusion!
Wout
|