POV-Ray : Newsgroups : povray.general : POV variables in parametric function : Re: POV variables in parametric function Server Time
9 Aug 2024 17:23:14 EDT (-0400)
  Re: POV variables in parametric function  
From: Mike Williams
Date: 9 Jun 2000 18:33:49
Message: <NVmYYAAdBXQ5EwNZ@econym.demon.co.uk>
Wasn't it Vaclav Cermak who wrote:
>
>Hi,
>
>  I tried to use POV variables inside function declaration in
>  paramatric surface primitive and it told me, that 
>  another variable than u and v in function definition.
>  I'am doing something bad or its normal?
>
>  I want to use it in curved stairway macro, where I 
>  need "spiral tube" to represent railing.

You can predefine your function using any kind of variable you like. If
you don't predefine the function you can't used "parametric" variables
(such as x, y, z and r) but you can use other scalar variables.

E.g. you can't say:

   parametric {
      function sin(z), . . .

because you can't use a parametric variable in that position.

You *can* say

   #declare A = 0.5;
   parametric {
      function sin(A*u), . . .

because non-parametric variables are allowed.


You can also say

   #declare F1=function(sin(z))
   parametric {
      function F1(u,v,0), . . .

but the result probably won't behave in the way you expect.

I guess that what you probably want for the handrail to a spiral
staircase is something like the following: R1 is the radius of the
staircase; R2 is the radius of the handrail tube; F controls the
frequency of the helical turns.

  #declare R1=1;
  #declare R2=0.1;
  #declare F=5;

  parametric {
    function R1*sin(F*v)+R2*sin(u),
             v,
             R1*cos(F*v)+R2*cos(u)
      <-pi,-1>,<pi,1>
      <-R1-R2,-1,-R1-R2>,<R1+R2,1,R1+R2>

But you could have achieved this result more easily with the built-in
"helix1" isosurface.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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