|
 |
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
|
 |