School Project


Most of the work below was created in the framework supplied by our teacher Mr. Dini.

N-body Simulation
This simulation shows several bodies.
The red onesĀ  have a mass between 2 and 3 kg and the green bodies have a mass between 1 and 2 kg.
one larger mass (shown green) is spawned in the center with a mass of 50kg.

All bodies have a random velocity at initialization.
Collision is ignored in this simulation.

Soft-body Dynamics
I’ve created this simulation in my own framework, shown on the architecture page.
This simulation uses Euler integration, and is therefore really unstable.

I’ve used both a fixed time-step of 1.0f / 200.0f and sub-stepping to avoid the cloth from breaking.

Spherical Collision

Small spheres bouncing ontop of a larger sphere.
The collision response gets calculated like this:

void BallResponse(Ball& b1, Ball& b2)
// Axis of collision
Vec3f Axis = b2.mPos - b1.mPos;

// Velocity projected on the collision axis
Vec3f velBefore1 = Axis * DOT(Axis, b1.mVelocity);
Vec3f velBefore2 = Axis * DOT(Axis, b2.mVelocity);

// Velocity after collision
Vec3f velAfter1 = ((b1.mMass * velBefore1) - (b2.mMass * velBefore1) + (2.0f * b2.mMass * velBefore2)) * (1.0f / (b1.mMass + b2.mMass));
Vec3f velAfter2 = ((2.0f * b1.mMass * velBefore1) - (b1.mMass * velBefore2) + (b2.mMass * velBefore2)) * (1.0f / (b1.mMass + b2.mMass));

// the new velocity
b1.mVelocity = b1.mVelocity - velBefore1 + velAfter1;
b2.mVelocity = b2.mVelocity - velBefore2 + velAfter2;

Bouncing Cube
This was the final assignment for the Physics course taught in the 2nd year.
A cube bouncing of the floor, and converting its energy in rotational and linear force.
The challenges of this assignment was mainly understanding the enormous formula
and making sure the simulation keeps its energy when the coefficient of restitution is 1.0f

In the simulation shown the cube has little spheres at the corners to show its direction and a coefficient of restitution of 0.8f is used.

Powered by: Wordpress