Node

class Node(var position: Vector2, var prevPosition: Vector2, var velocity: Vector2, var inverseMass: Double = 1.0, var radius: Double = 0.0, var id: Int = 0)(source)

Represents a single physical node with position, velocity, and related properties.

A node serves as an element in simulations, with attributes including its current position, previous position, velocity, inverse mass, radius, and a unique identifier. These properties define the motion and interaction of the node with forces or other nodes in the simulation.

Constructors

Link copied to clipboard
constructor(position: Vector2, prevPosition: Vector2, velocity: Vector2, inverseMass: Double = 1.0, radius: Double = 0.0, id: Int = 0)

Properties

Link copied to clipboard
val bounds: Rectangle

a bounding rectangle centered around the node, with dimensions based on its radius.

Link copied to clipboard
var id: Int

an optional unique identifier for the node. Default is 0.

Link copied to clipboard

the reciprocal of the node's mass. A value of 0 represents an immovable object, while higher values represent lower mass.

Link copied to clipboard
var position: Vector2

the current position of the node in the simulation space.

Link copied to clipboard
var prevPosition: Vector2

the position of the node in the previous simulation step.

Link copied to clipboard

the radius of the node, used for interactions or spatial calculations.

Link copied to clipboard
var velocity: Vector2

the current velocity of the node.