Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

Box to wall collision in C

OpenStudy (anonymous):

I have a program I need to write in C that has a ball start at a randomly seeded origin point within a 2D box. From there, it uses a command line argument to decide the angle the ball is projected at. From there, we need to find the angle it bounces off, and how far away from the origin it was. Any ideas?

OpenStudy (e.mccormick):

When you look at a bounce off a flat surface, the direction is based on the angle. How you are going to do it is all goin to depend on how you are getting the slope or angle. |dw:1412355408367:dw|

OpenStudy (e.mccormick):

That leads to this: |dw:1412355433131:dw|

OpenStudy (e.mccormick):

By slope, note the difference is just the sign change on y. |dw:1412355553352:dw| By angle, you can find angles that match and do some math. and A+B=180 degrees, so you can do some angle math. |dw:1412355651995:dw|

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Breathless: Spooky witch but cute
6 hours ago 3 Replies 0 Medals
Arriyanalol: help
6 hours ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
1 day ago 5 Replies 4 Medals
Jaded012023: Please tell me what you all think of this song
9 hours ago 6 Replies 1 Medal
Arriyanalol: bro how
9 hours ago 2 Replies 3 Medals
Arriyanalol: cant wait for the new bluey movie in 2027
1 day ago 12 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!