09-04-2005, 06:13 PM
I need to know how to find the angle between two points. I've been told that cross products do this, but I don't have any idea what those are. Can anyone help?
PY is done
angles
|
09-04-2005, 06:13 PM
I need to know how to find the angle between two points. I've been told that cross products do this, but I don't have any idea what those are. Can anyone help?
PY is done
09-04-2005, 06:31 PM
Could you perhaps be a little more specific?
At this moment I can't give you much more advice than to look up trigonometry.
/post]
09-04-2005, 11:36 PM
well, you could get the distance
Code: d! = SQR((x2! - x1!) ^ 2 + (y2! - y1!) ^ 2) and check it against all angles, but this is indeed very time consuming, and a waste of memory, but you can optimize it but compating point one's (x1, y1) position against point two's - if x1 < x2, then it will be somewhere between 180 and 360 (left side), and if it's above, you can assume that it's only between 270 and 360. this method is very time consuming, still....but i don't know any other ones off hand Oz~
09-04-2005, 11:48 PM
Here is a way to do it, the REMs explian each part... :
[syntax="qbasic"]X01 = 10: Y01 = 10' Point 1 X02 = 40: Y02 = 40' Point 2 'Sort and find distance across IF X02 > X01 THEN XR01 = X02 - X01 IF X02 < X01 THEN XR01 = X01 - X02 'Sort and find distance up IF Y02 > Y01 THEN YR01 = Y02 - Y01 IF Y02 < Y01 THEN YR01 = Y01 - Y02 'Use distances to return angle in Radins RAD! = ATN(YR01 / XR01) 'Convert radins to degrees ANG! = (RAD! / 3.1415926535897932384626433832795 * 180) PRINT ANG![/syntax] Making that a SUB routine might be better if you intend to use it allot.. :wink:
09-05-2005, 02:50 AM
You can't get an angle between 2 points. That's just big nonsense.
Sorry just had to say this. It's too late for me to post any easy vector code that might help. Btw Rattrap: You forgot to check whether XR01 is zero. Btw... Code: IF X02 > X01 THEN XR01 = X02 - X01 Code: XR01 = Abs(X02 - X01)
09-05-2005, 04:21 AM
Hmm.... :oops:
This work better? Code: X01 = 10: Y01 = 10' Point 1
09-22-2005, 04:41 PM
Quote:I need to know how to find the angle between two points. I've been told that cross products do this, but I don't have any idea what those are. Can anyone help? Atan2. Cross product does not return the angle it returns a vector orthogonal to a plane.
09-23-2005, 11:37 PM
Or use the vector identity
a . b = a . b . cos α In which α is the angle between the two vectors. |
« Next Oldest | Next Newest »
|