POV-Ray : Newsgroups : povray.binaries.images : Super Shapes with isosurface : Re: Super Shapes with isosurface Server Time
19 May 2024 06:02:12 EDT (-0400)
  Re: Super Shapes with isosurface  
From: Hans de Vries
Date: 22 Mar 2004 22:17:04
Message: <405fac30$1@news.povray.org>
The simplest version for the time being below. It speeds things up with circa 25%
The trick is to get the right ranges for theta (-pi..+pi) and phi (-pi/2..+pi/2)
and avoiding divides by zero.

#macro Super_Function_3D (m1, a1, b1, n11, n21, n31, m2, a2, b2, n12, n22, n32 )

   isosurface {
     function {
                pow(  pow(abs(cos(0.25*m2*(f_ph(x,z,y)-pi/2))/a2),n22)  +
                      pow(abs(sin(0.25*m2*(f_ph(x,z,y)-pi/2))/b2),n32)
                    ,1/n12)  *

                pow(  pow(abs(cos(0.25*m1*atan2(x,y))/a1),n21)  +
                      pow(abs(sin(0.25*m1*atan2(x,y))/b1),n31)
                    ,1/n11)  *

                    f_r(x,y,z)
                - 1
              }
     max_gradient 20
     contained_by { box { <-2,-2,-2>,<2,2,2> } }
    }

#end

Regards, Hans

Tor Olav Kristensen wrote:
> Hans de Vries wrote:
> ...
> 
>>     function {
>>                pow(  
>> pow(abs(cos(0.25*m2*asin(z/sqrt(x*x+y*y+z*z)))/a2),n22)  +
>>                      
>> pow(abs(sin(0.25*m2*asin(z/sqrt(x*x+y*y+z*z)))/b2),n32)
>>                    ,1/n12)  *
>>
>>                pow(  
>> pow(abs(cos(0.25*m1*acos(y/sqrt(x*x+y*y))*abs(y)/y)/a1),n21)  +
>>                      
>> pow(abs(sin(0.25*m1*acos(y/sqrt(x*x+y*y))*abs(y)/y)/b1),n31)
>>                    ,1/n11)  *
>>
>>                    sqrt (x*x+y*y+z*z)
>>                - 1
>>              }
> 
> ...
> 
> You can _try_ to increase the rendering speed, by replacing
> 'sqrt(x*x+y*y+z*z)' with 'f_r(x, y, z)' and 'sqrt(x*x+y*y)'
> with 'f_r(x, y, 0)'.
> 
> Also you should have a look at the internal functions;
> 'f_th()' and 'f_ph()'.
> 
> http://www.povray.org/documentation/view/244/
> 
> Because it seems like these may enable you to simplify some
> of your inverse trigonometric expressions.
> 
> E.g. this one: 'acos(y/sqrt(x*x+y*y))*abs(y)/y'
> 
> In order to use these functions, you must first include the
> 'functions.inc' file.
> 
> P.S.: antan2() is also useful.
> 
>


Post a reply to this message

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