Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Lab Demo Project 1: Gravity Simulator
Overview
Gravity exists between all objects. According to Newton's Second Law, a force applied to an
object will change its acceleration, affecting its velocity and position indirectly. The three-body
problem is a problem regarding gravity. Imagine that, in an empty space, there are three objects
of the same mass. They will begin to move due to gravity between them. Their motion is actually
very hard to predict because even a very tiny difference in the initial setup can affect their loci
tremendously. To see this, computers are often used to simulate their movement.
This project asks you to follow our guidance to implement a gravity simulator in
MATLAB. The final product should be a program that animates the movement of several (more
than three!) spherical objects, or balls, with different color, radius (mass) as well as initial
location, velocity and acceleration. The balls attract each other due to gravity, and collide
completely elastically.
You can find on Canvas a demo video showing how the program is supposed to work.
Milestones and grading policy
This project will last for 3 lab sessions. At the end of each lab session, you are expected to
complete a part of this project, called a milestone. The requirements for each milestone will be
documented in the corresponding lab worksheet.
Each milestone is due Thursday at 10:00 p.m. You must submit your code to Canvas before the
deadline to receive points for this part. Your code will be graded on its completeness, not
correctness. Students who make reasonable efforts to complete the tasks for a milestone will
receive full marks for the demo project section of the corresponding lab. On the contrary, non
sensical code, too few lines of code or irrelevant submissions will receive no point. However, a
deduction may apply if your code style is considered bad. See the "Code quality" section for
details.
The due date for demo project submission is Thursday at 10:00 p.m. No late submission
will be aceepted.Demo projects are aimed to help you get a sense of what a software project is like and also
practice your programming skills learnt from the lectures. The goal is not to judge your ability.
So you will not need to worry about your grade as long as you try your best to follow the
TAs during the lab.
Background
Animations
This project basically asks you to produce an animation. Animations are just pictures played
sequentially at a high rate. Each picture is called a frame. Thus, you goal for this project is just
to generate and render each frame.
The rate of frame update is measured in frame per second, or FPS.
MVC: model, view and controller
The MVC architecture is commonly used to develop large-scale projects. It divides a program
into three main components:
The model. It is a data structure that contains all information about the current state of your
program.
The view. It is responsible for visualizing the model and rendering the canvas, or providing
the UI (User Interface).
The controller. It contains all the logic behind the program.
A program with the MVC architecture first initiates the model using some predefined default
values and renders the view according to the initial model, then runs such a main loop: The view
passes all user input gathered, if any, to the controller. The controller then decides how to
update the model accordingly, and instructs the view to render the updated model.