[DUG] Arc Solved

Marshland Engineering marshland at marshland.co.nz
Thu Jan 20 15:38:35 NZDT 2011


The problem came in with the interpreation

DELPHI The arc traverses the perimeter of an ellipse that is bounded by the points (X1,Y1) and (X2,Y2). The arc is drawn following the perimeter of the ellipse, counterclockwise, from the starting point to the ending point.

Is the arc or the ellipse bounded by (X1Y1)  (X2Y2)? 

It is actually the ellipse.

The solution is quite simple.  (With the help of Jolyon - Thanks )

         xCtr:=DM.tblOperX1.AsFloat;
         yCtr:=DM.tblOperY1.AsFloat;
         if (dm.tblOper['CW']=False) then  begin
            xStart:=DM.tblOperX2.AsFloat;
            yStart:=DM.tblOperY2.AsFloat;
            xEnd:=DM.tblOperX3.AsFloat;
            yEnd:=DM.tblOperY3.AsFloat;
            end
           else begin
            xStart:=DM.tblOperX3.AsFloat;  //Swop start and end 
            yStart:=DM.tblOperY3.AsFloat;
            xEnd:=DM.tblOperX2.AsFloat;
            yEnd:=DM.tblOperY2.AsFloat;
         end;
         rad:=sqrt(sqr(xStart-xCtr)+sqr(yStart-yCtr));
         TopRH:=round((yCtr+rad)*Scale)+Hoffset;
         TopRV:=round((xCtr-rad)*Scale)+Voffset;
         BotLH:=round((yCtr-rad)*Scale)+Hoffset;
         BotLV:=round((xCtr+rad)*Scale)+Voffset;
         StartH:=round(yStart*Scale)+Hoffset;
         StartV:=round(xStart*Scale)+Voffset;
         EndH:=round(yEnd*Scale)+Hoffset;
         EndV:=round(xEnd*Scale)+Voffset;
         fDraw.Canvas.Arc(TopRH,TopRV,BotLH,BotLV,StartH,StartV,EndH,EndV);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20110120/131aa39a/attachment.html 


More information about the Delphi mailing list