Assignment 3: Rope simulation with gravity and collision detection
DATE DUE: March 21, 2016
Points possible: 10 points
CS-116B: Computer Graphics Algorithms
Instructor: Rob Bruce

OVERVIEW

For this assignment, you will create a rope simulator subject to gravity and collision detection. To simulate rope, you should use the mass spring model discussed in our lectures and in the readings. In this model, your rope is created from a series of particles connected to each other with invisible springs. The springs exert forces on the particles. Gravity also exerts forces on the particles.

SPECIFICATIONS

Your program should use a minimum of 10 particles.

There is no maximum number of particles. Experiment and use more if you'd like!

The particles should be evenly spaced along the length of the rope.

Both ends of your rope should be immobile. This means the particle at either end of your rope should not be subject to forces of gravity or spring forces.

You may choose the length of the rope as long as (1) the rope length is entirely visible on the screen and (2) there's some visible spacing between the particles.

Before your simulation begins, your rope should be in an initial horizontal rest state.

The particles all have the exact same weight: 1 kg.

The invisible springs that connect each particle are weightless. You do not need to include the weight of the spring in your calculations.

The particles are subject to gravity. Use 9.8 m/s2 as your constant for gravity.

The rope must detect when the particles come in contact with a stationary sphere.

The sphere must be below the rope's initial rest position. The sphere should not touch the rope at the initial rest position. This gives the rope an opportunity to fall on to the sphere when gravational and spring forces are applied.

The sphere is stationary. It does not move.

When one or more particles collide with the sphere, the sphere should absorb all the kinetic energy from the particles that come in contact. It is a perfectly inelastic collision. The sphere will not ever move.

I have provided you with a start program as basis for this assignment at: http://www.cs.sjsu.edu/~bruce/programs/spring_2016_cs116b/rope_simulation/rope_simulation.tar.gz (right mouse click then press "Save Link As...")

To unpack this archive, type the following command in a shell prompt: tar xzf rope_simulation.tar.gz

HINTS

Your particles will be subject to spring forces and weight.

Use Hooke's law to compute spring forces: Force = k * x. The constant 'k' is a spring constant. Higher k values equate to a stiffer spring. The variable x refers to the spring's displacement from its rest position. The rest position of a spring is when the spring is neither in tension or compression. It's the natural rest state of the spring.

Use Weight = mass * acceleration of gravity (w = m * g).

SUBMITTING YOUR PROGRAM

1. Please submit your program as a text file to the Canvas dropbox. I only need the source code. I will build the program myself.

2. Please name your program using the following naming convention:

Lastname_Firstname_assignment_3.c (for C programs)

Lastname_Firstname_assignment_3.cpp (for C++ programs)

Lastname_Firstname_assignment_3.java (for Java programs)

For example, my name is Rob Bruce. If I write my program in the C programming language, my assignment 3 should be named: Bruce_Rob_assignment_3.c

3. Please include your name as a comment at the beginning of your program like this:

/* Rob Bruce */

or this:

// Rob Bruce

4. I usually do not need a makefile to build your programs, regardless of language; however, in the unlikely event that I cannot build your project, I will send an email inquiry as appropriate.

5. I expect your program to build without syntax errors.

6. I expect your program to execute without run-time errors.

GRADING

Points will be deducted for any program that does not meet the specification as outlined above.

LATE ASSIGNMENTS

Assignments submitted after the due date will be worth, at most, 5 points. Additional points will be deducted for programs not meeting the specification as outlined above.