note 87461 modified in function.pi by danbrown

From: Date: Fri, 05 Dec 2008 23:48:10 +0000
Subject: note 87461 modified in function.pi by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147731@lists.php.net to get a copy of this message
<?php /* Returns angle of line segment in degrees. Angle will be a positive value between 0 and 360. 0 will be north, 90 east, 180 south, 270 west Author: Robert Kohr */ function get_angle($x1, $y1, $x2, $y2, $negative_y_is_up=0){ //differences in x and y $x = $x2 - $x1; $y = $y2 - $y1; //y will need to be negated for where + y is down if($negative_y_is_up){ //useful in some applications $y = -$y; } return (rad2deg(atan2($x, $y))+360)%360; } ?> --was-- /* Returns angle of line segment in degrees. Angle will be a positive value between 0 and 360. 0 will be north, 90 east, 180 south, 270 west Author: Robert Kohr */ function get_angle($x1, $y1, $x2, $y2, $negative_y_is_up=0){ //differences in x and y $x = $x2 - $x1; $y = $y2 - $y1; //y will need to be negated for where + y is down if($negative_y_is_up){ //useful in some applications $y = -$y; } return (rad2deg(atan2($x, $y))+360)%360; } http://php.net/manual/en/function.pi.php

« previous php.notes (#147731) next »