POV-Ray : Newsgroups : povray.general : Request: new simple pattern : Re: Request: new simple pattern Server Time
8 Aug 2024 10:26:28 EDT (-0400)
  Re: Request: new simple pattern  
From: Chris Huff
Date: 7 Jan 2001 10:18:07
Message: <chrishuff-076013.10194207012001@news.povray.org>
In article <3A5868E7.11DD2F4F@gmx.de>, Christoph Hormann 
<chr### [at] gmxde> wrote:

> Not sure whether it has everything you wanted, but how about:

I was about to post something similar, but I would write it:

#macro Gradient2(Vector)
    #local Len = vlength(Vector);
    #local V = Vector/Len;
    #local FX = V.x;
    #local FY = V.y;
    #local FZ = V.z;
      
    function {
        min(1, max(0, (x*FX + y*FY + z*FZ)/Len))
        // You sure about the /Len here?
    }
#end 

Probably no actual difference in parse time, and render time would be 
the same...it just computes the length and a division fewer 
times(vnormalize() computes the length and divides the vector by that).

And axis-aligned versions would be even simpler:

#declare Gradient2X = function {min(1, max(0, x))}
#declare Gradient2Y = function {min(1, max(0, y))}
#declare Gradient2Z = function {min(1, max(0, z))}

Interesting how one fairly simple looking feature (the function pattern) 
can replace so many others...

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

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