POV-Ray : Newsgroups : povray.newusers : CSG Problems in drawing Arc : Re: CSG Problems in drawing Arc Server Time
2 Jun 2024 13:44:45 EDT (-0400)
  Re: CSG Problems in drawing Arc  
From: Eugene K
Date: 20 Nov 2012 13:50:00
Message: <web.50abcfb21ba8ef45479850f0@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:
> Eugene.K wrote:
>
> > BUT --  CSG still does not work; we get two lit pixels at the intersection
> > of torus and cone boundary, indicating two points of intersection,
> > but that's it!
>
> this would be easier if you post a self-contained sample scene
> (e.g. with torus_z) that other people can render for themselves.
>
> CSG usually works pretty well. Most problems come from coincident
> surfaces or not realizing that you intersect volumes, not surfaces.
>
> Note there is also a "radians" function in functions.inc.
>
> PS: Somehow you managed to format SDL to look like assembler to me ;)

Thank you for that encouragement! Sorry such long time to get back to you
 - felt need to keep digging until I got to bottom of it then wright some
bytes for complete disclosure satisfaction. Result is an 'executable'
package of four functions which is set to display the answer to my initial
arc-drawing problem. There is also some more exploratory CSG.

Problem with this is that it's more than a little bit lengthy. For now,
I will simply append the entire text to paste into a '.pov' file.
I actually have entire packages I have been working up to share,
and know not how "publish" to POV-Ray community, perhaps you could help
me with this!? - or I'll just open another topic.
You are welcome to contact me at "eug### [at] gmailcom" so I can
return you a copy as Attachment, or for any other reason.

Anyway, here comes the File! - may you have fun playing with it!
Eugene

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//    #file "arctor.demo.CB18.0200" //POV-Ray File
// #whatsit "DrawRing Arcs, Circs, and Spheres"

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//=================================================
   #version 3.6 ;
   #global_settings{ ambient_light rgb<1,1,1>/1.0 }
//
   background{ rgb<1,1,1>/2.5 }
//
   light_source{ <+1,+1,-3>*10  rgb<1,1,1>/1.0 }
//
   camera{ perspective
                 angle (360/pi)*atan(1/2) / 1.0
              location < -3/5, +2/5, -1   > * 4.0
               look_at < +0  , +0  , +0   > * 1.0 }
//=================================================
// sphere{<0,0,0>,1 texture{pigment{rgb<0,1,1>/2.0}}}  //TEST
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   #if( 1 )  object{  //TEST->  Opr Enab 'texture' at }#end
// ----------------------------------------------------------
   #declare   dThin =   0.000001 ;// ~ 0{:lnth} marginal use
   #declare  RolClk = < 0, 0,-1> ;//(+y1 around z toward +x1)
   #declare      p0 = < 0, 0, 0> ;
     #macro  rad(oDeg) (oDeg*pi/180)  #end
     #macro  deg(oRad) (oRad*180/pi)  #end
     #macro    sign(A) (1-2*(A<0))    #end
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

//===========================================================
// SQUARE CROSS-SECTION TOROID AROUND 'Z'
// replaces 4th order quartic polynomial
// rP = toroid major +radius
// rQ = toroid minor +radius = square x-sect side length/2
// ----------------------------------------------------------
     #macro  torcyl_z(rP,rQ) //cylindric toroid of plane(y,x)
// --------  ------------------------------------------------
   difference { // pA                  pB               rQ
   cylinder { <0, 0, -rQ      > , <0, 0, +rQ      > , rP+rQ }
   cylinder { <0, 0, -rQ-dThin> , <0, 0, +rQ+dThin> , rP-rQ }
              }                                          #end
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//          (  rP    rQ  )
// torcyl_z ( 1.00, 0.10 )  //<-TEST
//===========================================================
//
//==============================================
   #macro  // cone to contain hemisphere

           //"cone{pA,rA,pB,rB}"
// --------  -----------------------------------



           )
// --------  -----------------------------------
     #local  oArc = mod(abs(oApt),360+dThin)/2 ;
   #if     ( oArc < 89.99 ) //:deg
   cone { p0, 0    //null base at pA=p0, rA=0
        ,    (rSph * oOri)             //pB
        , abs(rSph)* tan(rad(oArc))    //rB
        }
   #else   //at 89.99:deg, rB=5730*rSph:lnth
   cylinder{ p0, (oOri*rSph), abs(rSph) }//limit
   #end                                     #end
