POV-Ray : Newsgroups : povray.newusers : CSG Problems in drawing Arc Server Time
31 Oct 2024 22:25:18 EDT (-0400)
  CSG Problems in drawing Arc (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Eugene K
Subject: CSG Problems in drawing Arc
Date: 10 Oct 2012 20:40:01
Message: <web.50761028aeccd1571d9406540@news.povray.org>
This is my first posting; however, I have been studying and working with POV-Ray
for over two years in the general direction of spheripolar geometry for general
use as well as for study of physics, and the development of a stereo camera.  I
hope to be sharing some useful software soon, but for now it is time to ask for
help.

Given:

   #declare     x1 = +1*x ;
   #declare  rWire = 0.0100     ;// radius(wire), also coming known as 'rQ'
   #declare PitUp  = <-1, 0, 0> ;//( +z1 around x toward +y1 ) = "pitch up"
   #declare YawRgt = < 0,+1, 0> ;//( +z1 around y toward +x1 ) = "yaw right"
   #declare RolClk = < 0, 0,-1> ;//( +y1 around z toward +x1 ) = "roll clock"

.....the following functions were developed to draw an arc, and perform
satisfactorily:
////////////////////////////////////
// rArc = torus major radius  :lnth
// rWir = torus minor radius  :lnth
// oArc = arc width angle     :deg
// oClk = arc roll angle      :deg
// oRgt = arc yaw angle       :deg
////////////////////////////////////
//=============================
// TORUS AROUND THE 'Z' AXIS
// ----------------------------
     #macro  torus_z(rP,rQ)
// --------  ------------------
     object{ torus{rP,rQ}
     rotate  +090*PitUp }  #end
//=============================
// TORUS AROUND THE 'Y' AXIS
// ----------------------------
     #macro  torus_y(rP,rQ)
// --------  ------------------
             torus{rP,rQ}  #end
//=============================
//
//==================================================
// TOROIDAL ARC AROUND AXIS Z
// -------------------------------------------------
     #macro  arc_tor_z(rArc,oArc,oClk,rWir)
// --------  ---------------------------------------
      union                       {
// --------
   intersection
    { torus_z(rArc*sign(rArc),rWir)
      plane { XYZoRol(+x1, +sign(rArc)*oArc/2) , 0 }
      plane { -x1,0 }  }
// --------
   intersection
    { torus_z(rArc*sign(rArc),rWir)
      plane { XYZoRol(-x1, -sign(rArc)*oArc/2) , 0 }
      plane { +x1,0 }  }
// --------
     rotate  +oClk*RolClk         }             #end
//==================================================
// TOROIDAL ARC AROUND AXIS Y
// -------------------------------------------------
     #macro  arc_tor_y(rArc,oArc,oRgt,rWir)
// --------  ---------------------------------------
      union                       {
// --------
   intersection
    { torus_y(rArc*sign(rArc),rWir)
      plane { XYZoYaw(+x1, +sign(rArc)*oArc/2) , 0 }
      plane { -x1,0 }  }
// --------
   intersection
    { torus_y(rArc*sign(rArc),rWir)
      plane { XYZoYaw(-x1, -sign(rArc)*oArc/2) , 0 }
      plane { +x1,0 }  }
// --------
     rotate  +oRgt*YawRgt         }             #end
//==================================================

Here is a simple test call:
//                     rArc  oArc  oClk  rWir
    object{  arc_tor_z(+3.0, +090, +000, rWire)
             texture{UtilWht}  }

However, as you can see, the CSG is quite clunky...but it has been found to be

?

For example, a much cleaner way would be to use an intersection between the
torus and a cone, but it does not function in practice; even with use of 'sturm'
torus, I get only some little arc scraps on the wrong side of the supposed
intersection:
   #declare    p0 = <0,0,0> ;     //(given)
   #declare    r0 =  0      ;
//=========================================
     #macro  arc_tor_z(rArc,oArc,oClk,rWir)
// --------  ------------------------------
     #local  rX = (rArc+rWir) ;
     #local  hY = (rArc*cos(rad(oArc/2)));
// --------
     object                         {
   intersection
    { torus_z(rArc,rWir)
       cone { p0,r0
            , hY*y
            , rX  }
    }         rotate  +oClk*RolClk  }  #end
//=========================================
     #macro  arc_tor_y(rArc,oArc,oRgt,rWir)
// --------  ------------------------------
     #local  rX = (rArc+rWir) ;
     #local  hZ = (rArc*cos(rad(oArc/2))) ;
// --------
     object                         {
   intersection
    { torus_y(rArc,rWir)
       cone { p0,r0
            , hZ*z
            , rX  }
    }         rotate  oRgt*YawRgt   }  #end
//=========================================

Why does this not work?  So I thought to try using a dual-cylinder ring in place
of a torus for possibly easier rendering...
//====================================================
// square cross-sect rim in plane(^z)
// ---------------------------------------------------
     #macro  obj_cyl_z(rP,rQ)
// --------  -----------------------------------------
   difference{
         cylinder{ <0, 0, -rQ> , <0, 0, +rQ> , rP+rQ }
         cylinder{ <0, 0, -rQ> , <0, 0, +rQ> , rP-rQ }
             }                                    #end
//====================================================
// square cross-sect rim in plane(^y)
// ---------------------------------------------------
     #macro  obj_cyl_y(rP,rQ)
// --------  -----------------------------------------
   difference{
         cylinder{ <0, -rQ, 0> , <0, +rQ, 0> , rP+rQ }
         cylinder{ <0, -rQ, 0> , <0, +rQ, 0> , rP-rQ }
             }                                    #end
//====================================================
.....but this produces a pie-slice, not an arc!  Why??
CSG seems not to be functioning!  Does the first cyl need a texture or
something?

In addition, there seems to have been some sort of a special problem when
working around the trig functions, suggesting that inter-macro parameters (args
& vals) are not getting passed properly.  Now, I've done a lot of wrighting and

with these problems?  I can be strong in assembly language, but loathe the
thought of delving into the depths of C++ code, of which I know naught...time
now to Ask For Help !

Eugene.K


Post a reply to this message

From: Eugene K
Subject: Re: CSG Problems in drawing Arc
Date: 11 Oct 2012 02:30:07
Message: <web.5076669c1ba8ef451d9406540@news.povray.org>
So here I am answering my own post, with a much improved
torus-cone version to attempt drawing an arc:
//=========================================
// ARC AROUND THE 'Z' AXIS
// ----------------------------------------
     #macro  arc_tor_z(rArc,oArc,oClk,rWir)
// --------  ------------------------------
     #local  oRad = rad(oArc/2) ;
     #local  hY = (rArc*cos(oRad)+rWir) ;
     #local  rX = (rArc*sin(oRad)+rWir) ;
     debXY_f(rX,hY,"cone(rX,hY)")
// --------
   intersection                    {
     torus_z(rArc,rWir)
       cone{ p0, r0, hY*y, rX }
     rotate  +oClk*RolClk          }   #end
//=========================================
// ARC AROUND THE 'Y' AXIS
// ----------------------------------------
     #macro  arc_tor_y(rArc,oArc,oRgt,rWir)
// --------  ------------------------------
     #local  oRad = rad(oArc/2) ;
     #local  hZ = (rArc*cos(oRad)+rWir) ;
     #local  rX = (rArc*sin(oRad)+rWir) ;
     debXY_f(rX,hZ,"cone(rX,hZ)")
// --------
   intersection                    {
     torus_y(rArc,rWir)
       cone{ p0, r0, hZ*z, rX }
     rotate  +oRgt*YawRgt          }  #end
//=========================================

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   #include "arc_tor.txt"
//                     rArc  oArc  oClk  rWir
    object{  arc_tor_z(+3.0, +000, +000, rWire)
             texture{UtilWht}  }
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Here is '#DEBUG.txt' file data produced by the 'debXY( )' above
from my 'macDeb' package, showing reasonable numbers for the cone:
#debug: ###################### DEBUG MESSAGES OPENING #######################
#debug:
#debug:      2.131 :X         2.131 :Y     = cone(rX,hY)
#debug:
#debug: ###################### DEBUG MESSAGES CLOSING #######################

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!


Oh! Yes!  Version 3.6.2.msvc9 file was 'povwin362-32bit.msi', installed WinXP.

Eugene.K


Post a reply to this message

From: B  Gimeno
Subject: Re: CSG Problems in drawing Arc
Date: 11 Oct 2012 14:25:01
Message: <web.50770e791ba8ef45ae2fd8290@news.povray.org>
"Eugene.K" <eug### [at] gmailcom> wrote:
>      #local  oRad = rad(oArc/2) ;

.... among other things I'm not sure to understand... What says your manual about
the reserved word "rad"? Or is a macro written for you to pass degrees to
radians? In your published code the statements of some predefined variables
shine in his absence.

You should also read the manual about the macro "Wedge (Angle)" included in
"shapes.inc" that approaches to what you want.

Furthermore, pov-ray like any other computer program does exactly what you ask
him to do the way that you ask it ;-)


