Building Ragdolls

Sketching with Math and Quasi Physics

Verlet Points

Verlet integration is based on the assumption that, without force applied, an object will continue the uniform motion that it previously had. Instead of explcitly maintaining velocity as a variable belongs to the object, the change from the previous position to the current position is used as substitute for the velocity.

let v = (random(1) + random(1)) / 2;
update() {
  let temp = this.position.copy();
  this.position.add(this.getVelocity());
  this.prevPosition = temp;
}

setVelocity(v) {
  this.prevPosition = this.position.copy().sub(v);
}

getVelocity() {
  return this.position.copy().sub(this.prevPosition);
}

Learn more

Verlet integration

Verlet Sticks

The points can be connected by segments(sticks) that constrain the distances between them

update() {
  let dist = this.pa.position.dist(this.pb.position);
  let diff = this.length - dist;
  let offset = this.pa.position.copy().sub(this.pb.position).mult(diff / dist / 2);
  this.pa.position.add(offset);
  this.pb.position.sub(offset);
}

Pendulum

Ragdoll

Ragdoll 3D

index