POV-Ray : Newsgroups : povray.text.scene-files : Re: Announce: IsoCSG include file 0.2.1 : Re: Announce: IsoCSG include file 0.2.1 Server Time
29 Jul 2024 04:17:29 EDT (-0400)
  Re: Announce: IsoCSG include file 0.2.1  
From:
Date: 15 Mar 2002 05:43:07
Message: <luj39usb6135jfhup6m7kk4s5b8u3557gp@4ax.com>
On Thu, 14 Mar 2002 15:06:20 +0100, Christoph Hormann <chr### [at] gmxde> wrote:
> Nice, now you just need the same for cones

#macro IC_Cone (Start, Radius1, End, Radius2)
  #switch(select(Radius1-Radius2,-1,0,1))
    #case(0)
      IC_Cylinder (Start, End, Radius1)
    #break
    #case(-1)
      #local temp=Start;
      #local Start=End;
      #local End=temp;
      #local temp=Radius1;
      #local Radius1=Radius2;
      #local Radius2=temp;
    #else
      #local Start=Start+<0,0,0>;

      #local Cx=Start.x;
      #local Cy=Start.y;
      #local Cz=Start.z;

      #local Len=vlength(End-Start);
      
      #if (Len=0)
        #error "iso_csg.inc: Error: zero height cone"
      #end

      #local fn_T=function { Reorient_Trans(End-Start, x)  }
      
      #local Edge=vnormalize(<Len,Radius1-Radius2,0>);
      #local Ex=Edge.x;
      #local Ey=Edge.y;

      #local fn_X=
        function(x, y){
          select(
            x,
            select(
              y-Radius1,
              -x,                                   // under bottom
              f_r(x,y-Radius1,0)                    // bottom rounded edge below
bootom plane
            ),
            select(
              x*Ex-Ey*(y-Radius1),
              f_r(x,y-Radius1,0),                   // bottom rounded edge above
bootom plane
              select(
                x*Ey+y*Ex-Radius1*Ex,
                max(-x,x-Len,x*Ey+y*Ex-Radius1*Ex), // inside and above top cone
                select(
                  x*Ex-Ey*y-(Ex*Len-Ey*Radius2),
                  x*Ey+y*Ex-Radius1*Ex,             // outside edge
                  select(
                    y-Radius2,
                    x-Len,                          // above top
                    f_r(x-Len,y-Radius2,0)          // top rounded edge
                  )
                )
              )
            )
          )
        }

      #local fn_Y=
        function(x, y, z){
          fn_X( fn_T(x, y, z).x, f_r(0,fn_T(x, y, z).y,fn_T(x, y, z).z))
        }

      function(x, y, z){
        (fn_Y((x-Cx),(y-Cy),(z-Cz)))
      }
  #end
#end

ABX


Post a reply to this message

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