B. Gimeno


Post a reply to this message

From: Christian Froeschlin
Subject: Re: CSG Problems in drawing Arc
Date: 11 Oct 2012 15:53:22
Message: <507723b2@news.povray.org>
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 ;)


Post a reply to this message

From: Eugene K
Subject: Re: CSG Problems in drawing Arc
Date: 17 Oct 2012 01:25:07
Message: <web.507e40ab1ba8ef451d9406540@news.povray.org>
"B. Gimeno" <nomail@nomail> wrote:
> "Eugene.K" <eug### [at] gmailcom> wrote:
> >      #local  oRad = rad(oArc/2) ;
>
> .... among other things I'm not sure to understand... What says your manual about
> the reserved word "rad"? Or is a macro written for you to pass degrees to
> radians? In your published code the statements of some predefined variables
> shine in his absence.
>
> You should also read the manual about the macro "Wedge (Angle)" included in
> "shapes.inc" that approaches to what you want.
>
> Furthermore, pov-ray like any other computer program does exactly what you ask
> him to do the way that you ask it ;-)
>
>
> B. Gimeno

Thank you for your response!

//=============================================
// ARC RADIANS TO AND FROM DEGREES
// short-named for tidy trig formulae
// --------------------------------------------
   #declare  deg_rad = 180/pi ;//=(57.2957795-)
