Cubic Splines

Discuss SVG code, accessible via the XML Editor.
bcholmes
Posts: 2
Joined: Tue Feb 28, 2012 12:44 am

Cubic Splines

Postby bcholmes » Sat Mar 10, 2012 2:02 am

I'm working on a pet project to convert some map files into SVG, and I can't quite figure out how to handle splines.

Here's the background: I've got a bunch of maps created in an RPG mapping tool called Campaign Cartographer. The tool uses a file type based on FastCAD. I want to convert the files into SVG. I've had a lot of success figuring out most of the file format (I started with some C code that implemented some of the work, and I've also taken part on a mailing list that's been very helpful), and I've figured out how to convert a lot into SVG notation. But the area that I get stuck on is cubic splines. Here's the data I have available in the original file:

- Curve type (in this case, Cubic B-Spline)
- Resolution (as a float)
- A start parameter (float) and an end parameter (float)
- An array of points (float x and float y)

Unfortunately I don't understand the math of Cubic B-Splines well enough to figure out how to turn that data into SVG's control points to construct a valid path. Can anyone give me a pointer?

BC

bcholmes
Posts: 2
Joined: Tue Feb 28, 2012 12:44 am

Re: Cubic Splines

Postby bcholmes » Mon Mar 12, 2012 11:05 am

Conveniently, I figured out the answer to my own problem. Most of the data that I had was a red herring. The essential part was the list of points. A Cubic B-Spline is defined through interpolating those points. To convert a Cubic B-Spline into a Cubic Bezier, I needed to break up the spline into a series of curves, and calculate the end points and control points.

There's a PDF about splines and Bezier curves (and how to convert one to the other) over here that was tremendously helpful.

Thanks anyway!

BCing you

User avatar
brynn
Posts: 8050
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Cubic Splines

Postby brynn » Mon Mar 12, 2012 4:26 pm

Welcome to the forum!

I'm glad you solved it, because I (for one) don't know what a cubic spline is, or understand much of anything else about your question. But I'm glad you posted your question, because someday, someone else may have the same question, and your solution may help them :D


Return to “SVG / XML Code”

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests