[Solved] CS180 Assignment8- Linking the rope constraints

$25

File Name: CS180_Assignment8-_Linking_the_rope_constraints.zip
File Size: 442.74 KB

SKU: [Solved] CS180 Assignment8- Linking the rope constraints Category: Tag:
5/5 - (1 vote)

1.1 Linking the rope constraints

In rope.cpp, implement the constructor of the class Rope. It should create a new Rope object starting at start and ending at end, containing num nodes nodes. That is, something like the following diagram:

Each node is a mass, and each line between them is a spring. By creating a set of springs and masses, you create an object that behaves like a spring.

The nodes at the indices specified by pinned nodes should have their pinned attribute set to true (those will be stationary). For each node, you should create a Mass object, and set the mass and spring constant k into the Mass constructor (PLEASE check the code/header files to check what exactly you should pass to the constructor). You also should create a spring between consecutive masses, again check the signatures of the constructors to see what you should pass as arguments to it.

Run ./ropesim. You should see the rope drawn to the screen, although it wont be moving for now.

1.2 Explicit/Implicit Euler

Hookes law states that the force on two points along a spring is proportional to their distance. That is,

In Rope::simulateEuler, first implement Hookes law. Iterate over all the springs and apply the correct spring force to the mass on either end of the spring. Ensure that the force is pointing in the correct direction! Accumulate all forces due to springs in the forces attribute of each Mass.

Once all the spring forces have been computed, apply the laws of physics to each particle:

Run ./ropesim. Your simulation should start running, but as it only has 3 nodes, it doesnt look like much. At the top of application.cpp, you should see where the Euler and Verlet ropes are defined. Change the value 3 for the number of nodes to a higher constant like 16 for both ropes.

Run ./ropesim -s <step-count> to set the simulation to use a different number of simulation steps per frame. Try small values and large values (default is 64).

1.3 Explicit Verlet

Verlet is a different way of ensuring that all constraints are dealt with accurately. The benefit to this approach is that the simulation is handled entirely through the positions of the vertices in the simulation, and it remains fourth-order accurate! Unlike Euler, Verlet integration follows the following rule to calculate the next position in the simulation:

In addition, we can now emulate springs with an infinite spring constant. Instead of bothering with spring forces, we simply move each masss position such that the springs are set back to their rest length. The correction vector should be proportional to the displacement between the two masses and in the direction between one mass and the other. Each mass should move by half the displacement.

As long as we do this for every pair of springs, the simulation should approach stability. Additional rounds of simulations may be necessary to make the motion smoother.

1.4 Damping

Add damping to Hookes law in explicit Verlet. Springs in real life dont continue bouncing forever energy is lost to friction. Use damp factor 0.00005. The damping is applied by:

1.5

The functions you should modify are:

  • Rope::Rope() in rope.cpp
  • void Rope::simulateEuler() in rope.cpp
  • void Rope::simulateVerlet() in rope.cpp
  • Getting started

You need to have OpenGL libraries installed on your system to compile and run. Otherwise, you can use the VM provided. Download the projects skeleton code, and build the project by using the following commands:

$ mkdir build $ cd build $ cmake . .

$ make

After this, you should be able to run the given code by using ./ropesim.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS180 Assignment8- Linking the rope constraints
$25