Path: chuka.playstation.co.uk!news From: "Tom" Newsgroups: scea.yaroze.programming.3d_graphics,scee.yaroze.programming.3d_graphics Subject: Re: 3D Splines Date: Thu, 4 Nov 1999 23:54:11 -0800 Organization: PlayStation Net Yaroze (SCEE) Lines: 60 Message-ID: <7vt698$3c62@chuka.playstation.co.uk> References: <381FAE75.BD3A3572@surfsouth.com> NNTP-Posting-Host: asn16-158.mcmail.com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Xref: chuka.playstation.co.uk scea.yaroze.programming.3d_graphics:384 scee.yaroze.programming.3d_graphics:1428 Hello again, I've been having a quick poke through some of my old textbooks and I found a partial answer to you question in a book by AK Dewdney called "The New Turing Omnibus". It's packed full of pointless mathematical things like logic, fractals and things. Anyway here's the important stuff... A spline is a cubic equation which can be thought of as a point moving through space for a time t (this is taken over the range 0..1 for simplicity). The equations are: x(t) = ax + bx*t + cx*(t^2) + dx*(t^3) y(t) = ay + by*t + cy*(t^2) + dy*(t^3) z(t) = az + bz*t + cz*(t^2) + dz*(t^3) I'll just cover how to find a pratial solution for the x(t) equation as it's more or less the same for y(t) and z(t). The curve is defined by the position of the two end points (at t=0 and t=1) and their respective gradients. The equation of the gradients can easily be found: let x(t) now be: x(t) = a + b*t + c*(t^2) + d*(t^3) then dx(t) is: dx(t) = b + 2*c*t + 3*d*(t^2) To get a solution, we can find the values of a, b, c and d by taking the values of x(t) and dx(t) and t=0 and t=1: x(0) = a dx(0) = b x(1) = a + b + c + d dx(1) = b + 2*c + 3*d Simple or what? Now according to Mr Dewdney the values of a, b, c and d are as follows: a = x(0) b = dx(0) c = 3*(x(1) - x(0)) - 2*dx(0) - dx(1) d = 2*(x(0) - x(1)) + dx(0) + dx(1) I don't know how he got here, probably with some insanely complex maths but I trust his maths more than mine. Now then, you have the values of x(0) and x(1) (they're the end point values) and so the shape of the curve is now defined by the gradients at these endpoints. Here's where the trouble lies. All I know about finding the gradients is that the gradient of xi(1) should be the same as the gradient of xi+1(0). In other words, the 2 gradients that each point on your track must be the same to give a smooth edge. I'll try writing a PC program tomorrow to see how the gradient values affect the shape of the curve. I've a sneaking suspicion that the gradient values may be the coordinates of the other two control points, but I could be wrong. Hope this helps (and that someone else knows more than I do on this subject) Cheers, Tom