Advertisement

Getting destination with an angle

Started by February 17, 2002 04:03 PM
1 comment, last by JJXtra 23 years ago
Ive been trying to figure out how to get destination points given a certain angle. I''ve been using sin and cos for amounts moved, but Im having a problem finding edge destinations. For example, I have a ship on the screen, and it is facing at any angle (0-360), how would I check where a line from the ship intersects the edge of the screen? My res. is 1024x768. My brain is fried, any help is appreciated. Thanks- Jeff
- Jeff Johnson"He who questions training, only trains himself at asking questions" - Sphynx
Solve the equations :

left edge : x = 0
ship : x = x0 + t.cos(a), y = y0 + t.sin(a)

solve for t, that gives you the intersection with the left edge.

Lather, rinse, repeat.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
Xcellent, thank you for the help!
- Jeff Johnson"He who questions training, only trains himself at asking questions" - Sphynx

This topic is closed to new replies.

Advertisement