POV-Ray : Newsgroups : povray.advanced-users : Describing a perfect circle with a spline. : Re: Describing a perfect circle with a spline. Server Time
4 Oct 2024 17:05:48 EDT (-0400)
  Re: Describing a perfect circle with a spline.  
From: andrel
Date: 25 Sep 2007 16:06:30
Message: <46F96B46.8000401@hotmail.com>
Charles C wrote:
> andrel <a_l### [at] hotmailcom> wrote:
>> gregjohn wrote:
>>> For any number of points n, (n>3 if that makes it any easier), what is the
>>> simplest spline that defines a circle (value of spline at 0= start of
>>> circle, 1= back to same point).
>>>
>>> I have this fear that what I think may be a simple solution would instead be
>>> a rounded square for n=4.
>>>
>>>
>> The simple answer is that you can not make a perfect circle with
>> splines, because sin() and cos() have an infinite Taylor expansion.
>>
>> The more elaborate answer is that you can get a reasonable approximation
>> with 4 cubic splines. With more splines the approximation can be even
>> better. With two it is not even close.
>> You want to know how to define it in one spline, that I don't know. ;)
>> The 'problem' with standard splines is that not all points are treated
>> the same. Often the first and last point are on the spline whereas the
>> others are control points, indicating where 'approximately' you want the
>> spline to go. I wouldn't be surprised if there is a set of base
>> functions that are totally symmetrical and can be used for circular
>> splines, but POV does not support them (AFAIK).
>> If this question is beyond POV, I might look into the literature for you
>> and/or try to find a reasonable solution by minimizing some distance
>> function, but I would advise you to build a circle with a set of simple
>> splines (or use a very low cylinder).
> 
> 
> For any number of points? Does that mean you know how many sample points
> will be taken?  Also what do you mean by 'simple?' 
I guess that this remark is aimed at my first statement that it is 
essentially not possible. To (hopefully) clarify a bit more: splines are 
polynomials and sin() and cos() require a polynomial with infinite 
length to describe. So you can approximate a circle but never get is 
*exactly* right. That does not mean that for all practical purposes your 
solution below might give a sufficient approximation. You may even tweak 
the Scale a bit, because now all points on the curve are inside the 
circle. Increasing it a bit so that some of the curve is inside and 
another part is outside decreases the error even more.
> If you create a control
> point for each and every expected sample point, then shouldn't it be as
> 'perfect' as can be?  I'd just create a while loop going (either directly
> or in effect) from -1/n to n + (1/n) along with your
> Scale*sin(Position*2*pi) and Scale*cos(Position*2*pi) functions to create a
> cubic_spline.


Post a reply to this message

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