bearings
BlitzMax Forums/BlitzMax Beginners Area/bearings
| ||
how would I find the bearing of object B, from object A without using a protractor. :) I mean code in blitz. Do I have to find the sin cosin of the angle of that line between A and B? A B |
| ||
yes. what you need to learn about is vectors. I'll post a little demo program that might help you out. it is fairly straightforward. first, when you say 'bearing' i take that to mean " what angle would Object A be rotated to if Object A were Pointing at Object B" give me 5 mins... maybe 10 :) |
| ||
yep that is what I mean. so find the sin, cosin of that imaginary line between a and b then take it away from 360? |
| ||
this might be what you need: blitzmax angles are -180 to 180 (360 degrees) EDIT: |
| ||
ah yes, excellent, except that. it should calculate the A as zero all the time. because I want to get the bearing of B from A. So when i move the pointer exact to the left of A it should read 270 degrees. Exactly above = zero, to the right of A = 90. your code there is seeming to do it in half circles, as in from the right of A all the way to the left side of A = 180. But it should include the 90 degrees from the top of A until it reached the right of A. so 90 + 180 = 270. |
| ||
for that result modify line 31:Local angle = ATan2(x2-x1,y1-y2)+180 The problem is computer graphics have y axis going down the screen where as usual cartesian graphs have the positive y axis pointing up. |
| ||
Thanks skid. I updated it in the codebox above. |
| ||
thanks guys :) darn gurus... :P |
| ||
God I love it when folks post complete code examples!!! Thanks Skid and bradford6!! |