TPolarSeries
Posted: Thu Sep 16, 2004 6:12 pm
Does anyone have an algorithm to plot a circle about a non centered point using a TPolarSeries?
Steema Software - Customer Support Forums
http://493266.hkjq7.group/support/
Code: Select all
// angles measured in radians
procedure TransformCoord(const r0,a0: double; var angle, radius: double);
var x,y: double;
begin
x := r0*cos(a0) + radius*cos(angle);
y := r0*cos(a0) + radius*sin(angle);
radius := Sqrt(Sqr(x)+Sqr(y));
angle := ArcTan2(y,x);
end;
procedure TForm1.FormCreate(Sender: TObject);
var t: Integer;
r,a: Double;
begin
Series1.GetVertAxis.SetMinMax(0,200);
Series1.XValues.Order := loNone;
// draw circle with radius 25 at r0=100, angle = 2*Pi/3
for t:= 1 to 20 do
begin
// local coordinates
r := 25;
a := 2*Pi*t/20.0;
// transform to global coords
TransformCoord(100,2*Pi/3.0,a,r);
// angle to degrees
a := a* 180.0/Pi;
Series1.AddPolar(a,r);
end;
end;