POV-Ray : Newsgroups : povray.binaries.images : Just in time for Christmas, Hopefully : Re: Just in time for Christmas, Hopefully Server Time
2 Aug 2024 08:11:57 EDT (-0400)
  Re: Just in time for Christmas, Hopefully  
From: Tim Attwood
Date: 17 Dec 2007 06:13:12
Message: <476659c8$1@news.povray.org>
> I've tried everything that's been suggested, so far, but nothing - aside 
> from
> decreasing the number of control points - had any effect.  And decreasing 
> the
> number of control points messed up my uv_mapping.
>
> I'm posting the code for the bulb, if anyone can help me, I'd be grateful.

The problem is too many control points in a small space.
This is similar to other floating point accuracy issues, because
of floating point errors some of the points in your lathe are
doubling back, or coincident. A work-around is to scale up your
lathe's control points, then scale down the lathe to the desired size.

#macro ChristmasBulb(bulbMaterial, capMaterial, isMapped, Transform)

// These parameters control the size of the bulb.
// The cap translation is linked to these parameters
#local r = 125;
#local r2 = 50;
#local T = 3.125;

/* !--- DO NOT CHANGE THESE EQUATIONS. ---! */
#local h = sqrt(pow(r,2) - pow(r2,2));
#local s = degrees(atan(h/r2));

merge {
   lathe {
      linear_spline
      3338,

      #local a = 0;
      #while(a < s+90)
         #local P = vrotate(-r*y, a*z);

         <P.x, P.y>

        #local a = a + (s+90)/1500;
      #end


 #local b = s ;
 #while(b > 0)
 #local P = vrotate(-r2*x, b*z);

      <(r2+(r2*cos(radians(s))))+P.x,
       (r*sin(radians(s)))+(r2*sin(radians(s)))+P.y>

 #local b = b - s/169;
 #end
 #local c = 0;
 #while(c < s)
 #local P = vrotate(-(r2+T)*x, c*z);

  <(((r-T)*cos(radians(s)))+((r2+T)*cos(radians(s))))+P.x,
   ((r-T)*sin(radians(s)))+((r2+T)*sin(radians(s)))+P.y>

 #local c = c + s/169;
 #end
 #local d = s+90;
 #while(d > 0)
 #local P = vrotate(-(r-T)*y, d*z);

  <P.x, P.y>

 #local d = d - (s+90)/1500;
 #end
 #if(isMapped)
  uv_mapping
 #end
  }

  hollow on
  material { bulbMaterial }
   scale 1/100
   transform { Transform }
 }

// A plain, silver Bulb cap.  Not parameterized.
difference {
 union {
  cylinder { -0.15625*y, 0.0 0.25 }
  cylinder { -0.15625*y, 0.03125*y 0.21875 }
  torus { 0.21875, 0.03125 }
  torus { 0.21875, 0.03125 translate -0.15625*y }
  torus { 0.125, 0.0078125 rotate 90.0*x translate 0.109375*y }
  }
 cylinder { -0.21875*y, 0.0 0.21875 }
  material { capMaterial }
   photons { target reflection on refraction off }
   transform {
    translate ((r/100*sin(radians(s)))+(r2/100*sin(radians(s))))*y
    Transform
    }
 }

#debug concat("Max Height: " str((r*sin(radians(s)))+(r2*sin(radians(s))), 
0, 6)
"\n")

#end


Post a reply to this message

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