//::::::::::::::::::::::::::::::::::::::::::::::
//          ( oOri  rSph  oApt )
//  hemicon ( +1*y, +1.0, +090 )  //<-TEST
//==============================================
// +
//==============================================
   #macro   //sphere contained by cone
// --------  -----------------------------------



           )
// --------  -----------------------------------
     #local  oArc = mod(abs(oApt),360+dThin) ;
   union  {
// --------  -----------------------------------
   intersection {     // (oArc <= 180)//:deg
     sphere {p0,abs(rSph)}
    hemicon (+oOri,+rSph,+oArc)
                }
// --------  -----------------------------------
        #if              (oArc  > 180)//:deg
   difference {
     sphere {p0,abs(rSph)}
    hemicon (-oOri,+rSph,-oArc+360)
              }
// --------
      #else  sphere{p0,0}               #end//if
// --------  -----------------------------------
          }                                 #end
//::::::::::::::::::::::::::::::::::::::::::::::
//         ( oOri  rSph  oApt )
//  sphcon ( +1*y, +1.0, +090 )  //<-TEST
//==============================================
//
//===========================================================
// SQUARE CROSS-SECTION ARC AROUND AXIS 'Z'
// ----------------------------------------------------------


//                               both < 0 recipro complement

// rWir : +lnth = minor radius = square x-sect side length/2
// ----------------------------------------------------------
     #macro  arctor_z(rArc,oArc,oClk,rWir)
// --------  ------------------------------------------------
     #local  oRad = rad(mod(oArc,360+dThin))/2 ;
   union                          {
// ------------
   intersection          {//half to the right...
      torcyl_z(abs(rArc),rWir)
      plane { sign(rArc)*< +cos(+oRad), -sin(+oRad), 0 >, 0 }
      plane { -1*x, 0 }  }
// ------------
   intersection          {//and half to the left
      torcyl_z(abs(rArc),rWir)
      plane { sign(rArc)*< -cos(-oRad), +sin(-oRad), 0 >, 0 }
      plane { +1*x, 0 }  }
// --------
   rotate   +oClk*RolClk          }                      #end
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//          ( rArc  oArc  oClk  rWir )
   arctor_z ( +1.0, +240, +000, 0.02 )  //<-TEST
//===========================================================
//
//===================================================
// SQUARE CROSS-SECTION 'CIRC' OF PLANE(Y,X)
// w:'curvature' = 1 / r:'radius of curvature'
// --------------------------------------------------


//                           both < 0 recipro complmt

// rWir : +lnth     = square side length/2
// --------------------------------------------------
     #macro  circtor_z(wArc,sArc,oRol,rWir)
     object                                  {
// --------  ----------------------------------------
        #if  (abs(wArc) < 0.01 ) //:(deg/lnth)
// at 0.01:deg, rArc=5730*sArc:lnth, limit -> 'line'
   cylinder{ <-sArc/2,0,0> , <+sArc/2,0,0> , rWir }
// --------  ----------------------------------------

     #local  oArc = abs(deg(sArc*rad(wArc)));// o=s/r
     #local  rArc = sArc/rad(oArc)          ;// r=s/o
// --------  ----------------------------------------
        #if  (abs(oArc)  < 360 )//:deg
     object                       {
   arctor_z (+rArc,-sign(wArc)*oArc,+000,rWir)
  translate  +rArc *sign(wArc)*y  }
// --------  ----------------------------------------
      #else//(abs(oArc) >= 360 )//:deg
     object                      {
   torcyl_z  (abs(rArc),rWir)//shrinks w incr 'Omega'
  translate  +rArc*sign(wArc)*y  }
// --------  ----------------------------------------
       #end  #end//0.01
     rotate  +oRol*RolClk                    }   #end
//:::::::::::::::::::::::::::::::::::::::::::::::::::
//           ( wArc   sArc  oRol  rWir )
// circtor_z ( +090, +2.00, +000, 0.02 )  //<-TEST
//===================================================

//:::::::::::::::::::::::::::::::::::::::::::::::::::
//->TEST End Object
    texture {pigment{rgb<0,1,1>/1.3}}  }#end//objTEST
//:::::::::::::::::::::::::::::::::::::::::::::::::::
//     #eof "arctor.demo"


Post a reply to this message

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