POV-Ray : Newsgroups : povray.binaries.images : iso-sphere-sweep - second example : Re: iso-sphere-sweep - second example Server Time
16 Aug 2024 18:18:35 EDT (-0400)
  Re: iso-sphere-sweep - second example  
From: Tor Olav Kristensen
Date: 4 Jan 2002 22:40:14
Message: <3C367532.90EB725D@hotmail.com>
Tor Olav Kristensen wrote:
>...
> #macro CylinderFunction(pA, pB, Radius)
> 
>   #local Ax = pA.x;
>   #local Ay = pA.y;
>   #local Az = pA.z;
>   #local vL = pB - pA;
>   #local Lx = vL.x;
>   #local Ly = vL.y;
>   #local Lz = vL.z;
>   #local LL = vdot(vL, vL);
>   #local vD = vL/LL;
>   #local Dx = vD.x;
>   #local Dy = vD.y;
>   #local Dz = vD.z;
>   #local AD = vdot(pA, vD);
> 
>   function {
>     sqrt(
>       (x - Ax - max(0, min(x*Dx + y*Dy + z*Dz - AD, 1))*Lx)^2
>      +(y - Ay - max(0, min(x*Dx + y*Dy + z*Dz - AD, 1))*Ly)^2
>      +(z - Az - max(0, min(x*Dx + y*Dy + z*Dz - AD, 1))*Lz)^2
>     )
>    -Radius
>   }
> 
> #end // macro CylinderFunction
>...

If one includes functions.inc, then the
function above can be written like this:

function {
  f_sphere(
    x - Ax - max(0, min(x*Dx + y*Dy + z*Dz - AD, 1))*Lx,
    y - Ay - max(0, min(x*Dx + y*Dy + z*Dz - AD, 1))*Ly,
    z - Az - max(0, min(x*Dx + y*Dy + z*Dz - AD, 1))*Lz,
    Radius
  )
}

This might render faster because of the use of
the internal sphere function, but I have not
found clear evidence of that yet.


Tor Olav


Post a reply to this message

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