POV-Ray : Newsgroups : povray.binaries.animations : circle or spiral by spline ?? : Re: circle or spiral by spline ?? Server Time
6 Oct 2024 06:42:19 EDT (-0400)
  Re: circle or spiral by spline ??  
From: Tor Olav Kristensen
Date: 14 Oct 2004 08:17:17
Message: <416e6e4d$1@news.povray.org>
Tor Olav Kristensen wrote:
> Shurakai wrote:
> 
>> Hi everybody,
>>
>> i tried to create a perfect circle using the spline function. But 
>> somehow i
>> wasn't able to create a real circle. The problem is i can't use Chris
>> Colefax's spline macro, because it's not working with my PovRay. Always
>> produces a fatal error ??!! The prob is i need the circle defined by a
>> spline otherwise my animation debug macro will show no path for the 
>> camera.
>> Anyway is there a trick ?? I tried cubic, quadratic and natural splines,
>> but no chance, never a real circle. The spline looks always a bit weird.
>> not perfectly round. And the camera moves near and far from the focused
>> object, when going around on the spline.
>> Then i tried to create a spiral, but there i have the same problem.
>> Please if someone knows a solution, i would be happy to know it also :).
> 
> 
> I recommend that you read a little about Rational B-Splines.

It is also possible to define circle and spiral movements
with simple trigonometric expressions in some functions:

#declare X_Fn = function(R, A) { R*cos(A) }
#declare Z_Fn = function(R, A) { R*sin(A) }

#declare Steps = 50;
#declare Radius = 10;

union {
   #declare Cnt = 0;
   #while (Cnt < Steps)
     #declare Angle = radians(Cnt/Steps*360);
     #declare pPos = <X_Fn(Radius, Angle), 0, Z_Fn(Radius, Angle)>;
     sphere { pPos, 0.1 }
     #declare Cnt = Cnt + 1;
   #end // while
   texture ...
}


To get a spiral with an increasing radius:

#declare RR = Cnt/Steps*Radius;
#declare pPos = <X_Fn(RR, Angle), 0, Z_Fn(RR, Angle)>;


Another kind of spiral:

#declare Height = 8;
#declare Y_Fn = function(T) { (T/Steps - 0.5)*Height }
...
#declare pPos = <X_Fn(Radius, Angle), Y_Fn(Cnt), Z_Fn(Radius, Angle)>;


Note that all this is untested code.

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

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