an example of using matrices in a C chart to simulate the opening
shot on a pool table.
The model consists of the following blocks.
|Init chart||Initializes the position and velocity of the cue ball.|
|Pool chart||Calculates the two-dimensional dynamics of each ball on the pool table.|
|Plot block||Animates the motion of each ball during the opening shot.|
|Vel scope||Displays the velocity of each ball during the opening shot.|
|Clock||Provides the instantaneous simulation time to the Plot block.|
To simulate the opening shot, the Pool chart stores two-dimensional data in matrices.
|To store values for...||The Pool chart uses...|
|The instantaneous position of each ball||The 15-by-2 matrix |
|The instantaneous velocity of each ball||The 15-by-2 matrix |
|Friction and interaction forces acting on each ball||The 15-by-2 matrix |
|Boolean data on whether any two balls are in contact||The 15-by-15 matrix |
The Pool chart calculates the motion of each ball on the pool table using MATLAB® functions that perform matrix calculations.
|Calculates the friction force acting on each ball.|
|Returns a matrix of Boolean data on whether any two balls are in contact.|
|Returns 1 if ball interactions have changed and 0 otherwise.|
|Initializes the position and velocity of every ball on the pool table.|
|Calculates the interaction force acting on each ball.|
|Returns 1 if any ball has stopped moving and 0 otherwise.|
|Returns 1 if any ball has been newly pocketed and 0 otherwise.|
|Returns true if any ball is out of bounds and false otherwise.|
|Returns true if a ball is near a pocket on the pool table and false otherwise.|
|Sets the velocity of a ball to 0 if it has been pocketed.|
|Resets the position and velocity of any ball that is out of bounds.|
|Keeps track of which balls have stopped moving.|
To run the model, follow these steps:
sf_pool at the MATLAB command
Click anywhere in the animated pool table to specify the initial position of the cue ball.
Click a different spot to specify the initial velocity of the cue ball.
Watch the balls move across the pool table.