pin

fun pin(particle: Particle, x: Float = particles.xOf(particle), y: Float = particles.yOf(particle), compliance: Float = 0.0f): Pin(source)

Holds particle at (x, y), by default where it is now, and returns the pin's handle.

Throws

if particle is gone or compliance is negative or not finite.

Samples

val world = PhysicsWorld()
val p = world.particles.add(x = 10f, y = 10f)
// Held where it is now; move the pin and it follows.
val pin = world.constraints.pin(p)
world.constraints.movePin(pin, 30f, 10f)
repeat(10) { world.step(1.seconds / 60) }
assertTrue(world.particles.xOf(p) in 29f..31f)
assertPrints(world.constraints.particleOf(pin) == p, "true")