Skip to main content
gamedev.net
🔒 Locked

Gradient Splines?

Started by SeraphLance Apr 23, 2009 at 8:30 PM 3 replies 750+ views
Original Post
SeraphLance
SeraphLance
I've been looking for a way to interpolate between two gradients, and I found this, which describes exactly what I need. However, upon looking for more information on the spline described (Catmull-Rom), I find things more along the lines of this. I'm assuming the latter is a Catmull-Rom spline on the shaky evidence that Wikipedia confirms it with a different image. If so, what does that make the first picture? Another kind of Catmull-Rom spline? If not, what is it, so I can look up more information. If so, how exactly does it work? That is, how can I find a value by interpolating its slope?
alvaro
alvaro
Your first image is a cubic spline. You want a cubic polynomial
f(x) = A*x^3 + B*x^2 + C*x + D

You know f(0), f(1), f'(0) and f'(1). That imposes 4 linear equations on A, B, C and D which determine them uniquely.

Is that what you need?
SeraphLance
SeraphLance
Hmm, it seems like what I'd need. I'm only vaguely familiar with systems of linear equations, but wouldn't such a thing require calculating the derivative of the function (i.e. f'(x) = 3Ax^2 + 2Bx + C) ? To my knowledge, that's not really a practical procedure in a program.
alvaro
alvaro
Quote:
Original post by SeraphLance
Hmm, it seems like what I'd need. I'm only vaguely familiar with systems of linear equations, but wouldn't such a thing require calculating the derivative of the function (i.e. f'(x) = 3Ax^2 + 2Bx + C) ? To my knowledge, that's not really a practical procedure in a program.


What? You can actually solve the system of linear equations by hand in this case.
SeraphLance
SeraphLance
Oh, I see. At first I wasn't sure what you meant, but now I see you mean, solving for a generalized solution by hand in terms of f(0), f(1), f'(0), and f'(1).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.