// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Limit a heading change by turn speed // Not compiled or tested in-world // Setup: Put in a spare owned prim. Set headings, nonnegative TURN_SPEED and DT. Owner touch prints calculations only. // Stop / restore: Disable/remove. No prim motion or appearance is changed. // Notes: Uses degrees and a negative180-degree tie convention. This calculates yaw only, not full orientation. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Motion planning only. float CURRENT=350.0; float TARGET=40.0; float TURN_SPEED=30.0; float DT=0.2; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(TURN_SPEED<0.0||DT<0.0) { llOwnerSay("Invalid rate/time."); return; } float delta=TARGET-CURRENT+180.0; delta-=360.0*llFloor(delta/360.0); delta-=180.0; float limit=TURN_SPEED*DT; if(delta>limit)delta=limit; if(delta< -limit)delta=-limit; float result=CURRENT+delta; result-=360.0*llFloor(result/360.0); llOwnerSay("Next heading="+(string)result+" step="+(string)delta); } }