// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Simulate a damped spring in small steps // Not compiled or tested in-world // Setup: Place in a spare owned prim. Set positive stiffness, nonnegative damping and target; use the supplied small step size. Touch for owner-only output. // Stop / restore: Remove/disable. The script calculates only; no scene properties change. // Notes: Numerical stability depends on step size and stiffness. The simulation is illustrative and does not drive prim physics. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Planning only. float STIFFNESS=12.0; float DAMPING=5.0; float TARGET=1.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(STIFFNESS<=0.0||DAMPING<0.0) { llOwnerSay("Invalid spring parameters."); return; } float x=0.0; float velocity=0.0; float dt=0.02; integer i; for(i=0;i<100;++i) { float acceleration=STIFFNESS*(TARGET-x)-DAMPING*velocity; velocity+=acceleration*dt; x+=velocity*dt; if((i+1)%20==0)llOwnerSay("t="+(string)((i+1)*dt)+" position="+(string)x+" velocity="+(string)velocity); } } }