note 99318 added to function.atan2
| From: | andyidol at gmail dot com | Date: | Tue, 10 Aug 2010 15:18:11 +0000 |
| Subject: | note 99318 added to function.atan2 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171533@lists.php.net to get a copy of this message | ||
This function will return degree by vertex coordinates in general trigonometrical coordinate system
where zero is located at position (1, 0), 90' at (0, 1), 180' at (-1, 0) and so on.
<?php
function GetDegree($x, $y)
{
// we don't want to cause division by zero
if($x == 0) $x = 1 / 10000;
$deg = rad2deg(atan(abs($y / $x)));
if($y >= 0) $deg = $x < 0 ? 180 - $deg : $deg;
else $deg = $x < 0 ? 180 + $deg : 360 - $deg;
return $deg;
}
?>
----
Server IP: 78.41.111.10
Probable Submitter: 78.107.255.44
----
Manual Page -- http://www.php.net/manual/en/function.atan2.php
Edit -- https://master.php.net/note/edit/99318
Del: integrated -- https://master.php.net/note/delete/99318/integrated
Del: useless -- https://master.php.net/note/delete/99318/useless
Del: bad code -- https://master.php.net/note/delete/99318/bad+code
Del: spam -- https://master.php.net/note/delete/99318/spam
Del: non-english -- https://master.php.net/note/delete/99318/non-english
Del: in docs -- https://master.php.net/note/delete/99318/in+docs
Del: other reasons-- https://master.php.net/note/delete/99318
Reject -- https://master.php.net/note/reject/99318
Search -- https://master.php.net/manage/user-notes.php