POV-Ray : Newsgroups : povray.advanced-users : quadratic & cubic splines Server Time
30 Jul 2024 10:12:27 EDT (-0400)
  quadratic & cubic splines (Message 1 to 3 of 3)  
From: Leroy Whetstone
Subject: quadratic & cubic splines
Date: 8 Dec 1999 12:49:23
Message: <384EB574.6D9E0A42@janics.com>
What type of quadratic and cubic spline is use in POV's lathe and prism?

I've wrote a little program to make my own lathes, sors, prisms and
polygons.I'm up grading it and would like to preview these splines. I
found the formula for bezier splines and it seems to work . Any help
would be appreciated.


Post a reply to this message

From: Leroy Whetstone
Subject: Re: quadratic & cubic splines
Date: 23 Dec 1999 13:14:23
Message: <386281BC.4536C7D7@janics.com>
Well! I finally done it. I asked a question that no one was willing or able
to  answer.
Maybe I just asked in the wrong group.
But here's a quick look at what I've found:

// bezier spline formula  ---------------------
 I found this at http://www.moshplant.com/direct-or/bezier/

(ControlX0,ControlY0) the first control point
(PointX0,PointY0)     the first point
(ControlX1,ControlY1)  the second control point
(PointX1,PointY1)      the second point

Cx = 3 * (ControlX0 - PointX0):  Cy = 3 * (ControlY0 - PointY0)
Bx = 3 * (ControlX1 - ControlX0) - Cx: By = 3 * (ControlY1 - ControlY0) - Cy

Ax = PointX1 - PointX0 - Cx - Bx:    Ay = PointY1 - PointY0 - Cy - By

for t=0 to 1 step .01
Xp = Ax * t ^ 3 + Bx * t^2 + Cx*t + PointX0  ' X location
Yp = Ay * t ^ 3 + By * t^2 + Cx*t + PointY0 ' Y location
plot(Xp,Yp)
next

// Cubic spline formula   ---------------------
 I used the basic bezier formula with second control point at the start
 equal to the slope between the first point and the third point divid by 3
 add to the second point.

// quadric spline formula ---------------------
 I just got lost in the web of quadratic stuff on the net and never could
 find a formula for the spline. So I played with what I knew about bezier
 and wrote this. It seems to work alright.

(ControlX0,ControlY0) the control point
(PointX0,PointY0)      the first point
(PointX1,PointY1)      the second point

Bx = 2 * (ControlX0 - PointX0): By = 2 * (ControlY0 - PointY0)
Ax = PointX1 - PointX0 - Bx: Ay = PointY1 - PointY0 - By

for t=0 to 1 step .01
Xp = Ax * t ^ 2 + Bx * t + PointX0  ' X funtion
Yp = Ay * t ^ 2 + By * t + PointY0 ' Y funtion
plot(Xp,Yp)
next

When it comes time to do the next curve, the control point becomes
 the next point plus the slope between the point before and the point after
  divide by 3.
----------------------------------------------------------
I hope this can help someone else.


Post a reply to this message


Attachments:
Download 'us-ascii' (3 KB)

From: Ken
Subject: Re: quadratic & cubic splines
Date: 23 Dec 1999 13:57:06
Message: <3862718D.C7E6FA62@pacbell.net>
Leroy Whetstone wrote:
> 
> Well! I finally done it. I asked a question that no one was willing or able to 
answer.
> Maybe I just asked in the wrong group.

  While this might be considered an advanced user question it is really
something that is more appropriately discussed in the programming group.
Just because we are advanced users does not mean that we understand the
programming issues behind the program itself. I am glad you found the
info you needed anyway.

-- 
Wishing you Seasons Greetings, A Merry Christmas, Happy New Millennium !
Ken Tyler -  1300+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.