POV-Ray : Newsgroups : povray.newusers : Soda Can model Server Time
23 Apr 2024 06:08:02 EDT (-0400)
  Soda Can model (Message 1 to 1 of 1)  
From: Seany
Subject: Soda Can model
Date: 5 Jul 2014 14:00:01
Message: <web.53b83ca660cdad186508a86b0@news.povray.org>
I am trying to model a Soda can, with the ends becoming conical (what is this
transformation called?), instead of a simple cyliner, using the following code :

    #include "colors.inc"
    #include "stones.inc"

  camera {
    location <8, 8, -23>
    look_at  <8, 8, 3>
  }


  light_source { <2, 4, -3> color White}




  #macro tube(P1, P2, r1, r2)
  #local _P3 = P1 - 0.01*(P2-P1); // V1 - 0.1*V2
  #local _P4 = P1 + 1.01*(P2-P1); // V1 + 1.1*V2

  // the inner cylinder is a little bit larger to ensure that it
  // cuts through the outer cylinder caps
  // a texture enforces a cap

  difference {
    cylinder {P1,P2,r1}
    cylinder {_P3,_P4,r2}
  }
  #end


  #macro funnel(P1, P2, r1, r2, r3, r4)
  #local _P3 = P1 - 0.001*(P2-P1); // V1 - 0.1*V2
  #local _P4 = P1 + 1.001*(P2-P1); // V1 + 1.1*V2
  difference {
    cone {P1,  r1
      P2,  r3}
    cone {_P3, r2
      _P4, r4}
  }
  #end


  #macro can(base, top, base_funnelheight, top_funnelheight, baseR, midR, topR,
thickn)

  // get the main tube

  // set the inner tube dims
  #local _innerB = (base + <0,0,base_funnelheight>) ;
  #local _innerT = (top - <0,0,top_funnelheight>) ;

  #local _innerR = (midR - thickn);



  // get the top funnel

  // get the inner cone
  #local _innerConeB_TFunnel = _innerT;
  #local _innerConeT_TFunnel = top;

  #local _innerConeB_Radius_TFunnel = _innerR;
  #local _innerConeT_Radius_TFunnel = topR - thickn;

  // get the outer cone
  #local _outerConeB_TFunnel = _innerT;
  #local _outerConeT_TFunnel = top;

  #local _outerConeB_Radius_TFunnel = midR;
  #local _outerConeT_Radius_TFunnel = topR;




  // get the bottom funnel

  // get the inner cone
  #local _innerConeB_BFunnel = base;
  #local _innerConeT_BFunnel = _innerB;

  #local _innerConeB_Radius_BFunnel = baseR - thickn;
  #local _innerConeT_Radius_BFunnel = _innerR;

  // get the outer cone
  #local _outerConeB_BFunnel = base;
  #local _outerConeT_BFunnel = _innerB;

  #local _outerConeB_Radius_BFunnel = baseR;
  #local _outerConeT_Radius_BFunnel = midR;





  // make the Can



  union{

    // make the tube
    tube(_innerB, _innerT, midR, _innerR)
    //tube(_innerB, _innerT, midR, _innerR)

    // make the top funnel
    funnel(_innerT, top, _outerConeB_Radius_TFunnel, _outerConeT_Radius_TFunnel,
_innerConeB_Radius_TFunnel, _innerConeT_Radius_TFunnel)

    // make the bottom funnel
    funnel(_innerB, base, _outerConeT_Radius_BFunnel,
_outerConeB_Radius_BFunnel, _innerConeT_Radius_BFunnel,
_innerConeB_Radius_BFunnel)
    // funnel(_innerB, base, _outerConeT_Radius_BFunnel,
_outerConeB_Radius_BFunnel, _innerConeT_Radius_BFunnel,
_innerConeB_Radius_BFunnel)
    }


  #end


  object{

   can(<8,8,2.5>, <8,8,12>, 1.25, 0.98, 5.9, 6.3, 6.2, 0.2)

  // funnel(<8,8,2.5>, <8,8,3.75>, 6.3, 5.9, 6.1, 5.7)


  texture{ pigment{ color rgbf<0.2,0.7,0.5,0.14>}
             finish { phong 0.2 }}


             rotate <-90, 0, 0>
         translate < 0, 0, 3>
        // scale <0.5, 0.5, 0.5>
  }

The problem is, while the top funnel admits the same thickness as the middle
section, the bottom funnel is much thicker.

What can I do to solve it?


Post a reply to this message

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