POV-Ray : Newsgroups : povray.general : still struggling with arcs : Re: still struggling with arcs Server Time
1 Aug 2024 16:25:50 EDT (-0400)
  Re: still struggling with arcs  
From: Mike Williams
Date: 2 Aug 2005 17:09:59
Message: <Fpiy1BAZE+7CFwJf@econym.demon.co.uk>
Wasn't it Slime who wrote:
>> Is there also a way for a arc without any #while (ctr < 1)
>> sort of thing?
>> A simple arc from a torus?
>
>
>difference {
>    torus {
>        5,1
>        rotate -90*x
>    }
>    plane {
>        y,0
>    }
>}

But that doesn't hit the specified endpoints and height.

I can manage a macro that copes with cases where the endpoints have the
same y value (i.e. P1.y = P2.y) but I can't figure out the rotation of
the plane that would cope with the case where that's not the case

#macro TorusArch(P1,P2,H)
                        // horizontal distance between P1 and P2
  #local W=sqrt(pow(P2.x-P1.x,2)+pow(P2.z-P1.z,2))/2;
  difference {
    torus {1,0.05
      rotate x*90       // make it vertical
      scale <W,H,W>     // fix the width and height
                        // turn it to face the correct direction
      rotate -y*(atan2(P2.z-P1.z,P2.x-P1.x)*180/pi)
                        // move the centre of the torus to the
                        // midpoint of P1 and P2
      translate (P1+P2)/2
    }
    plane {y,0
                        // rotation to cope with P1.y != P2.y
      // rotate <??,??,??>
                        // move the centre of the rotation to the
                        // midpoint of P1 and P2
      translate (P1+P2)/2
    }
    pigment {rgb <0.5,1,0>}
  }
#end


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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