rope
Keeps particles a and b at most rest apart, and returns its handle: like distance, but it only pulls, so closer than rest it goes slack.
Throws
as distance does.
Samples
val world = PhysicsWorld()
val anchor = world.particles.add(x = 0f, y = 0f, mass = Particles.STATIC)
val weight = world.particles.add(x = 0f, y = 20f)
// At most 50 long, slack when pushed: the weight falls until the rope goes taut.
val rope = world.constraints.rope(anchor, weight, rest = 50f)
repeat(60) { world.step(1.seconds / 60) }
assertPrints(world.constraints.isRope(rope), "true")
assertTrue(world.particles.yOf(weight) in 49f..51f)Content copied to clipboard