Body

class Body(val nodes: List<Node>, val boundaryNodes: List<Int> = emptyList(), val links: List<Link> = emptyList(), val boundaryLinks: List<Int> = emptyList(), val triangles: List<Triangle> = emptyList(), var inverseBodyMass: Double = 1.0, var static: Boolean = false)(source)

Represents a physical body in a simulation composed of nodes, links, and triangles.

A Body serves as the central structure in simulations, encapsulating physical properties, relationships, and behaviors of its constituent parts. It supports initialization, integration of forces, resolution of constraints, and updates to its boundaries. The body can either be static or dynamic, depending on the static property.

Constructors

Link copied to clipboard
constructor(nodes: List<Node>, boundaryNodes: List<Int> = emptyList(), links: List<Link> = emptyList(), boundaryLinks: List<Int> = emptyList(), triangles: List<Triangle> = emptyList(), inverseBodyMass: Double = 1.0, static: Boolean = false)

Properties

Link copied to clipboard

the list of indices referring to links considered as boundary links.

Link copied to clipboard

the list of indices referring to nodes considered as boundary nodes.

Link copied to clipboard
var bounds: Rectangle

the bounding rectangle that encapsulates the body's nodes, updated automatically.

Link copied to clipboard

the list of Constraints influencing the behavior and interaction of the body.

Link copied to clipboard

the list of Forces acting on the body in the simulation.

Link copied to clipboard

the reciprocal of the total mass of the body, used in weight calculations.

Link copied to clipboard

the list of Links that define relationships or connections between nodes.

Link copied to clipboard

the list of Nodes that make up the physical body.

Link copied to clipboard

a flag indicating whether the body is static (non-movable) or dynamic.

Link copied to clipboard

the list of Triangles used for structural and mass-related calculations.

Functions

Link copied to clipboard
fun Body.bodyAreaConstraint(configure: BodyAreaConstraint.() -> Unit = {})

Adds a body area constraint to the body, ensuring that its area remains close to a target rest area during simulation. The constraint includes compliance and uses iterative solving to maintain this condition.

Link copied to clipboard

Adds a BoundaryNodeRelaxForce to the Body's list of forces. This force acts on the boundary nodes of the body to relax their positions by adjusting their velocities based on neighboring node positions.

Link copied to clipboard
fun Body.gravity(configure: GravityForce.() -> Unit): Boolean

Adds a gravitational force to the body and allows configuring its properties.

Applies a gravitational force to the body by adding it to the list of forces acting on the body.

Link copied to clipboard
suspend fun initialize()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Body.manyNodeForce(configure: ManyNodeForce.() -> Unit)
Link copied to clipboard

Applies a circular constraint to the nodes of this Body.

Link copied to clipboard

Adds a node collision constraint to the body, configuring it using the provided lambda.

Link copied to clipboard

Applies a node contour constraint to the body and configures it using the provided configuration block.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun postsolve(dt: Double)
Link copied to clipboard
suspend fun presolve(dt: Double)
Link copied to clipboard

Adds a rectangular boundary constraint to the body, ensuring that its nodes remain confined within a specified rectangular region during the simulation.

Link copied to clipboard
suspend fun solve(dt: Double, alpha: Double)
Link copied to clipboard

Adds a triangle area constraint to the body, ensuring that the areas of triangles in the body remain consistent with their initial (rest) areas during simulation.

Link copied to clipboard