Advertisement

Angles! Argh!

Started by February 16, 2003 05:14 PM
3 comments, last by Jay Provoni 21 years, 9 months ago
Hi. I have a problem that should be simple but i''m well and truly confused now... (I;m using VB btw). I a box with a point in the centre (at co-ord 50, 50) You can move the mouse around. What I need is to calculate the angle from the mouse pointer to the origin, in degrees (that is, if the pointer is above and to the left of the origin the result should be somewhere between 270 and 359 degrees). I''m getting very stuck; one problem is that VB uses radians and I keep ending up with divide by 0 errors. Thanks in advance :-) This is embarrassing being stuck on elementary math!
atan2 will calculate angles easily with out you needing to worry about dividing by zero and weather one or both of them are negetive and crap like that. Then to convert the result to degrees, multiply by 180 and divide by pi.

[edit]

atan2 is part of the c math library, I'm not sure if VB has it. Good luck anyway.

[edited by - smart_idiot on February 16, 2003 7:23:55 PM]
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Advertisement
Ah cheers :-)
Thats just what i was looking for!
Thanks again.
JP.
Ah cheers :-)
Thats just what i was looking for!
Thanks again.
JP.
In case anyone is looking at this thread in retrospect for help:
see also
http://www.visualbasicforum.com/t22104.html

This topic is closed to new replies.

Advertisement