// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Clip a line segment to a circular boundary // Not compiled or tested in-world // Setup: Use a spare owned prim. Set XY endpoints A/B, CENTER and positive RADIUS. Touch for owner-only calculation output. // Stop / restore: Remove/disable. Does not sense, collide with, or modify actual objects. // Notes: Prints entry and exit independently; tangency can print the same point twice. Z is discarded. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Ideal geometry only. vector A=<-5.0,1.0,0.0>; vector B=<5.0,1.0,0.0>; vector CENTER=ZERO_VECTOR; float RADIUS=3.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; vector d=B-A; d.z=0.0; vector f=A-CENTER; f.z=0.0; float a=d*d; if(a<0.000001||RADIUS<=0.0) { llOwnerSay("Invalid segment/radius."); return; } float b=2.0*(f*d); float c=f*f-RADIUS*RADIUS; float disc=b*b-4.0*a*c; if(disc<0.0) { llOwnerSay("No crossings."); return; } float root=llSqrt(disc); list parameters=[(-b-root)/(2.0*a),(-b+root)/(2.0*a)]; integer found; integer i; for(i=0;i<2;++i) { float t=llList2Float(parameters,i); if(t>=0.0&&t<=1.0) { ++found; llOwnerSay("Crossing="+(string)(A+t*d)); } } if(!found)llOwnerSay("Intersections lie outside the segment."); } }