List Info

Thread: Translating degrees for drawing




Translating degrees for drawing
user name
2006-10-20 17:40:30
    I'm trying to draw a circle with a red indicator (line)
that 
represents wind direction.  I can draw a circle, but what I
can't figure 
out is how to draw the indicator.  The data I get reports
the direction 
in degrees.  For example, right now our wind direction is
320 (degrees), 
or in text format it reports it as Northwest.

    How can I translate that 320 degrees and have it draw a
red line 
starting in the middle of the circle to it's edge?

-- 
W | It's not a bug - it's an undocumented feature.
 
+-----------------------------------------------------------
---------
  Ashley M. Kirchner <mailto:ashleypcraft.com>   .  
303.442.6410 x130
  IT Director / SysAdmin / Websmith             .    
800.441.3873 x130
  Photo Craft Laboratories, Inc.            .     3550
Arapahoe Ave. #6
  http://www.pcraft.com
..... .  .    .       Boulder, CO 80303, U.S.A.


_______________________________________________
Magick-users mailing list
Magick-usersimagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick
-users
Translating degrees for drawing
user name
2006-10-20 19:56:44
On 10/20/06, Ashley M. Kirchner <ashleypcraft.com> wrote:
>
>    I'm trying to draw a circle with a red indicator
(line) that
> represents wind direction.  I can draw a circle, but
what I can't figure
> out is how to draw the indicator.  The data I get
reports the direction
> in degrees.  For example, right now our wind direction
is 320 (degrees),
> or in text format it reports it as Northwest.
>
>    How can I translate that 320 degrees and have it
draw a red line
> starting in the middle of the circle to it's edge?

OK, let's say that your center point is (cx, cy) and you're
drawing a
line of length L at angle A, your origin (0, 0) is in the
upper-left
corner of the image, and North is 0 degrees, East is 90,
etc. You
would draw a line from (cx, cy) to (cx + L * sin(A), cy - L
* cos(A)).

Of course, that assumes your trig functions operate on
degrees. Odds
are they use radians, so you would convert with something
like sin(A *
pi / 180).

GNS
_______________________________________________
Magick-users mailing list
Magick-usersimagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick
-users
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )