Page 1 of 1

How to position images using Polar coordination (in a circle

Posted: 2008-03-10T15:25:15-07:00
by janjaap
Dear ImageMagick Experts,

I was wondering if anyone could help me to be able to position an animated gif (dot) in a circle using Polar coordination so that I am able to use bearing (degrees) and distance to the edge as values to determ the position of the dot.

My current code is the folowing (PHP):

Code: Select all

exec("convert -size 38x38 ./images/compass_38.gif -font ./fonts/hotlink_watermark.ttf  -pointsize 9 -draw \"text  26,32 '".$distance_limit."'\" -background '#F6F4F0' \( ./images/flashing_star_10.gif -repage 0x0+".$x."+".$y."\! \) -loop 0 -crop 34x30+4+4\! ./images/result.gif;");
More information about the polar coordinate system:

http://en.wikipedia.org/wiki/Polar_coordinate_system

Image

Re: How to position images using Polar coordination (in a circle

Posted: 2008-03-10T16:07:55-07:00
by fmw42
(x-xc)=r*cos(pi*angle/180)
(y-yc)=r*sin(pi*angle/180)

where

xc=x coordinate of center of image
yc=y coordinate of center of image

r=radius
angle=bearing in degrees

Re: How to position images using Polar coordination (in a circle

Posted: 2008-03-10T16:20:03-07:00
by janjaap
Hi there!

Thanks a lot for your reply.

Do you happen to know how to do this calculation in PHP? The folowing doesn't work:

Code: Select all

$x = 14*cos(pi()*$prikker["bearing"]/180);
$y = 14*sin(pi()*$prikker["bearing"]/180);
$x = $x - 14;
$y = $y - 14;

Re: How to position images using Polar coordination (in a circle

Posted: 2008-03-10T17:25:43-07:00
by janjaap
I found the solution via Experts Exchange:

$x_z = 14;
$y_z = 14;
$R = $distance_limit;
$d = round($prikker["distance"]); // 5.5; //
$b = round($prikker["bearing"]); // 75; //

$_r = $R - $d;
$theta = 90 - $b;

$degrees = 90 - $b;
$radians = $degrees * pi() / 180;

$x = $x_z + (14 * (($R - $d) / $R) * cos($radians));
$y = $y_z - (14 * (($R - $d) / $R) * sin($radians));

$x = $x_z + (14 * ($d / $R) * cos($radians));
$y = $y_z - (14 * ($d / $R) * sin($radians));