Line Arc

Hi,

I'm using the Alchemy port, but not the WCK.

I was looking through the demos and I'd like to use the LineArc shape.

Obviously, as I'm not using the WCK this means I'm going to have write it myself - which isn't a problem. I had a look through to see if I could understand how the lineArcs are implemented in the WCK, but, I couldn't really work it out.

Can anyone give a brief explanation? Or offer a possible alternative method?
Here's the lineArc function from wck.BodyShape. There's a lot here you don't need but if you look at that for() loop you can see it just creates a bunch of 2 point line shapes to approximate a curve between 2 angles. There isn't a real "arc" shape, just an approximation using lines.

Code:
      /**
       * Creates a solid semi circle using lines (two point polygons).
       */
      public function lineArc(degrees:Number = 360, sides:uint = 0, radius:Number = 0, pos:V2 = null, angle:Number = 0, detail:Number = 8):Array {
         pos ||= new V2();
         if(radius == 0) {
            radius = Util.bounds(this).top;
         }
         if(sides == 0) {
            /// Use the size of the arc to determine how many sides to use. The distance between <0,r> and <r,0> relative to the world
            /// is a good indicator of how big the arc is.
            var d:Number = Point.distance(
               Util.localizePoint(world, this, new Point(radius, 0)),
               Util.localizePoint(world, this, new Point(0, radius))
            );
            sides = Math.round(d / world.scale * detail);
         }
         var rad:Number = Util.D2R * degrees;
         var polys:Array = [];
         var v:Vector.<V2> = Vector.<V2>([new V2(0, radius)]);
         for(var i:uint = 0; i < sides; ++i) {
            v[1] = new V2(0, radius).rotate((i + 1) / sides * rad);
            orientVertices(v, pos, angle);
            polys.push(line(v[0], v[1]));
            v[0].x = v[1].x;
            v[0].y = v[1].y;
         }
         return polys;
      }
Thanks mayobutter, I'm not quite sure how I manages to miss something so obvious!

Original thread: https://box2d.org/forum/viewtopic.php?t=7575