Oihana PHP

fixAngle.php

Table of Contents

Functions

fixAngle()  : float
Normalize an angle in degrees to the range [0, 360).

Functions

fixAngle()

Normalize an angle in degrees to the range [0, 360).

fixAngle(float|int $angle) : float

If the input is not numeric (NaN, null, etc.), the function will return 0.

Parameters
$angle : float|int

The angle in degrees.

Tags
example
echo fixAngle(370);   // 10
echo fixAngle(-90);   // 270
echo fixAngle(720.5); // 0.5
echo fixAngle(NAN);   // 0
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
float

The normalized angle between 0 (inclusive) and 360 (exclusive).


        
On this page

Search results