• Support PF! Buy your school textbooks, materials and every day products Here!

Moving ball colliding with a side of a cube

  • #1

Homework Statement



assuming the path of the ball is linear, if the ball collides with the cube, I want to find which side the cube the ball collided with. this is a discreet problem, the ball's position and velocity are always known. the cube's size is bigger than the ball's size in the way that the ball's radius is negligible in this problem, and the time step is small enough so that the change in position of the ball in different time step is also small enough.


Homework Equations



line equation using ball's current position and velocity
plane equation using 3 corners of a side of the cube

The Attempt at a Solution



I figured the collision took place once the ball just penetrates the cube, and the solution is to determine the line equation of the ball and the plane equation of the six sides of the box and determine which plane the line segment is intersecting.

the problem is I don't know how to calculate the equation of the line in 3D and equation of planes and then calculation for the intersections. I have forgotten much of the math needed to solve problems like this...
 

Answers and Replies

  • #2
CWatters
Science Advisor
Homework Helper
Gold Member
10,529
2,295
Where they touch one co-ordinate will match one of the co-ordinates of the plane and the others will be in bounds. So consider a cube with one corner at the origin (0,0,0) and another at (1,1,1). Then you can check if the surface of the ball is on one of the faces eg if any of these conditions are true..

0, 0<y<1, 0<z<1
or
1, 0<y<1, 0<z<1
or
0<x<1, 0, 0<z<1
or
0<x<1, 1, 0<z<1
or
0<x<1, 0<y<1, 0
or
0<x<1, 0<y<1, 1
 

Related Threads on Moving ball colliding with a side of a cube

Replies
11
Views
2K
Replies
5
Views
1K
  • Last Post
Replies
0
Views
2K
Replies
4
Views
1K
  • Last Post
Replies
0
Views
2K
  • Last Post
Replies
8
Views
3K
  • Last Post
Replies
6
Views
1K
Replies
6
Views
7K
Replies
1
Views
315
Top