|
Hey, I'm trying to find the angle of an object from a certain point. I've tried a few things nothing seems to be working properly. I suck at explaining so here's a little drawing of what I mean:
(comments are locked)
|
This tells you the angle between the two vectors - but it's only good for 180 degrees and it will be positive no matter which way the rotation happens - did you want something else? This might work, let me give it a shot!
Jun 24 '12 at 01:25 AM
commodore
hm... there's no way to check if it goes past 180 either way is there?
Jun 24 '12 at 01:45 AM
commodore
@commodore: Best way to do it is to use the vector difference between the two points and Pythagorean's Theorem.
Jun 24 '12 at 01:51 AM
Mizuho
@commodore Ah damn I was afraid you were going to say that :)
Jun 24 '12 at 02:21 AM
whydoidoit
Try this:
Jun 24 '12 at 02:24 AM
whydoidoit
(comments are locked)
|
Here's the updated function. It uses the positive x axis as 0 and counts degrees counter-clockwise. Edit: Cleaned the code up. Maybe I'm just implementing your code wrong. It only gives me a value around 1.4.. Thanks for helping and sorry if I'm annoying or too much of a noob to understand
Jun 27 '12 at 12:59 AM
commodore
Gimme a second to throw this into my testing grounds then. I'll be back in about 10 minutes...
Jun 27 '12 at 01:06 AM
Mizuho
Thank you! I'll take a little screencap of my problem. It's most likely a problem on my end.
Jun 27 '12 at 01:08 AM
commodore
I included the debugger so you could see when I'm pressing "h"
Jun 27 '12 at 01:24 AM
commodore
That took a looong time (sorry, I became very bad at math), but I figured out a foolproof way of doing it! See my updated answer.
Jun 27 '12 at 01:34 AM
Mizuho
(comments are locked)
|

