POV-Ray : Newsgroups : povray.general : supershapes in povray : Re: supershapes in povray Server Time
5 Nov 2024 03:16:48 EST (-0500)
  Re: supershapes in povray  
From: Mike Williams
Date: 14 Jul 2003 01:49:51
Message: <GFud$BAW6jE$EwVs@econym.demon.co.uk>
Wasn't it ingo who wrote:
>in news:pdb### [at] netplexaussieorg Paul Bourke 
>wrote:
>
>>     http://astronomy.swin.edu.au/~pbourke/surfaces/supershape3d/
>> 
>
>Paul,
>
>on that page you write "One is to use the builtin parametric primitive, 
>doing it this way would result in ...". Do you have a scene using the 
>parametric primitive available? I'd like try it with my param.inc macro ( 
>http://members.home.nl/seedseven/ ) as it uses a syntax very close to the 
>parametric primitive, but to be honest I'm too lazy to figure it out for 
>myself.

I think it goes something like this:

// Choose one of the three examples from supershape.pov
#declare Example=1;

// Suitable camera positions for each example shape
#switch (Example)
#case (1)
  camera { location  <2,1,-2> look_at <0, 0, 0>}
  #break
#case (2)  
  camera { location  <2,1,-10> look_at <0, 0, 0>}
  #break
#case (3)  
  camera { location  <-0.5,0.5,-2> look_at <0, 0, 0>}
  #break
#end

light_source {<100,200,-100> colour rgb 1}
light_source {<-100,-200,-100> colour rgb 0.5}

// ----------------------------------------

#include "param.inc"

#macro SuperShape(SS1m,SS1a,SS1b,SS1n1,SS1n2,SS1n3,SS2m,SS2a,SS2b,SS2n1,
SS2n2,SS2n3,resol) 
  #declare SS1 = function(T) { 1/
      pow( pow(abs(cos(SS1m*T/4))/SS1a,SS1n2) 
    + pow(abs(sin(SS1m*T/4))/SS1b,SS1n3), 1/SS1n1)
  }
  #declare SS2 = function(T) { 1/
      pow( pow(abs(cos(SS2m*T/4))/SS2a,SS2n2) 
     + pow(abs(sin(SS2m*T/4))/SS2b,SS2n3), 1/SS2n1)
  }

  #declare Fx=function(u,v) { SS1(u) *cos(u) *SS2(v) *cos(v) }
  #declare Fy=function(u,v) { SS1(u) *sin(u) *SS2(v) *cos(v) }
  #declare Fz=function(u,v) { SS2(v) *sin(v) }

  Parametric(Fx,Fy,Fz,<-pi/2,-pi>,<pi/2,pi>,resol,resol,"")

#end

// ----------------------------------------
// Run It

object {
  #switch (Example)
  #case (1)
    SuperShape(1,1,1   77,0.81,71.7,   8,1,1,0.63,2.92,0.24, 100)
    #break
  #case (2)  
    SuperShape(9,1,1,92,0.3,-45,  4,1,1,-0.8,88,-0.35,  39)
    #break
  #case(3)
    SuperShape(4,1,1,1,1,1,  0,1,1,1,1,1,  50)
    #break
  #end

  pigment {rgb 0.9}
  finish {phong 0.5 phong_size 10}
}



-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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