note 70986 added to function.imageline
| From: | IanB at osu1 dot php dot net | Date: | Tue, 07 Nov 2006 11:59:22 +0000 |
| Subject: | note 70986 added to function.imageline | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119461@lists.php.net to get a copy of this message | ||
Here's a function to plot a line on a polar coordinate system:
<?php
function imagepolarline($image,$x1,$y1,$length,$angle,$color)
{
$x2 = $x1 + sin( deg2rad($angle+90) ) * $length;
$y2 = $y1 + cos( deg2rad($angle+90) ) * $length;
imageline($image,$x1,$y1,$x2,$y2,$color);
}
?>
x1,y1 are the coordinates for the central point. If you want the orientation to be like a compass
i.e. 90 degrees = East, 180 = South etc, then use the following:
$x2 = $x1 + cos( deg2rad($angle-90)) * $length;
$y2 = $y1 + sin( deg2rad($angle-90)) * $length;
----
Server IP: 203.16.234.91
Probable Submitter: 59.100.3.105
----
Manual Page -- http://www.php.net/manual/en/function.imageline.php
Edit -- https://master.php.net/note/edit/70986
Del: integrated -- https://master.php.net/note/delete/70986/integrated
Del: useless -- https://master.php.net/note/delete/70986/useless
Del: bad code -- https://master.php.net/note/delete/70986/bad+code
Del: spam -- https://master.php.net/note/delete/70986/spam
Del: non-english -- https://master.php.net/note/delete/70986/non-english
Del: in docs -- https://master.php.net/note/delete/70986/in+docs
Del: other reasons-- https://master.php.net/note/delete/70986
Reject -- https://master.php.net/note/reject/70986
Search -- https://master.php.net/manage/user-notes.php