mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 21:56:00 +02:00
TAChart: Replace separate sin() and cos() calls by sincos(). Issue #40473.
This commit is contained in:
parent
ffe2e33f69
commit
493a568bb0
@ -83,8 +83,7 @@ begin
|
|||||||
|
|
||||||
t := (Now() - FStartTime) * SecsPerDay;
|
t := (Now() - FStartTime) * SecsPerDay;
|
||||||
exp_factor := exp(-t/td);
|
exp_factor := exp(-t/td);
|
||||||
sin_factor := sin(TWO_PI * t / t0);
|
SinCols(TWO_PI * t / t0, sin_factor, cos_factor);
|
||||||
cos_factor := cos(TWO_PI * t / t0);
|
|
||||||
|
|
||||||
// Position: an exponentially damped sinusoidal motion
|
// Position: an exponentially damped sinusoidal motion
|
||||||
x := A0 * sin_factor * exp_factor;
|
x := A0 * sin_factor * exp_factor;
|
||||||
|
@ -65,6 +65,9 @@
|
|||||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Linking>
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<DebugInfoType Value="dsDwarf3"/>
|
||||||
|
</Debugging>
|
||||||
<Options>
|
<Options>
|
||||||
<Win32>
|
<Win32>
|
||||||
<GraphicApplication Value="True"/>
|
<GraphicApplication Value="True"/>
|
||||||
|
@ -21,7 +21,6 @@ type
|
|||||||
FInterpolate: Boolean;
|
FInterpolate: Boolean;
|
||||||
FNumXCountNeeded: Integer;
|
FNumXCountNeeded: Integer;
|
||||||
FNumYCountNeeded: Integer;
|
FNumYCountNeeded: Integer;
|
||||||
FOwnerSeries: TCustomChartSeries;
|
|
||||||
FPaletteMax: Double;
|
FPaletteMax: Double;
|
||||||
FPaletteMin: Double;
|
FPaletteMin: Double;
|
||||||
FOnChanged: TNotifyEvent;
|
FOnChanged: TNotifyEvent;
|
||||||
|
@ -1383,6 +1383,7 @@ function TPolarSeries.GetNearestPoint(const AParams: TNearestPointParams;
|
|||||||
var
|
var
|
||||||
dist: Integer;
|
dist: Integer;
|
||||||
gp: TDoublePoint;
|
gp: TDoublePoint;
|
||||||
|
sin_gpx, cos_gpx: Double;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result := false;
|
Result := false;
|
||||||
@ -1406,9 +1407,10 @@ begin
|
|||||||
if dist >= AResults.FDist then
|
if dist >= AResults.FDist then
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
SinCos(gp.x, sin_gpx, cos_gpx);
|
||||||
AResults.FDist := dist;
|
AResults.FDist := dist;
|
||||||
AResults.FIndex := i;
|
AResults.FIndex := i;
|
||||||
AResults.FValue := DoublePoint(gp.y*cos(gp.x), gp.y*sin(gp.x));
|
AResults.FValue := DoublePoint(gp.y*cos_gpx, gp.y*sin_gpx);
|
||||||
AResults.FImg := ParentChart.GraphToImage(gp);
|
AResults.FImg := ParentChart.GraphToImage(gp);
|
||||||
if dist = 0 then break;
|
if dist = 0 then break;
|
||||||
end;
|
end;
|
||||||
|
@ -893,12 +893,16 @@ procedure TGenericChartMarks.DrawLink(
|
|||||||
ADrawer: IChartDrawer; ADataPoint, ALabelCenter: TPoint);
|
ADrawer: IChartDrawer; ADataPoint, ALabelCenter: TPoint);
|
||||||
var
|
var
|
||||||
phi: Double;
|
phi: Double;
|
||||||
|
sinPhi, cosPhi: Double;
|
||||||
begin
|
begin
|
||||||
if ADataPoint = ALabelCenter then exit;
|
if ADataPoint = ALabelCenter then exit;
|
||||||
|
|
||||||
with (ADataPoint - ALabelCenter) do phi := ArcTan2(Y, X);
|
with (ADataPoint - ALabelCenter) do phi := ArcTan2(Y, X);
|
||||||
if (FLinkDistance <> 0) then
|
if (FLinkDistance <> 0) then
|
||||||
ADataPoint := ADataPoint + Point(round(FLinkDistance*cos(phi)), -round(FLinkDistance*sin(phi)));
|
begin
|
||||||
|
SinCos(phi, sinPhi, cosPhi);
|
||||||
|
ADataPoint := ADataPoint + Point(round(FLinkDistance*cosPhi), -round(FLinkDistance*sinPhi));
|
||||||
|
end;
|
||||||
|
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user