TPolarSeries
TPolarSeries
Does anyone have an algorithm to plot a circle about a non centered point using a TPolarSeries?
Hi.
All you have to do is transform values from local coordinate system to global angle,radius. The following code should explain what I meant:
Alternatively, if you only want to draw circle, not related to series points at specific coordinates, all you have to do is manually draw using TChart.Canvas.Circle method in TChart OnAfterDraw event.
All you have to do is transform values from local coordinate system to global angle,radius. The following code should explain what I meant:
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;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com