POV-Ray : Newsgroups : povray.newusers : Tips on code : Re: Tips on code Server Time
4 Nov 2024 13:00:18 EST (-0500)
  Re: Tips on code  
From: Jeffry Reifel
Date: 5 Aug 2003 15:20:43
Message: <3f30038b@news.povray.org>
"Loek Peters" <loe### [at] hotmailcom> wrote in message
news:3f2fa3cd$1@news.povray.org...
> Hello all
>
> Is there a way to optimize the code I have writen, or is this the shortes
> way to this shape?
>
> Thanx
> Loek Peters
>
> // begin
> #include "colors.inc"
> background { color Black }
>
> camera  {
>         location <0, 0, 10>
>         look_at  <0, 0,  -1>
>         }
>
> light_source { <1, 3, 6> color White}
>
> declare myTexture =
>         texture {
>                 pigment { color rgb <0.56,0.35,0.30> }
>                 normal { bumps 0.7 scale 0.02 }
>                 finish {ambient 0.27 diffuse 0.8 phong 0.2}
>                 }
>         }
>
> declare rod = union {
>         sphere {
>                 <0, 3, 2>, 0.5
>                 }
>         sphere {
>                 <0, -3, 2>, 0.5
>                 }
>         cylinder {
>                 <0, 3, 2>,
>                 <0, -3, 2>,
>                 0.5
>                 }
>         texture { myTexture }
>         }
>
> difference {
>         intersection{
>                 object { rod }
>                 box {
>                 <-0.6, -3.6,   1>,
>                 < 0.6, 3.6,  2>
>                 }
>                 texture { myTexture }
>         }
>                 object {rod scale <-0.7, 0.954, 0>}
>                 object {rod scale <-0.1, 0.875, 1> translate <0,0,-0.5>}
>   }
> //end
// This is as short as I could get it.

#macro _(R,O,D)blob{threshold.01cylinder{<0,3,-2><0,-3,-2>.5,1scale<R,O
>translate z*D}}#end difference{_(1,1,0)_(.7.954,0)_(.1.875.5)box{-<1,4
2><1,4,-3>}pigment{rgb<.56.35.3>}normal{bumps.7scale.02}finish{ambient
.27diffuse.8phong.2}translate z*11}light_source{<-1,3,-6>1}//rod

//Would someone like to take a crack at shortening mine?

#macro _(J,E,F)sphere{J,1,1rotate z*E-20translate<F,0,24-A>pigment{rgb
9/A}}#end#local B=-1;blob{#while(B<1)#local C=6*sin(B*5+3);#local A=3*
abs(sin(B*3));_(<B-A,C-7*B-1>,2,-4)_(<2*sin(B*3-1)+B,3*sin(B*3-3)+2*B>
,-22,-1)_(<A+B,C-7*B>,9,1)_(<A+B,C-7*B>,9,5)#local B=B+.01;#end}//jef


Post a reply to this message

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