POV-Ray : Newsgroups : povray.advanced-users : Isosurface question Server Time
28 Jul 2024 16:29:44 EDT (-0400)
  Isosurface question (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Andrew C on Mozilla
Subject: Isosurface question
Date: 20 Jul 2004 16:31:23
Message: <40fd811b@news.povray.org>
Isosurfaces... wonderful things, aren't they?

At the present moment, I have one that's going increadibly slowly. 
That's probably because of the huge max_gradiant required to draw it. 
But it surely doesn't help that I have to explain the function I want 
POV-Ray to draw in a very inefficient way...

  * * *

Suppose I have a macro like this:

#macro Fn1(x, y, z)
   #declare A = sin(x) * cos(y) * tan(z);
   #declare B = sqrt(x*y / z);
   #declare C = exp(log(x)*y - z);

   (A*B - C)*(tan(A+B)-log(C))
#end

Now, suppose I wanted to draw an isosurface of that. (I completely made 
up the function - I imagine it's not very interesting to look at!) The 
only way I can think of to draw it is something like this:

#declare Fn1 =
{
   ( (sin(x) * cos(y) * tan(z))*sqrt(x*y / z) - exp(log(x)*y - z) ) * 
(tan(sin(x) * cos(y) * tan(z) + sqrt(x*y / z)) - log(exp(log(x)*y - z)) )
}

Notice how A, B and C have to be calculated *TWICE*...

Is there any way round this??

Andrew @ home.


Post a reply to this message

From: Fredrik Eriksson
Subject: Re: Isosurface question
Date: 20 Jul 2004 17:49:55
Message: <opsbghm7g8cs6ysw@news.povray.org>
On Tue, 20 Jul 2004 21:28:14 +0100, Andrew C on Mozilla <voi### [at] devnull>  
wrote:
> #declare Fn1 =
> {
>    ( (sin(x) * cos(y) * tan(z))*sqrt(x*y / z) - exp(log(x)*y - z) ) *  
> (tan(sin(x) * cos(y) * tan(z) + sqrt(x*y / z)) - log(exp(log(x)*y - z)) )
> }
>
> Notice how A, B and C have to be calculated *TWICE*...
>
> Is there any way round this??


Something like this:


#declare Fn1_Aux =
function ( A, B, C ) {
	(A*B - C)*(tan(A+B)-log(C))
}


#declare Fn1 =
function {
	Fn_1_Aux( sin(x)*cos(y)*tan(z), sqrt(x*y / z), exp(log(x)*y - z) )
}



-- 
FE


Post a reply to this message

From: Mike Williams
Subject: Re: Isosurface question
Date: 20 Jul 2004 22:02:50
Message: <GqstUBAz6c$AFwBa@econym.demon.co.uk>
Wasn't it Andrew C on Mozilla who wrote:
>Isosurfaces... wonderful things, aren't they?
>
>At the present moment, I have one that's going increadibly slowly. 
>That's probably because of the huge max_gradiant required to draw it. 
>But it surely doesn't help that I have to explain the function I want 
>POV-Ray to draw in a very inefficient way...
>
>  * * *
>
>Suppose I have a macro like this:
>
>#macro Fn1(x, y, z)
>   #declare A = sin(x) * cos(y) * tan(z);
>   #declare B = sqrt(x*y / z);
>   #declare C = exp(log(x)*y - z);
>
>   (A*B - C)*(tan(A+B)-log(C))
>#end
>
>Now, suppose I wanted to draw an isosurface of that. (I completely made 
>up the function - I imagine it's not very interesting to look at!) The 
>only way I can think of to draw it is something like this:
>
>#declare Fn1 =
>{
>   ( (sin(x) * cos(y) * tan(z))*sqrt(x*y / z) - exp(log(x)*y - z) ) * 
>(tan(sin(x) * cos(y) * tan(z) + sqrt(x*y / z)) - log(exp(log(x)*y - z)) )
>}
>
>Notice how A, B and C have to be calculated *TWICE*...
>
>Is there any way round this??
>
>Andrew @ home.

I don't think so.

If you write

#declare A = function {sin(x) * cos(y) * tan(z)}
#declare B = function {sqrt(x*y / z)}
#declare C = function {exp(log(x)*y - z)}
   
#declare Fn1 = function {(A(x,y,z)*B(x,y,z) - C(x,y,z))
              *(tan(A(x,y,z)+B(x,y,z))-log(C(x,y,z)))}

I believe that POV still calculates A B and C twice. It certainly takes
quite a bit longer to render the surface when it's written this way than
when you write

#declare Fn1 = function {
   ( (sin(x) * cos(y) * tan(z))*sqrt(x*y / z) - exp(log(x)*y - z) ) * 
(tan(sin(x) * cos(y) * tan(z) + sqrt(x*y / z)) - log(exp(log(x)*y - z))
)}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Isosurface question
Date: 21 Jul 2004 07:04:47
Message: <40fe4dcf$1@news.povray.org>
In article <GqstUBAz6c$AFwBa@econym.demon.co.uk> , Mike Williams 
<nos### [at] econymdemoncouk>  wrote:

> I believe that POV still calculates A B and C twice. It certainly takes
> quite a bit longer to render the surface when it's written this way than
> when you write

You can "use" the sum/prod functions to create temporary real variables.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Isosurface question
Date: 21 Jul 2004 08:42:52
Message: <40fe64cc$1@news.povray.org>
Andrew C on Mozilla wrote:
> Isosurfaces... wonderful things, aren't they?
> 
> At the present moment, I have one that's going increadibly slowly. 
> That's probably because of the huge max_gradiant required to draw it. 
> But it surely doesn't help that I have to explain the function I want 
> POV-Ray to draw in a very inefficient way...
> 
>  * * *
> 
> Suppose I have a macro like this:
> 
> #macro Fn1(x, y, z)
>   #declare A = sin(x) * cos(y) * tan(z);
>   #declare B = sqrt(x*y / z);
>   #declare C = exp(log(x)*y - z);
> 
>   (A*B - C)*(tan(A+B)-log(C))
> #end
> 
> Now, suppose I wanted to draw an isosurface of that. (I completely made 
> up the function - I imagine it's not very interesting to look at!) The 
> only way I can think of to draw it is something like this:
> 
> #declare Fn1 =
> {
>   ( (sin(x) * cos(y) * tan(z))*sqrt(x*y / z) - exp(log(x)*y - z) ) * 
> (tan(sin(x) * cos(y) * tan(z) + sqrt(x*y / z)) - log(exp(log(x)*y - z)) )
> }
> 
> Notice how A, B and C have to be calculated *TWICE*...
> 
> Is there any way round this??

Yes. I once presented a solution to this.

It's halfway down in this message:

http://tinyurl.com/3f642
http://news.povray.org/povray.text.scene-files/message/%3C3fbe6e34%40news.povray.org%3E/#%3C3fbe6e34%40news.povray.org%3E
"My favourite isosurface (see p.b.i. for image)", 21. Nov. 2003


There's source code and more information in the rest of that thread:

http://tinyurl.com/6glf6
http://news.povray.org/povray.text.scene-files/thread/%3Cweb.3fbbe555cd7b5c811235fd70%40news.povray.org%3E
Started by Alex Kluchikov 19. Nov. 2003

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Isosurface question
Date: 21 Jul 2004 12:07:12
Message: <40fe94b0@news.povray.org>
Andrew C on Mozilla wrote:
...
>   #declare C = exp(log(x)*y - z);
...

Hmmm... That looks suspicious.

Are you aware that you are using the base 10 logarithm here ?

Use ln(x) for the natural logarithm.

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: Andrew C on Mozilla
Subject: Re: Isosurface question
Date: 21 Jul 2004 16:45:59
Message: <40fed607$1@news.povray.org>
> ...
> 
>>   #declare C = exp(log(x)*y - z);
> 
> ...
> 
> Hmmm... That looks suspicious.
> 
> Are you aware that you are using the base 10 logarithm here ?
> 
> Use ln(x) for the natural logarithm.

Oh, yeah, sure... it's not a real function, I just typed randomly to 
make an example.

Andrew @ home.


Post a reply to this message

From: Andrew C on Mozilla
Subject: Re: Isosurface question
Date: 21 Jul 2004 17:01:12
Message: <40fed998$1@news.povray.org>
>> #declare Fn1 =
>> {
>>   ( (sin(x) * cos(y) * tan(z))*sqrt(x*y / z) - exp(log(x)*y - z) ) * 
>> (tan(sin(x) * cos(y) * tan(z) + sqrt(x*y / z)) - log(exp(log(x)*y - z)) )
>> }
>>
>> Notice how A, B and C have to be calculated *TWICE*...
>>
>> Is there any way round this??
> 
> 
> Yes. I once presented a solution to this.
> 
> It's halfway down in this message:
> 
> http://tinyurl.com/3f642
>
http://news.povray.org/povray.text.scene-files/message/%3C3fbe6e34%40news.povray.org%3E/#%3C3fbe6e34%40news.povray.org%3E


Aaaahhhh.... I seeeee..... If a pass a variable into a second function, 
POV-Ray calculates the value to pass ONCE, and then passes it, and it 
can then be used multiple times within the second function... excellent!

The *real* function I want to render is recursive... POV-Ray reports 
412K tokens. (!!) If I can figure out how to do it this way, it will 
hopefully parse raster and render lots faster too... (Will probably have 
to use the file-I/O directives to write an SDL file, then #include it 
back in.)

Thanks for that!

Andrew @ home.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Isosurface question
Date: 21 Jul 2004 21:49:03
Message: <40ff1d0f$1@news.povray.org>
Andrew C on Mozilla wrote:
...
> Aaaahhhh.... I seeeee..... If a pass a variable into a second function, 
> POV-Ray calculates the value to pass ONCE, and then passes it, and it 
> can then be used multiple times within the second function... excellent!

Yes, you've got it.

=)

> The *real* function I want to render is recursive... POV-Ray reports 
> 412K tokens. (!!) If I can figure out how to do it this way, it will 
> hopefully parse raster and render lots faster too... (Will probably have 
> to use the file-I/O directives to write an SDL file, then #include it 
> back in.)

In this post you can find macros that build a function
recursively:

http://tinyurl.com/5d473
http://news.povray.org/povray.text.scene-files/message/%3C3C9F86D5.778C126F%40hotmail.com%3E/#%3C3C9F86D5.778C126F%40hotmail.com%3E
"Code for NURBS surfaces as mesh2{} objects ", 25. Mar. 2002

(Look at the DeCasteljau_U() and BlendUFunction() and macros.)

First I had special versions of these macros that wrote the
function to a SDL file, but for higher order NURBS functions
this quickly became ugly (i.e. HUGE files). So I let POV-Ray
assemble these functions directly.

I guess that you are working on your fractal functions. If you
don't want to generate these functions recursively, then you
might find this post (and thread) interesting:

http://tinyurl.com/6nthl
http://news.povray.org/povray.advanced-users/message/%3CXns93AC374E6D9E5torolavkhotmailcom%40204.213.191.226%3E/#%3CXns93AC374E6D9E5torolavkhotmailcom%40204.213.191.226%3E
"Re: Use of povray functions to make fractals other than
"famous" Mandelbrot with same scalability? ", 2 Jul. 2003


> Thanks for that!

Just glad to help.

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: Andrew C on Mozilla
Subject: Re: Isosurface question
Date: 22 Jul 2004 16:02:58
Message: <41001d72$1@news.povray.org>
>> Aaaahhhh.... I seeeee..... If a pass a variable into a second 
>> function, POV-Ray calculates the value to pass ONCE, and then passes 
>> it, and it can then be used multiple times within the second 
>> function... excellent!
> 
> 
> Yes, you've got it.
> 
> =)

