POV-Ray : Newsgroups : povray.binaries.images : Isosurface help please : Re: Isosurface help please Server Time
19 Aug 2024 20:09:50 EDT (-0400)
  Re: Isosurface help please  
From: Mike Williams
Date: 20 Oct 2000 14:00:21
Message: <80wEwBA2wG85EwZv@econym.demon.co.uk>
Wasn't it David Fontaine who wrote:
>In order to make a Menger-sponge isosurface i want a function that will
>give me a triangular wave.
>I tried using floor, but I get a plane at x=0 where it should be empty
>space. Is this a bug? What would be a better way to get a triangle wave?
>
>isosurface {
>   function {
>      abs(x/6+3-floor(x/6+3)-.5)-2/6
>   }
>   contained_by { box { -3,3 } }
>   pigment { color rgb x }
>}

I can't imagine why you might possibly think that might lead to a
triangle wave. Any function that only involves x can only ever produce
results that are made up of x planes.

Let's try so solve this equation

    abs(x/6+3-floor(x/6+3)-.5)-2/6 = 0

The first thing we notice is that 3-floor(3) is always zero, so we can
get rid of the "+3"s.

    abs(x/6-floor(x/6)-.5)-2/6 = 0

Now, since x goes from -3 to +3 (due to the contained_by box) we can see
that x/6 goes from -0.5 to +0.5, and floor(x/6) can only be 0 or -1.

When x>0, floor(x/6) is zero, the equation reduces to

    abs(x/6-.5)-2/6 = 0

which has solutions at x=1 and x=5. The x=5 solution is outside the
contained_by box.

When x<0, floor(x/6) is -1, the equation reduces to

    abs(x/6+.5)-2/6 = 0

which has solutions at x=-1 and x=-5. The x=-5 solution is outside the
contained_by box.

So what you see is the two planes x=1 and x=-1.



If you want a sawtooth wave, try starting with something like 

   function { y - x + floor(x) }

If you want a symmetrical triangle wave, try starting with 

   function { y - abs(x-floor(x)-0.5) }


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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