Archived

This topic is now archived and is closed to further replies.

JJXtra

Getting destination with an angle

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites