Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Technique for drawing splines?  (Read 2902 times)

0 Members and 1 Guest are viewing this topic.

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Technique for drawing splines?
« on: September 04, 2011, 01:51:18 pm »
I've been playing with b-splines a bit lately - working on a small shmup. I was wondering if anyone has a particularly clean way to draw splines/curves.

Currently I am just drawing lines at an interval determined by how many control points are in the spline. This works relatively well while the spline is static, but when modifying the spline this interval changes and the result isn't the most pleasing.

It's not a huge issue, especially because you only see it in the editor, but I figured someone must have done this before, though I didn't find anything in my searching.

tl;dr - I'm bored. Let's talk about computer graphics and programming :)

citizen-erased

  • Newbie
  • *
  • Posts: 1
    • View Profile
Technique for drawing splines?
« Reply #1 on: September 11, 2011, 04:45:03 am »
You can draw nice looking splines by drawing many lines between control points. Interpolate between 2 control points using a small step size and draw a straight line between each point as you step along. If your step size generates points smaller than a pixel you'll get a very good approximation of the curve but you can get away with using a large size. To draw the whole curve just apply the same concept to each pair of control points.

Also keep in mind that the interpolation is non linear. The distance between points found by stepping along the spline at regular intervals of t (interpolation amount) will be different (in most cases) but this is not likely to be a problem for displaying it in the editor.