POV-Ray : Newsgroups : povray.general : Extruding a function... Server Time
29 Jul 2024 00:33:58 EDT (-0400)
  Extruding a function... (Message 1 to 6 of 6)  
From: Simon
Subject: Extruding a function...
Date: 19 Jun 2007 06:57:02
Message: <4677b67e@news.povray.org>
I believe this is possible to do with isosurfaces - I'm just not very good 
at them :s

I need something like a sine wave extruded in the +z direction

If I have:
f(x) = sin(2*pi*x)

how do I get that into something like corrugated roof? I've read the 
excellent tutorial on isosurfaces <http://www.econym.demon.co.uk/isotut/> 
and can copy/paste as well as the next man but  am obviously missing 
something as I don't seem to be able to do what I need

As always, any input is greatly appreciated!


Post a reply to this message

From: Samuel Benge
Subject: Re: Extruding a function...
Date: 19 Jun 2007 10:23:49
Message: <4677e6f5$1@news.povray.org>
Simon wrote:
> If I have:
> f(x) = sin(2*pi*x)
> 
> how do I get that into something like corrugated roof?

Simon,

The cross section of a corrugated roof will be 2D, so you will need data
for at least two axes when making your roof. Here is an example:

function{
  y               // Makes a y-facing surface.
  +cos(2*pi*x)/4  // Distorts surface by adding one x-oriented wave
                  // per unit, scaled by 0.25.
}

~Sam


Post a reply to this message

From: Simon
Subject: Re: Extruding a function...
Date: 19 Jun 2007 11:40:58
Message: <4677f90a$1@news.povray.org>
Thanks very much for that :) That actually makes sense :)

I'd gone off on a tangent and actually came up witha  macro to make a mesh 
froma  given function - I'll compare the 2 to match parse times/render 
times. Also, I expect the isosurface will have a higher quality...

Again, thank you!
~S

"Samuel Benge" <stb### [at] THIShotmailcom> wrote in message 
news:4677e60d$1@news.povray.org...
> Simon wrote:
>> If I have:
>> f(x) = sin(2*pi*x)
>>
>> how do I get that into something like corrugated roof?
>
> Simon,
>
> The cross section of a corrugated roof will be 2D, so you will need data 
> for at least two axes when making your roof. Here is an example:
>
> function{
>  y  // makes a y-facing surface
>  +cos(x*pi*2)/4  // distorts surface by adding one x-oriented wave
> // per unit, scaled by 0.125
> }
>
> ~Sam


Post a reply to this message

From: Mike Williams
Subject: Re: Extruding a function...
Date: 19 Jun 2007 16:14:13
Message: <VbjWpBAGU8dGFwIM@econym.demon.co.uk>
Wasn't it Simon who wrote:
>I believe this is possible to do with isosurfaces - I'm just not very good 
>at them :s
>
>I need something like a sine wave extruded in the +z direction
>
>If I have:
>f(x) = sin(2*pi*x)
>
>how do I get that into something like corrugated roof? I've read the 
>excellent tutorial on isosurfaces <http://www.econym.demon.co.uk/isotut/> 
>and can copy/paste as well as the next man but  am obviously missing 
>something as I don't seem to be able to do what I need

Mathematically, what you want to plot is y=f(x)

I.e     y = sin(2*pi*x)

But isosurfaces evaluate expressions of the format 
        <function> = <threshold>
where threshold is a constant, so we rewrite the expression as

        y - sin(2*pi*x) = 0

isosurface {
  function { y - sin(2*pi*x) }
        max_gradient 4
        contained_by{sphere{0,5}}
        pigment {rgb 1}
}

We dont need to bother saying "threshold 0" because that's the default.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Simon
Subject: Re: Extruding a function...
Date: 19 Jun 2007 16:39:32
Message: <46783f04$1@news.povray.org>
That is very clear! Thanks Mike - If you don't mind some further 
questions...

Say we wanted to do something like an infinitely long crinkle-cut chip 
(excuse the awful description)

Dealing with 1 dimension at a time...

y<1+sin(x*2*pi)
y>-1+sin(x*2*pi + pi/2)

how can I combine the 2? - to be more precise, how do I define the "solid" 
bit as the area between the two?

If you'd rather point me at a tutorial and leave me to it, I understand but 
if you're willing to walk me through this, I'd greatly appreciate it

Thanks in advance!

NB I've used the sine wave isosurface for the curtains in an animation I'm 
posting in p.b-a if you're interested.


"Mike Williams" <nos### [at] econymdemoncouk> wrote in message 
news:Vbj### [at] econymdemoncouk...
> Wasn't it Simon who wrote:
>>I believe this is possible to do with isosurfaces - I'm just not very good
>>at them :s
>>
>>I need something like a sine wave extruded in the +z direction
>>
>>If I have:
>>f(x) = sin(2*pi*x)
>>
>>how do I get that into something like corrugated roof? I've read the
>>excellent tutorial on isosurfaces <http://www.econym.demon.co.uk/isotut/>
>>and can copy/paste as well as the next man but  am obviously missing
>>something as I don't seem to be able to do what I need
>
> Mathematically, what you want to plot is y=f(x)
>
> I.e     y = sin(2*pi*x)
>
> But isosurfaces evaluate expressions of the format
>        <function> = <threshold>
> where threshold is a constant, so we rewrite the expression as
>
>        y - sin(2*pi*x) = 0
>
> isosurface {
>  function { y - sin(2*pi*x) }
>        max_gradient 4
>        contained_by{sphere{0,5}}
>        pigment {rgb 1}
> }
>
> We dont need to bother saying "threshold 0" because that's the default.
>
> -- 
> Mike Williams
> Gentleman of Leisure


Post a reply to this message

From: Mike Williams
Subject: Re: Extruding a function...
Date: 19 Jun 2007 23:01:50
Message: <e+dEACAzfJeGFwiV@econym.demon.co.uk>
Wasn't it Simon who wrote:
>That is very clear! Thanks Mike - If you don't mind some further 
>questions...
>
>Say we wanted to do something like an infinitely long crinkle-cut chip 
>(excuse the awful description)
>
>Dealing with 1 dimension at a time...
>
>y<1+sin(x*2*pi)
>y>-1+sin(x*2*pi + pi/2)
>
>how can I combine the 2? - to be more precise, how do I define the "solid" 
>bit as the area between the two?
>
>If you'd rather point me at a tutorial and leave me to it, I understand but 
>if you're willing to walk me through this, I'd greatly appreciate it
>
>Thanks in advance!

You can use this trick to do two dimensions at once

http://www.econym.demon.co.uk/isotut/substitute.htm#thick

Like this:

     function { abs(sin(2*pi*x)-y)-0.25 }

To do four directions, you can use max() to perform the intersection of
the simpler functions.

#declare  F = function(x,y) {0.1*sin(2*pi*x)+y}

isosurface {
  function { max( F(x,y-1), F(x-0.5,-y-1), F(x,z-1), F(x-0.5,-z-1)) }
        max_gradient 1.2
        contained_by{box{<-5,-2,-2><5,2,2>}}
        pigment {rgb <0.9,0.8,0.7>}
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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