TopCoder problem "BallMotion" used in SRM 13 (Division I Level Two , Division II Level Two)



Problem Statement

    
Class Name: BallMotion
Method Name: getLocation
Parameters: int,int,int,int,int,int,int,int
Returns: String

Consider a room of length xMax feet and width yMax feet that has a ball of
radius r stationed at some point (xStart,yStart) within its perimeter.
Determine the x and y coordinates of the ball at a specified time t if the ball
has an initial velocity, broken down into an x component (xVel) and a y
component (yVel). (In other words, each second the ball moves xVel feet along
the x direction and yVel feet along the y direction.) Assume that the ball
always rolls with constant speed, and it rebounds from the wall precisely when
it touches the wall at an equal but opposite angle that it hits the wall (Law
of Reflection applies).

Implement a class BallMotion which includes a method getLocation.  The method
takes 8 ints as arguments: 
*xMax, the length of the room (horizontal x distance), in feet;
*yMax, the width of the room (vertical y distance), in feet;
*xStart, the starting x coordinate of the center of the ball, in feet;
*yStart, the starting y coordinate of the center of the ball, in feet;
*radius, the radius of the ball, in feet;
*xVel, the initial x velocity, in feet per second;
*yVel, the initial y velocity, in feet per second;
*time, the time, in seconds. 
The method returns a String consisting of the final x and y coordinates, in
feet, of the ball.  The String is of the form "(x,y)" where x and y are
integers (with no leading zeroes) representing the final x and y coordinates of
the center of the ball.  The quotes are for clarity and there are no spaces.

The room spans from (0,0) to (xMax,yMax) where (0,0) is the lower left corner.
A positive velocity represents motion away from 0.
Here is the method signature:
public String getLocation(int xMax, int yMax, int xStart, int yStart, int
radius, int xVel, int yVel, int time);

The parameters satisfy:
0<xMax<=1000
0<yMax<=1000
radius<xStart<xMax-radius
radius<yStart<yMax-radius
0<2*radius<yMax
0<2*radius<xMax
-100<=xVel<=100
-100<=yVel<=100
0<=time<=1000

Examples:
*If the room is 10 x 10, and the ball is originally at (5,5) with radius 1, and
initial x velocity 1, initial y velocity 1 and t=5, the method should return
"(8,8)".
*If the room is 10 x 10, and the ball is originally at (2,3) with radius 1, and
initial x velocity 3, initial y velocity -1 and t=3, the method should return
"(7,2)". 
 

Definition

    
Class:BallMotion
Method:getLocation
Parameters:int, int, int, int, int, int, int, int
Returns:String
Method signature:String getLocation(int param0, int param1, int param2, int param3, int param4, int param5, int param6, int param7)
(be sure your method is public)
    

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=101

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=3012&pm=101

Writer:

Unknown

Testers:

Problem categories: