Overview
ThePData interface defines the complete state and configuration of a particle in the simulation. Each particle maintains its physical properties, motion state, applied forces, and event triggers.
Interface Definition
Fields
Unique identifier for the particle. Used to reference and manage individual particles in the simulation.
Initial Conditions
Initial position vector in 3D space
[x, y, z]. Defines where the particle starts in the simulation.Initial velocity vector
[vx, vy, vz]. Defines the particle’s starting velocity in each dimension.Initial acceleration vector
[ax, ay, az]. Typically set to [0, 0, 0] unless starting with specific acceleration.Force Formulas
Formula string for force in x-direction. Can reference variables
t, x, y, z and use Math functions. Leave empty or “0” for no force.Formula string for force in y-direction. Supports mathematical expressions with time and position variables.
Formula string for force in z-direction. Can include complex expressions with trigonometric functions.
Current State
Current position vector
[x, y, z]. Updated each simulation step based on velocity and acceleration.Current velocity vector
[vx, vy, vz]. Updated each step based on forces and acceleration.Elapsed simulation time in seconds for this particle. Incremented by
deltaT each step.Visualization
Array of position points forming the particle’s trajectory trail. Each element is a
[x, y, z] position.Used to render the motion path when path visualization is enabled.Hexadecimal color code for the particle. Supports standard CSS color formats.
Physics Properties
Particle mass in kilograms. Affects force calculations via Newton’s second law (F = ma).
Ground contact flag.
true when particle is touching the ground (y ≤ 0), enabling friction calculations.Kinematic mode flag. When
true, the particle ignores forces and follows purely kinematic motion (constant velocity).Advanced Systems
Array of force objects applied to the particle. Forces are evaluated and combined each simulation step.See Force System for details.
Array of event triggers that can modify particle behavior when conditions are met.See Event System for details.
Creating Particles
Basic Particle
Particle with Forces
Kinematic Particle
Runtime Behavior
Initialization
When a particle is created:curr_fisis set top0_fiscurr_velis set tov0_fistis set to0trail_threeis initialized as empty arrayenSuelois calculated based on initial y-position
Each Simulation Step
- Forces are evaluated from
fx,fy,fzformulas andforcesarray - Net force is calculated by summing all force components
- Acceleration is computed:
a = F_net / mass(unlessisMassless) - Velocity is updated:
v = v + a * deltaT - Position is updated:
p = p + v * deltaT - Current position is added to
trail_three - Events are checked and triggered
- Time
tis incremented bydeltaT
Related
- Force System - Define forces applied to particles
- Event System - Create conditional behaviors
- Configuration Guide - Configure particle arrays and save/load setups