' Michael Zhu Date: January 06, 2017
1 Structural analysis 1.1 class definitions
- Hockey Class: Class Puck
- Ball Table class: Class table
- Batter class: Class Hockey_stick
1.2 Key functions
According to the above class, and the following requirements:
Input: The current position and speed of the batter (controlled by the robot). Output: The current position and speed of the puck. It is known that the key functions are collision detection and velocity calculation after collisions. One of the difficulties is collision detection.
- void Check_collision ();//Check for collisions
- void Update_position ();//Update location
- void Update_velocity ();//update speed
2 Interface Design
The physics engine is a relatively independent piece that simply provides a simple interface to the GUI and policy.
2.1 Algorithm Interface
- void Puckstep ();//Update physical state
2.2 Data Interface
Hockey:
- Double radius;
- Double Position[axis_count];
- Double Velocity[axis_count];
- Double mass; Corresponds to a parameter in common and passes the argument to the variable in common each time.
Ball Table:
- Double length;
- Double width;
- Double goalline1;
- Double Goalline2;
Ball Sticks:
- Double radius;
- Double mass;
- Double Pre_position[axis_count], Cur_position[axis_count];
Double Velocity[axis_count]; The above is the parameter in the class.
static double Default_puck_radius = 0;
static double default_puck_mass = 0;
static double default_table_length = 0;
static double default_table_width = 0;
static double Default_hockey_stick_radius = 0;
static double default_hockey_stick_mass = 0;
static double default_goal_length1 = 0;
- static double default_goal_length2 = 0; The above parameters are preset values, and other modules can be used directly.
Physical Engine Interface