2D Point Collisions
For this programming assignment, you will implement a Java class that represents simple particles in twoo dimensional space. These particles have no mass and there are no external forces acting on these particles. Each particle has a location and a velocity. For this part of the assignment, we only want to be able to do a couple of things with particles:
- Create a particle: when it is created, each particle must be given a position and velocity
- Move a particle: update time (by adding to the current time)
- Find out where a particle is: get the position of a particle
- Determine if two particles will collide
- Determine when two particles will collide
Your class should be called Particle and it will implement the following methods:
- a constructor that takes four double values, defining a particle: xPos, yPos, xVel, and yVel
- getX, which returns the x position of the particle
- getY, which returns the y position of the particle
- advanceTime, which takes and argument of type double and moves the particle forward in time by the amount passed as an argument
- whenCollide, which takes an argument of type Particle, and returns the time of the collision (a double) or -1 if there is no collision
A sample driver is available here.