|
|
"Bald Eagle" wrote:
> "Nevado" wrote:
>
> >.... I spent more hours googling parametric functions and understanding
> > matrix solving than writing the code
>
> I know exactly what you mean. I had looked over splines and matrices a number
> of times in the past, but never made enough headway in understanding how to
> translate the theory into anything usable.
>
> It would be great if you could at some point share some of what you learned -
> I believe several people here on the boards have expressed some interest at
> one point or another in how splines are interpolated.
Well, I started out just knowing that for cubic splines, some kind of
third-degree function had to be involved.
At first I thought the function would look like I was taught in high scool math:
y = f(x) = ax^3 + bx^2 + cx + d
But clipka set me straight on that: POV-Ray splines are actually described by
two functions of a third parameter t,
x = f1(t) = a1t^3 + b1t^2 + c1t + d1
y = f2(t) = a2t^3 + b2t^2 + c2t + d2
thus the name parametric function. This was news to me, so I had to read up on
that and found these links useful:
https://www.cs.unm.edu/~angel/CS534/LECTURES/CS534_06.pdf
http://web.eecs.umich.edu/~sugih/courses/eecs487/lectures/37-B-splines.pdf
Knowing four x- and y-values on the spline, I could find this function by using
matrices. I read up on that here:
http://www.mathsisfun.com/algebra/matrix-multiplying.html
I learned that solving a cubic polynomial from four known points requires a 4x4
matrix involving a huge number of calculations done in a specific order.
Luckily, I could copy some of those calculations from here:
http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
And once I had them translated into JustBasic, I could test if they worked
correctly here:
http://www.mathportal.org/calculators/matrices-calculators/matrix-calculator.php
So, yeah, in this kind of project, Google definitely is your friend ;-)
I'm making this sound easier than it was, because some long nights were
involved, but it was also a fun challenge. I'm sure everyone in here knows the
feeling from writing a POV-Ray scene and clicking "Run" - and the thrill when it
works exactly like you wanted. Or when you figure out exactly why it doesn't - I
had a lot of those too.
By the way, I probably wouldn't have bothered to develop my PointWriter app this
far without your encouragement, so you deserve credit for that.
Post a reply to this message
|
|