bend
fun bend(a: Particle, b: Particle, c: Particle, compliance: Float = 0.0f, rest: Float = Float.NaN): Bend(source)
Keeps the angle at particle b, from a through b to c, at rest, and returns its handle.
The angle is how far the line turns at b: 0 is straight on, and it is signed, positive turning clockwise on screen (y grows down), so a bend can be held curled one way. Without a rest, it is the angle they make now. Its compliance is per radian: how far it turns per unit of torque.
Throws
if a particle is gone, two of them are the same, or compliance is negative or not finite.
Samples
val world = PhysicsWorld()
val a = world.particles.add(x = 0f, y = 0f, mass = Particles.STATIC)
val b = world.particles.add(x = 20f, y = 0f, mass = Particles.STATIC)
val c = world.particles.add(x = 40f, y = 0f)
world.constraints.distance(b, c)
// Keeps the angle at b straight, so c sticks out instead of hanging down.
val bend = world.constraints.bend(a, b, c)
repeat(30) { world.step(1.seconds / 60) }
assertTrue(world.particles.yOf(c) in -1f..1f)
assertTrue(world.constraints.angleOf(bend) in -0.05f..0.05f)Content copied to clipboard