// SPDX-License-Identifier: MIT
// Copyright (c) 2026 Incoprea
// Match position and velocity on an oscillation
// Not compiled or tested in-world
// Setup: Put in a spare owned prim. Set amplitude, positive period and time. Owner touch prints calculations only.
// Stop / restore: Disable/remove. No prim motion or appearance is changed.
// Notes: Velocity units are coordinate-units per second. No prim is moved.
// License: see LICENSE in this distribution.
// Original Incoprea. MIT. Motion planning only.
float AMPLITUDE=2.0;
float PERIOD=5.0;
float TIME=1.0;
default
{
    touch_start(integer detectedCount)
    {
        if(llDetectedKey(0)!=llGetOwner())return;
        if(PERIOD<=0.0)
        {
            llOwnerSay("Positive period required.");
            return;
        }
        float omega=TWO_PI/PERIOD;
        llOwnerSay("Displacement="+(string)(AMPLITUDE*llSin(omega*TIME))+" velocity="+(string)(AMPLITUDE*omega*llCos(omega*TIME)));
    }
}
