Cloth

class Cloth(source)

A sheet made by PhysicsWorld.cloth: a grid of columns by rows particles, held by structural links along its rows and columns, shear links across each square, and bends along its rows and columns.

toString gives its size, for example Cloth(12x8).

Samples

val world = PhysicsWorld()
// A curtain 12 particles across and 8 down, hanging from its top row.
val curtain = world.cloth(left = 0f, top = 0f, columns = 12, rows = 8, spacing = 6f)
assertPrints(curtain, "Cloth(12x8)")
assertPrints(world.particles.inverseMassOf(curtain.particleAt(5, 0)), "0.0")
assertPrints(world.particles.inverseMassOf(curtain.particleAt(5, 7)) > 0f, "true")

Properties

Link copied to clipboard

Every bend: along the rows, then along the columns.

Link copied to clipboard

Number of particles across.

Link copied to clipboard

Every link: structural ones first, then shear.

Link copied to clipboard

The particles, row by row from the top-left: see particleAt.

Link copied to clipboard
val rows: Int

Number of particles down.

Functions

Link copied to clipboard
fun particleAt(column: Int, row: Int): Particle

Returns the particle at column and row, counted from the top-left.

Link copied to clipboard
open override fun toString(): String