// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Measure shortest distance between two infinite guide lines // Not compiled or tested in-world // Setup: Put in the root of a spare owned object/linkset. Child touch handlers may consume events. Touch first line start/end, then second line start/end. Collect 4 owner touches; the next touch starts another measurement. // Stop / restore: Reset clears collected points; disable/remove to stop. No geometry is changed. // Notes: The lines are infinite; closest positions can lie beyond clicked segments. Parallel lines use perpendicular point-to-line distance. Results use actual touch positions in region coordinates, not hidden mesh dimensions. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Live touch measurements only. list points; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(llDetectedTouchFace(0)<0) { llOwnerSay("Touch position unavailable."); return; } if(llGetListLength(points)>=4)points=[]; points+=[llDetectedTouchPos(0)]; integer collected=llGetListLength(points); if(collected<4) { llOwnerSay("Recorded point "+(string)collected+" of 4."); return; } vector a=llList2Vector(points,0); vector b=llList2Vector(points,1); vector c=llList2Vector(points,2); vector d=llList2Vector(points,3); vector u=b-a; vector v=d-c; if(llVecMag(u)<0.000001||llVecMag(v)<0.000001) { llOwnerSay("Repeated endpoint."); return; } vector normal=u%v; float length=llVecMag(normal); float distance; if(length<0.000001)distance=llVecMag((c-a)%u)/llVecMag(u); else distance=llFabs((c-a)*normal)/length; llOwnerSay("Infinite guide-line separation="+(string)distance); } changed(integer flags) { if(flags&CHANGED_OWNER)llResetScript(); } }