![]() |
|
This thread is locked; no one can reply to it.
![]() ![]() |
1
2
|
Math question (2d trig) |
DanielH
Member #934
January 2001
![]() |
Here is the link again. Going down the list line by line: 1 through 5 are adjustable. You can manually change or drag the points around. 1. p1 is player position make an imaginary triangle 9. F is angle from x axis to the line p2 to p1 10 I meant to remove (it is duplicated at line 18) 11. calculate B - using the similar triangle method I described earlier (law of sines) Next 2 lines 15 and 16 I calculate collision point using both A and B {"name":"613192","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/0\/e07b47d697607193b4119438b8663fd2.png","w":576,"h":538,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/0\/e07b47d697607193b4119438b8663fd2"} 15. calculate point p3 = player + time * speed * angle this part of that is where we get bv.x and bv.y p4.x = bullet.x + time * bv.x 17, 18 and 19 are lines drawn between the points with limits put in |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
I don't see which triangles are similar. Can you let me know? I finally gave up and tried the equation I provided to Michael based on his formula and it works perfectly. I now have a little tank shooting down an airplane. I don't know if I'll develop it further, but at least now I have proof of concept. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
DanielH
Member #934
January 2001
![]() |
2 triangles. The "big" triangle has 3 sides. Side a is a vector where start is player and end is collision Side b is a vector where start is bullet and end is also collision. Side c is a vector where start is player and end is bullet We don't know time so we can't calculate a or b. We can calculate c with distance formula. "Small" triangle is a similar triangle where all sides lengths are divided by time In my example I used trig to calculate small c. Then take ratio of big c to little c to calculate time. |
Michael Weiss
Member #223
April 2000
|
Wow! I have been away for a while and I come back to find all this cool discussion. When I have time I will see if I can wrap my head around these new concepts. Thank you all for working on my little math problem. I was pretty sure there were multiple ways to get the answer.
|
|
1
2
|