# project | assignment – EECS 4491 /5391: Assignment 2

### EECS 4491 /5391: Assignment 2

project | assignment | math代写 – 该题目是值得借鉴的math方面代写的题目

#### Part1: Spring Mass system [Marks 25]

Develop a spring mass system and a corresponding simulator that support an arbitrary number of particles. The particles can be connected with springs in arbitrary ways and are subject to gravity. There is a flat ground oriented along the y-axis that you should model using penalty forces. The simulator should support the following integration methods: Forward Euler, Symplectic Euler, and Verlet.

You must implement the interface commands below. None of these commands need to work after the user has started the simulation. Additionally, during grading these commands will only be called (during a particular invocation of the application) in the order in which they are given here.

1. system <sys_name> dim

This command initializes the particle system to hold up to the given number of particles. Particles may be initialized to the origin of the world, or may not appear until added by the next command.

1. system <sys_name> particle

This command sets a position, mass and velocity for a given particle.

1. system <sys_name> all_velocities

This command sets the velocity of all particles.

This links the simulator to a particular particle system, and initializes it to work with a given number of springs.

1. simulator <sim_name> spring

This sets up a given spring. If the restlength is a negative number, the system should automatically set the restlength of the spring to the distance between the corresponding particles at the time the command is given.

1. simulator <sim_name> fix

This command nails particle to its current position.

1. simulator <sim_name> integration <euler|symplectic|verlet>

This changes the integration technique used by the given simulator and sets the time step of the integration.

1. simulator <sim_name> ground

Sets the parameters of the penalty forces applied to particles that try to go underground.

1. simulator <sim_name> gravity

Sets the acceleration due to gravity, in unit length per unit time squared.

1. simulator <sim_name> drag

Sets the global drag (friction) coefficient (Fi = -kdrag vi). The command expects a positive number

Marking scheme:

• [4] Particle system.
• [4] Script commands.
• [3] Forward Euler.
• [3] Verlet.
• [3] Symplectic Euler.
• [4] Ground forces
• [1] Gravity
• [1] Locking of a particles position.
• [2] Particle and spring drawing.
• [Penalty] [-2] Provide a readme.txt file that explains in detail which of the requirements you have implemented, and what does not work.

Instructions:

• Call your system partSys and the simulator partSim so we can use the same scripts to test the assignment.

#### Bonus: Interaction [Marks 5]

Use the pointer to drag particles around. Pressing and holding down the left mouse button should insert a zero length spring in the system that drags the corresponding particle to the pointers position. Assume that the desired z value is the z-position of the selected particle at the time it was selected, and that the scene is not rotated, i.e. the xy-plane is aligned with the screen.

Instructions

1. Make sure you follow the exact syntax specified in the assignment. We will be using the same set of scripts to test your code. Notice that the scripts create one additional spring. That spring can be used for the interaction, so you do not have to instantiate one at run time. However, you are free to do so if you wan.t
2. There is a lot of code already provided. You do not need to write your own vector, or quaternion libraries. However, if you have one you may use it.
3. You may NOT use any other existing code.
4. Do not use spaces in file names.
5. If the code doesnt compile or doesnt run you will get 0 points. No partial points will be given.
6. If your code doesnt parse correctly the input files you will get zero points. 7. Please follow the same guidelines of assignment 1 for the submission through moodle. In particular, remember to write a readme file with a description of what you’ve done, what’s missing, or any extra features that you may have added. We will test your projects primarily with the scripts that are posted online, so make sure it works for those. As usual we will NOT test your code with malformed or nonsensical commands. If you couldn’t get your project to work with our scripts, you may submit scripts of your making that do something we can look at (let us know in the readme though). Do this only as a LAST RESORT!

Performance tips:

• use an appropriate time step. If the simulation explodes use 0.0001 for debugging reasons. When everything is working fine, the time step should be in the range (0.001, 0.01), preferably closer to 0.01.
• try to draw points using GL_POINTS instead of drawing spheres for each particle. You can even add an if-statement to use points or spheres depending on how many particles there are.
• double-check that you don’t accidentally have a memory leak and that you are not re-allocating variables that do not need to be re-allocated.
• double-check that you don’t accidentally copy large amounts of data unnecessarily.
• double-check you don’t accidentally have an O(n^2) or worse algorithm. You should be able to do things with just a few O(n) loops per time step. In particular, you should NOT be checking for the "closest particle to the mouse" every time step.

Another possible reason for performance problems is console output. Writing to the console can be expensive. Commenting out your console output may improve performance.