// --------
     #macro  deg(oRad)  (oRad * deg_rad)   #end
     #macro  rad(oDeg)  (oDeg / deg_rad)   #end
//=============================================
....is part of 'Core', my personal constants package;
I'd much rather write "sin(rad(oDeg))" than
"sin(radians(oDeg))", especially in tight places,
and no one else yet was using that symbol, so...?

I would like to share such packages, but don't know how yet.

I looked into 'shapes.inc' and found 'Wedge( )', which does use
at least relevant technique...thank you!

Eugene.K


Post a reply to this message

From: Eugene K
Subject: Re: CSG Problems in drawing Arc
Date: 17 Oct 2012 02:00:19
Message: <web.507e46ec1ba8ef451d9406540@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 suggestions.
My posts have been hasty, but as first ones
at least got me out into POV_Ray community.
Self-contained scene files will be a necessity for good sharing,
although my own reference several .txt-include modules.
Still whittling things down to where I have 'breadboard' scene files.

Yes, it has seemed unclear whether CSG cone{ (open?)}
has inside or not (need vector?), same for cylinder{ (open?)}
I think I need more practice of use.

I need do some more study on what is 'cone', though - got some stuff
in Oakley's 'Analytic Geometry' page 200, plus study POV implementation.

Yes, I'd much rather write "sin(rad(oDeg))" than "sin(radians(oDeg))",
especially in tight places, and symbol not yet used, so:
//=============================================
// ARC RADIANS TO AND FROM DEGREES
// short-named for tidy trig formulae
// --------------------------------------------
   #declare  deg_rad = 180/pi ;//=(57.2957795-)
// --------
     #macro  deg(oRad)  (oRad * deg_rad)   #end
     #macro  rad(oDeg)  (oDeg / deg_rad)   #end
//=============================================
......from my 'Core' custom symbols package.

Eugene.K


Post a reply to this message

From: Cousin Ricky
Subject: Re: CSG Problems in drawing Arc
Date: 24 Oct 2012 12:00:01
Message: <web.50880fa91ba8ef4578641e0c0@news.povray.org>
"Eugene.K" <eug### [at] gmailcom> wrote:
>
> //=============================================
> // ARC RADIANS TO AND FROM DEGREES
> // short-named for tidy trig formulae
> // --------------------------------------------
>    #declare  deg_rad = 180/pi ;//=(57.2957795-)
> // --------
>      #macro  deg(oRad)  (oRad * deg_rad)   #end
>      #macro  rad(oDeg)  (oDeg / deg_rad)   #end
> //=============================================
> ....is part of 'Core', my personal constants package;
> I'd much rather write "sin(rad(oDeg))" than
> "sin(radians(oDeg))", especially in tight places,
> and no one else yet was using that symbol, so...?

"Yet" is the key word.  POV-Ray reserves all-lowercase identifiers for possible
future use, although this rule is not enforced.  I suggest you change rad to Rad
and deg to Deg.


Post a reply to this message

From: B  Gimeno
Subject: Re: CSG Problems in drawing Arc
Date: 24 Oct 2012 15:10:01
Message: <web.50883cae1ba8ef45ae2fd8290@news.povray.org>
The "math.inc" standard include file provides a way for working with
trigonometric functions easilly.
Instead: sin(radians(X)), cos(radians(X)), etc...
Use: sind(X) or cosd() or tand() which works directly in *d*egrees.

B.Gimeno


Post a reply to this message

From: Eugene K
Subject: Re: CSG Problems in drawing Arc
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

From: Christian Froeschlin
Subject: Re: CSG Problems in drawing Arc
Date: 20 Nov 2012 18:24:33
Message: <50ac1131$1@news.povray.org>
Eugene.K wrote:

> 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!?

you can "publish" by posting with attached text files to p.t.scene-files
or with an attached zip file to p.b.scene-files. For resuable objects
you can also have a look at http://objects.povworld.org


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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