POV-Ray : Newsgroups : povray.advanced-users : SuperCone Server Time
4 Nov 2024 17:38:00 EST (-0500)
  SuperCone (Message 1 to 2 of 2)  
From: Nieminen Mika
Subject: SuperCone
Date: 30 Jul 1999 03:46:03
Message: <37a1583b@news.povray.org>
The SuperCone macro allows you to specify a cone which have two radiuses
in both ends (ie. the ends are elliptical).
  Example scene:

camera { location <6,5,-10> look_at 0 angle 35 }
light_source { <100,100,-20>,1 }
plane { y,-1.5 pigment { checker rgb 1, rgb .5 } }

object
{ SuperCone(<0,-1.5,0>,1,2, <0,1.5,0>,1,.5)
  pigment { rgb x } finish { specular .5 }
}

  And the macro:

----------------------------------------------------------------------------
#macro SuperCone(end1,a,b,end2,c,d)
  intersection
  { quartic
    { <0, 0,  0,  0, 0,   0,   0,  b*b-2*b*d+d*d, 2*(b*d-b*b), b*b,
       0,  0,   0,  0,   0,  0, 0,  0,  0, 0,
       0, 0,  0, a*a-2*a*c+c*c, 2*(a*c-a*a), a*a, 0,  0,  0, 0,
       -(a*a-2*a*c+c*c)*(b*b-2*b*d+d*d),
       -(2*((b*d-b*b)*(a*a-2*a*c+c*c)+(a*c-a*a)*(b*b-2*b*d+d*d))),
       -(b*b*(a*a-2*a*c+c*c)+4*(a*c-a*a)*(b*d-b*b)+a*a*(b*b-2*b*d+d*d)),
       -(2*(b*b*(a*c-a*a)+a*a*(b*d-b*b))), -a*a*b*b>
      sturm
    }
    cylinder { 0, z, max(max(a,b),max(c,d)) }
    bounded_by { cone { 0, max(a,b), z, max(c,d) } }
    
    #local Dirv=end2-end1;
    scale <1,1,vlength(Dirv)>
    #local VX1=z;
    #local VX2=vnormalize(Dirv);
    #local VY=vcross(VX2,VX1);
    #if(vlength(VY)>0)
      #local VY=vnormalize(VY);
      #local VZ1=vcross(VY,VX1);
      #local VZ2=vcross(VY,VX2);
      matrix < VX1.x, VY.x, VZ1.x,
               VX1.y, VY.y, VZ1.y,
               VX1.z, VY.z, VZ1.z,
               0     0      0 >
 
      matrix < VX2.x, VX2.y, VX2.z,
               VY.x,  VY.y,  VY.z,
               VZ2.x, VZ2.y, VZ2.z,
               0,     0,     0 >
    #end
    translate end1
  }
#end
----------------------------------------------------------------------------

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Nieminen Juha
Subject: Re: SuperCone
Date: 24 Aug 1999 08:05:36
Message: <37c28a90@news.povray.org>
I noticed that the code doesn't work well if you specify a negative
radius. With a very little modification it will work also with negative
radiuses:

#macro SuperCone(end1,a,b,end2,c,d)
  intersection
  { quartic
    { <0, 0,  0,  0, 0,   0,   0,  b*b-2*b*d+d*d, 2*(b*d-b*b), b*b,
       0,  0,   0,  0,   0,  0, 0,  0,  0, 0,
       0, 0,  0, a*a-2*a*c+c*c, 2*(a*c-a*a), a*a, 0,  0,  0, 0,
       -(a*a-2*a*c+c*c)*(b*b-2*b*d+d*d),
       -(2*((b*d-b*b)*(a*a-2*a*c+c*c)+(a*c-a*a)*(b*b-2*b*d+d*d))),
       -(b*b*(a*a-2*a*c+c*c)+4*(a*c-a*a)*(b*d-b*b)+a*a*(b*b-2*b*d+d*d)),
       -(2*(b*b*(a*c-a*a)+a*a*(b*d-b*b))), -a*a*b*b>
      sturm
    }
    cylinder { 0, z, max(max(abs(a),abs(b)),max(abs(c),abs(d))) }
    bounded_by { cone { 0, max(abs(a),abs(b)), z, max(abs(c),abs(d)) } }
    
    #local Dirv=end2-end1;
    scale <1,1,vlength(Dirv)>
    #local VX1=z;
    #local VX2=vnormalize(Dirv);
    #local VY=vcross(VX2,VX1);
    #if(vlength(VY)>0)
      #local VY=vnormalize(VY);
      #local VZ1=vcross(VY,VX1);
      #local VZ2=vcross(VY,VX2);
      matrix < VX1.x, VY.x, VZ1.x,
               VX1.y, VY.y, VZ1.y,
               VX1.z, VY.z, VZ1.z,
               0     0      0 >
 
      matrix < VX2.x, VX2.y, VX2.z,
               VY.x,  VY.y,  VY.z,
               VZ2.x, VZ2.y, VZ2.z,
               0,     0,     0 >
    #end
    translate end1
  }
#end


-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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