Sin/cos combinations to math.sincos. resolves gitlab #40288 by Alexey T minus the Amiga parts.

This commit is contained in:
marcoonthegit 2023-07-10 17:18:24 +02:00
parent 032158d943
commit fa44cd9da6
4 changed files with 16 additions and 9 deletions

View File

@ -252,8 +252,7 @@ begin
else else
begin begin
OneOverSqrt2 := 1.0 / sqrt(2.0); OneOverSqrt2 := 1.0 / sqrt(2.0);
sinx := sin(x); SinCos(x,sinx,cosx);
cosx := cos(x);
result := sqrt(2.0/(PI*x)) * result := sqrt(2.0/(PI*x)) *
( P1(x)*(OneOverSqrt2*(sinx-cosx)) ( P1(x)*(OneOverSqrt2*(sinx-cosx))
- 8.0/x*Q1(x)*(-OneOverSqrt2*(sinx+cosx)) - 8.0/x*Q1(x)*(-OneOverSqrt2*(sinx+cosx))

View File

@ -19,7 +19,7 @@ unit freetype;
interface interface
uses sysutils, classes, {$IFDEF DYNAMIC}freetypehdyn{$ELSE}freetypeh{$ENDIF}, FPImgCmn; uses sysutils, classes, math, {$IFDEF DYNAMIC}freetypehdyn{$ELSE}freetypeh{$ENDIF}, FPImgCmn;
{ TODO : take resolution in account to find the size } { TODO : take resolution in account to find the size }
{ TODO : speed optimization: search glyphs with a hash-function/tree/binary search/... } { TODO : speed optimization: search glyphs with a hash-function/tree/binary search/... }
@ -542,13 +542,20 @@ begin
end; end;
procedure TFontManager.MakeTransformation (angle:real; out Transformation:FT_Matrix); procedure TFontManager.MakeTransformation (angle:real; out Transformation:FT_Matrix);
var ScaledAngle,asin,acos : Real;
begin begin
ScaledAngle :=Angle*$10000;
with Transformation do with Transformation do
begin begin
xx := round( cos(angle)*$10000); sincos(ScaledAngle,asin,acos);
yx:=round(asin);
xx:=round(acos);
xy:=-yx; yy:=xx;
{ xx := round( cos(angle)*$10000);
xy := round(-sin(angle)*$10000); xy := round(-sin(angle)*$10000);
yx := round( sin(angle)*$10000); yx := round( sin(angle)*$10000);
yy := round( cos(angle)*$10000); yy := round( cos(angle)*$10000);
}
end; end;
end; end;

View File

@ -18,7 +18,7 @@ unit PolygonFillTools;
interface interface
uses uses
Classes, FPImage, FPCanvas, PixTools; Math, Classes, FPImage, FPCanvas, PixTools;
procedure FillPolygonSolid(Canv: TFPCustomCanvas; const Points: array of TPoint; procedure FillPolygonSolid(Canv: TFPCustomCanvas; const Points: array of TPoint;
Winding: Boolean; Color: TFPColor); Winding: Boolean; Color: TFPColor);
@ -103,8 +103,7 @@ function RotatePoint(const APoint: TPoint; Angle: Double): TPoint;
var var
sa, ca: Double; sa, ca: Double;
begin begin
sa := sin(Angle); sincos(Angle,sa,ca);
ca := cos(Angle);
Result.X := Round( ca * APoint.X + sa * APoint.Y); Result.X := Round( ca * APoint.X + sa * APoint.Y);
Result.Y := Round(-sa * APoint.X + ca * APoint.Y); Result.Y := Round(-sa * APoint.X + ca * APoint.Y);
end; end;

View File

@ -516,9 +516,11 @@ Unit UComplex;
{ sinus complex } { sinus complex }
{ sin(x+iy) = sin(x).cos(iy) + cos(x).sin(iy) } { sin(x+iy) = sin(x).cos(iy) + cos(x).sin(iy) }
{ cos(ix) = cosh(x) et sin(ix) = i.sinh(x) } { cos(ix) = cosh(x) et sin(ix) = i.sinh(x) }
var sinre,cosre : real;
begin begin
csin.re := sin(z.re) * cosh(z.im); sincos(z.re,sinre,cosre);
csin.im := cos(z.re) * sinh(z.im); csin.re := sinre * cosh(z.im);
csin.im := cosre * sinh(z.im);
end; end;
function ctg (const z : complex) : complex; function ctg (const z : complex) : complex;