// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Predict first contact of two moving circular bounds // Not compiled or tested in-world // Setup: Use a spare owned prim. Set relative POSITION/VELOCITY and nonnegative radii. Touch for owner-only calculation output. // Stop / restore: Remove/disable. Does not sense, collide with, or modify actual objects. // Notes: The supplied vectors should be planar for circles; the same equation also models spheres. No live entities are tracked. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Ideal geometry only. vector POSITION=<8.0,2.0,0.0>; vector VELOCITY=<-2.0,0.0,0.0>; float R1=1.0; float R2=1.5; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(R1<0.0||R2<0.0) { llOwnerSay("Invalid radius."); return; } float radius=R1+R2; float c=POSITION*POSITION-radius*radius; if(c<=0.0) { llOwnerSay("Already touching or overlapping."); return; } float a=VELOCITY*VELOCITY; if(a<0.000001) { llOwnerSay("No relative motion."); return; } float b=2.0*(POSITION*VELOCITY); float disc=b*b-4.0*a*c; if(disc<0.0) { llOwnerSay("No contact on trajectories."); return; } float t=(-b-llSqrt(disc))/(2.0*a); if(t<0.0) { llOwnerSay("Contact lies in the past."); return; } llOwnerSay("First contact in "+(string)t+" seconds."); } }