Browse Source

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

marcoonthegit 2 years ago
parent
commit
fa44cd9da6

+ 1 - 2
packages/fcl-image/src/extinterpolation.pp

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

+ 9 - 2
packages/fcl-image/src/freetype.pp

@@ -19,7 +19,7 @@ unit freetype;
 
 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 : speed optimization: search glyphs with a hash-function/tree/binary search/... }
@@ -542,13 +542,20 @@ begin
 end;
 
 procedure TFontManager.MakeTransformation (angle:real; out Transformation:FT_Matrix);
+var ScaledAngle,asin,acos : Real;
 begin
+  ScaledAngle :=Angle*$10000;
   with Transformation do
     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);
     yx := round( sin(angle)*$10000);
     yy := round( cos(angle)*$10000);
+}
     end;
 end;
 

+ 2 - 3
packages/fcl-image/src/polygonfilltools.pp

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

+ 4 - 2
packages/rtl-extra/src/inc/ucomplex.pp

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