Sign in to follow this  
cptrnet

Finding the line?

Recommended Posts

How do I find the line, in 2D, that a object is moving on, such as a pong ball. So from the velocity how do I calculate the line coordinates? I need it to figure out so I can tell where the ball will hit for the computer. I am terrible at math, I don't even know what this calculation is called, so I dont know what to look for on google or here. Can anyone lend me some help. Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by cptrnet
How do I find the line, in 2D, that a object is moving on, such as a pong ball. So from the velocity how do I calculate the line coordinates? I need it to figure out so I can tell where the ball will hit for the computer. I am terrible at math, I don't even know what this calculation is called, so I dont know what to look for on google or here. Can anyone lend me some help. Thanks.


It's called the slope. Rise over run. See the definition of a line that you were supposed to learn in 7th grade. If you want, there are 30 different forms of the equation here

Share this post


Link to post
Share on other sites
They never taught me how to find the slope from a velocity. If you don't want to be helpful just don't post, don't waste the space on the forums. I wasn't in the highest math class either, you know some people struggle. I have no idea what those calculations are on that page. Am I supposed to know what everything is? If I did why would I post on here? Can someone give me a retards version of what the poster above tried to give me. Im sorry Im not as gifted as you are.

Share this post


Link to post
Share on other sites
Quote:
Original post by cptrnet
They never taught me how to find the slope from a velocity. If you don't want to be helpful just don't post, don't waste the space on the forums. I wasn't in the highest math class either, you know some people struggle. I have no idea what those calculations are on that page. Am I supposed to know what everything is? If I did why would I post on here? Can someone give me a retards version of what the poster above tried to give me. Im sorry Im not as gifted as you are.


Apart from your trolling, I'll just repeat that the slope is the velocity, which is 'rise over run', or dy/dx, or however else you want to call it.

You might try looking at formula #2 from the definition of the line web page. Since you should know all but one value (you know the starting coordinates and the slope called m), and I presume you know one of the ending coordinates (the row your paddle is on), it should be easy to figure out.

Share this post


Link to post
Share on other sites
I think you are better off doing things with vector math, as slope you can run into division by zero issues if your ball is going directly up/down.

Vector math really isnt too terribly difficult to get a grasp on, especially for 2D where you will rarely need to use cross products.

Share this post


Link to post
Share on other sites
Well, a good resource is Mathworld. Just type line in the search field and follow the first link. What you describe is a line-line intersection. You can look that up on Mathworld as well, but I doubt you'll find that as useful as what you'll find on this site. If you follow the link under resources above for Programming>>Math and Physics the first three topics under Physics Tutorials is a good place to start. Under Math you'll find an article on fast 2D line intersection. Under Programming>>Game Programming you'll find a tutorial using pong Game Programming 101 Part I.

That will get you started.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this