Posted Sun May 13, 2007 7:24 PM
Posted Sun May 13, 2007 11:08 PM
johnnywc, on Sun May 13, 2007 9:24 PM, said:
Is DX = 0? (i.e., Is TX = SX?) Yes: Is DY = 0? (i.e., Is TY = SY?) Yes: The ship is on top of the target. Exit. No: Is DY < 0? (i.e., Is TY < SY?) Yes: The ship needs to point/move in direction 0. Exit. No: The ship needs to point/move in direction 8. Exit. End-If End-If End-If Is DY = 0? (i.e., Is TY = SY?) Yes: Is DX < 0? (i.e., Is TX < SX?) [We already checked for DX = 0.] Yes: The ship needs to point/move in direction 12. Exit. No: The ship needs to point/move in direction 4. Exit. End-If End-If Is |DX| = |DY|? [Note: These are their absolute values.] Yes: Is DX < 0? (i.e., Is TX < SX?) Yes: Is DY < 0? (i.e., Is TY < SY?) Yes: The ship needs to point/move in direction 14. Exit. No: The ship needs to point/move in direction 10. Exit. End-If No: Is DY < 0? (i.e., Is TY < SY?) Yes: The ship needs to point/move in direction 2. Exit. No: The ship needs to point/move in direction 6. Exit. End-If End-If End-IfThis takes care of the obvious cases where either DX or DY (or both) are 0, or where |DX| = |DY|. The remaining cases can either be handled with lookup tables-- IF YOU WANT THE RESULTS TO BE AS EXACT AS POSSIBLE-- or (if you don't care so much about how exact the results are) you could simply split the remaining cases between directions 1, 3, 5, 7, 9, 11, 13, and 15, without worrying whether they might actually be closer to directions 0, 2, 4, 6, 8, 10, 12, or 14.
Is DX < 0? (i.e., Is TX < DX?) Yes: Is DY < 0? (i.e., Is TY < SY?) Yes: Is |DX| < |DY|? Yes: The ship needs to point/move in direction 15. Exit. (Or: Check if it's closer to direction 14, 15, or 0.) No: The ship needs to point/move in direction 13. Exit. (Or: Check if it's closer to direction 12, 13, or 14.) End-If No: Is |DX| < |DY|? Yes: The ship needs to point/move in direction 9. Exit. (Or: Check if it's closer to direction 8, 9, or 10.) No: The ship needs to point/move in direction 11. Exit. (Or: Check if it's closer to direction 10, 11, or 12.) End-If End-If No: Is DY < 0? (i.e., Is TY < SY?) Yes: Is |DX| < |DY|? Yes: The ship needs to point/move in direction 1. Exit. (Or: Check if it's closer to direction 0, 1, or 2.) No: The ship needs to point/move in direction 3. Exit. (Or: Check if it's closer to direction 2, 3, or 4.) End-If No: Is |DX| < |DY|? Yes: The ship needs to point/move in direction 7. Exit. (Or: Check if it's closer to direction 6, 7, or 8.) No: The ship needs to point/move in direction 5. Exit. (Or: Check if it's closer to direction 4, 5, or 6.) End-If End-If End-IfAs far as the lookup tables, I would use the smaller of the two absolute values (|DX| or |DY|) and use it to find the value of the appropriate trigonometric function (sine or cosine) for the two angles that need to be tested. The table would assume that the smaller absolute value is 1, and the lookup value would then be multiplied as needed to get the appropriate value. Then you can compare the larger of the two absolute values with the two lookup values to see if the vector is between them, or lies to either side, to see which direction is closest.
Is DX < 0? (i.e., Is TX < DX?) Yes: Is DY < 0? (i.e., Is TY < SY?) Yes: Is |DX| < |DY|? Yes: Is |DY| > "5.7" * |DX|? Yes: The ship needs to point/move in direction 0. No: Is |DY| < "1.127" * |DX|? Yes: The ship needs to point/move in direction 14. No: The ship needs to point/move in direction 15. End-If End-If No: Is |DX| > "5.7" * |DY|? Yes: The ship needs to point/move in direction 12. No: Is |DX| < "1.127" * |DY|? Yes: The ship needs to point/move in direction 14. No: The ship needs to point/move in direction 13. End-If End-If End-If No: Is |DX| < |DY|? Yes: Is |DY| > "5.7" * |DX|? Yes: The ship needs to point/move in direction 8. No: Is |DY| < "1.127" * |DX|? Yes: The ship needs to point/move in direction 10. No: The ship needs to point/move in direction 9. End-If End-If No: Is |DX| > "5.7" * |DY|? Yes: The ship needs to point/move in direction 12. No: Is |DX| < "1.127" * |DY|? Yes: The ship needs to point/move in direction 10. No: The ship needs to point/move in direction 11. End-If End-If End-If End-If No: Is DY < 0? (i.e., Is TY < SY?) Yes: Is |DX| < |DY|? Yes: Is |DY| > "5.7" * |DX|? Yes: The ship needs to point/move in direction 0. No: Is |DY| < "1.127" * |DX|? Yes: The ship needs to point/move in direction 2. No: The ship needs to point/move in direction 1. End-If End-If No: Is |DX| > "5.7" * |DY|? Yes: The ship needs to point/move in direction 4. No: Is |DX| < "1.127" * |DY|? Yes: The ship needs to point/move in direction 2. No: The ship needs to point/move in direction 3. End-If End-If End-If No: Is |DX| < |DY|? Yes: Is |DY| > "5.7" * |DX|? Yes: The ship needs to point/move in direction 8. No: Is |DY| < "1.127" * |DX|? Yes: The ship needs to point/move in direction 6. No: The ship needs to point/move in direction 7. End-If End-If No: Is |DX| > "5.7" * |DY|? Yes: The ship needs to point/move in direction 4. No: Is |DX| < "1.127" * |DY|? Yes: The ship needs to point/move in direction 6. No: The ship needs to point/move in direction 5. End-If End-If End-If End-If End-IfNote that |DX| and |DY| are swapped around in some of these computations!
Edited by SeaGtGruff, Sun May 13, 2007 11:17 PM.
Posted Mon May 14, 2007 2:53 AM
Posted Mon May 14, 2007 5:54 AM
Posted Mon May 14, 2007 7:57 AM
Posted Mon May 14, 2007 8:11 AM
Posted Mon May 14, 2007 9:34 AM
Posted Mon May 14, 2007 9:57 AM
Posted Mon May 14, 2007 2:19 PM
Edited by djmips, Sat May 19, 2007 5:31 PM.
Posted Sat May 19, 2007 3:13 AM
Posted Sat May 19, 2007 5:29 PM
Heaven/TQA, on Sat May 19, 2007 2:13 AM, said:
Posted Sun May 20, 2007 10:21 AM
Heaven/TQA, on Mon May 14, 2007 1:53 AM, said:
Posted Mon May 21, 2007 3:50 PM
Heaven/TQA, on Mon May 14, 2007 1:53 AM, said:
cmp #$80 ror ror vex cmp #$80 ror ror vex cmp #$80 ror ror vex cmp #$80 ror ror vex sta vex+1
lsr ror vex lsr ror vex lsr ror vex lsr ror vex clc adc #$F8 eor #$F8 sta vex+1
Edited by djmips, Thu May 24, 2007 11:23 AM.
Posted Sun May 27, 2007 3:14 AM
Posted Sun Jun 3, 2007 12:16 AM
johnnywc, on Sun May 13, 2007 7:24 PM, said:
findtarget.bin 4K
53 downloads
target.txt 6.95K
48 downloadsPosted Sun Jun 3, 2007 12:42 AM
Robert M, on Sat Jun 2, 2007 11:16 PM, said:
Posted Sun Jun 3, 2007 1:13 AM
Posted Sun Jun 3, 2007 9:06 AM
djmips, on Sun Jun 3, 2007 1:13 AM, said:
Posted Sun Jun 3, 2007 9:21 AM
djmips, on Sun Jun 3, 2007 12:42 AM, said:
Posted Sun Jun 3, 2007 11:52 AM
Posted Sun Jun 3, 2007 4:14 PM
djmips, on Sun Jun 3, 2007 11:52 AM, said:
0 members, 1 guests, 0 anonymous users