I tried it today in my lunch break. It *seems* to go very very much 
faster this way - this WITH a higher max_gradient...

(I also figured out how to use the select() function to terminate the 
iteration sequence as soon as possible. It actually make the render many 
times SLOWER - until I changed it to return a positive number rather 
than 0 when it "bails out". Then it was lots faster!)

>> The *real* function I want to render is recursive... POV-Ray reports 
>> 412K tokens. (!!) If I can figure out how to do it this way, it will 
>> hopefully parse raster and render lots faster too... (Will probably 
>> have to use the file-I/O directives to write an SDL file, then 
>> #include it back in.)
> 
> 
> I guess that you are working on your fractal functions.

Yup.

> If you
> don't want to generate these functions recursively, then you
> might find this post (and thread) interesting:
> 
> http://tinyurl.com/6nthl
>
http://news.povray.org/povray.advanced-users/message/%3CXns93AC374E6D9E5torolavkhotmailcom%40204.213.191.226%3E/#%3CXns93AC374E6D9E5torolavkhotmailcom%40204.213.191.226%3E


Aahhh... use an *array* of functions... I wasn't sure if you could 
actually do that... yes, that saves writing an include file and reading 
it back... great!

>> Thanks for that!
> 
> Just glad to help.

Maybe you should do it for a living. ;-)

Out of interest... is there a document anywhere that explains the messy 
details of how POV-Ray's isosurface drawing system actually works? 
(Other than the source code of course. :-P)

Thanks.
Andrew @ home.


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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