Browse Source

* Added DegNormalize

git-svn-id: trunk@27492 -
michael 11 years ago
parent
commit
d45ced0221
1 changed files with 34 additions and 0 deletions
  1. 34 0
      rtl/objpas/math.pp

+ 34 - 0
rtl/objpas/math.pp

@@ -244,6 +244,15 @@ function gradtodeg(grad : float) : float;inline;
 { one cycle are 2*Pi rad }
 function cycletorad(cycle : float) : float;inline;
 function radtocycle(rad : float) : float;inline;
+{$ifdef FPC_HAS_TYPE_SINGLE}
+Function DegNormalize(deg : single) : single; inline;
+{$ENDIF}
+{$ifdef FPC_HAS_TYPE_DOUBLE}
+Function DegNormalize(deg : double) : double; inline;
+{$ENDIF}
+{$ifdef FPC_HAS_TYPE_EXTENDED}
+Function DegNormalize(deg : extended) : extended; inline;
+{$ENDIF}
 
 { trigoniometric functions }
 
@@ -670,6 +679,31 @@ function radtocycle(rad : float) : float;inline;
      radtocycle:=rad*(1/(2*pi));
   end;
 
+{$ifdef FPC_HAS_TYPE_SINGLE}
+Function DegNormalize(deg : single) : single; 
+
+begin
+  Result:=Deg-Trunc(Deg/360)*360;
+  If Result<0 then Result:=Result+360;
+end;
+{$ENDIF}
+{$ifdef FPC_HAS_TYPE_DOUBLE}
+Function DegNormalize(deg : double) : double; inline;
+
+begin
+  Result:=Deg-Trunc(Deg/360)*360;
+  If (Result<0) then Result:=Result+360;
+end;
+{$ENDIF}
+{$ifdef FPC_HAS_TYPE_EXTENDED}
+Function DegNormalize(deg : extended) : extended; inline;
+
+begin
+  Result:=Deg-Trunc(Deg/360)*360;
+  If Result<0 then Result:=Result+360;
+end;
+{$ENDIF}
+
 {$ifndef FPC_MATH_HAS_TAN}
 function tan(x : float) : float;
   var