// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Clip a finite segment at a plane // Not compiled or tested in-world // Setup: Use a spare owned prim. Set A/B and plane point/normal. Touch for owner-only calculation output. // Stop / restore: Remove/disable. Does not sense, collide with, or modify actual objects. // Notes: A segment lying in the plane is reported separately from a unique crossing. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Ideal geometry only. vector A=<1.0,2.0,-1.0>; vector B=<3.0,2.0,4.0>; vector NORMAL=<0.0,0.0,1.0>; vector ON_PLANE=ZERO_VECTOR; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(llVecMag(NORMAL)<0.000001) { llOwnerSay("Zero normal."); return; } float da=(A-ON_PLANE)*NORMAL; float db=(B-ON_PLANE)*NORMAL; float denominator=da-db; if(llFabs(denominator)<0.000001) { if(llFabs(da)<0.000001)llOwnerSay("Segment lies in plane."); else llOwnerSay("Parallel without crossing."); return; } float t=da/denominator; if(t<0.0||t>1.0) { llOwnerSay("Crossing outside segment."); return; } llOwnerSay("Crossing="+(string)(A+(B-A)*t)+" fraction="+(string)t); } }