Difference between revisions of "FixD"

From SCAR Divi Manual
Jump to: navigation, search
(Definition)
(Definition)
Line 13: Line 13:
 
   Result := Abs(Degrees);
 
   Result := Abs(Degrees);
 
   Result := (Floor(Result) mod 360 + DecRet(Result)) * t;
 
   Result := (Floor(Result) mod 360 + DecRet(Result)) * t;
   if Result < 0 then Inc(Result, 360);
+
   if Result < 0 then Result := Result + 360;
 
end;
 
end;
 
</source>
 
</source>

Revision as of 10:18, 1 July 2011

Definition

function FixD(Degrees: Extended): Extended;

Source

function FixD(Degrees: Extended): Extended;
var
  t: Integer;
begin
  if Degrees < 0 then t := -1 else t := 1;
  Result := Abs(Degrees);
  Result := (Floor(Result) mod 360 + DecRet(Result)) * t;
  if Result < 0 then Result := Result + 360;
end;

Availability

SCAR Divi 3.00 > Current

Description

Fixes an angle specified by Degrees in degrees by adding/subtracting 360 until the value is larger than or equals 0 and is smaller than or equals 360.

Example

begin
  WriteLn(FixD(25));
  WriteLn(FixD(385));
end.

Output:

25
25

See Also