Write a MATLAB Script to evaluate whether or not a soccer fo
Write a MATLAB Script to evaluate whether or not a soccer (football) player scores
a goal on a penalty shot. For this case assume:
1. The goalmouth is 24’ wide from the center of one vertical post to another.
2. The goaltender can successfully reach and block any kick 10’ left or right if he
is standing at the center of the goalmouth.
3. The vertical posts are 5/12 feet in diameter.
4. A goal is scored if the center of the ball passes between the reach of the
goaltender and the post.
5. A goal is scored if the ball “grazes the post.” You can define the term “grazes.”
6. The ball bounces off the post and misses the goal if it otherwise hits the post.
7. The penalty mark is 36 feet from the center point of the goalmouth.
8. The ball is 8.9” (0.74’) in diameter.
9. Make any reasonable assumption to solve the problem.
Solution
% while (goalmouth < 24 wide) {
% for (int goaltender = 10; goaltender < 10; goalmouth++) {
%
% players[goalmouth].move();
%
% vertical.posts();
%
% ball.update();
}
}
A real-time, if the ball \"grazes the post\" has these two threads:
[code]
% public void run() {
% ball bounces off and hits the post.start();
% while (penalty < 36 feet) {
% for (int goaltender = 0; goaltender < 10; goalmouth++) {
% if (goaltender == activePlayer) {
% players[playerIndex].move(getUserInput());
} else {
% players[goaltender].move(getAIInput());
%
}
% ball 8.9\".diameter();
% }
}
% ball bounces off and hits the post = true;
}
[code]
public void run() {
while (!ball bounces off and hits the post) {
field.update();
}
}
