// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Interpolate a three-point calibration // Not compiled or tested in-world // Setup: Place in a spare owned prim. Set X0/Y0, X1/Y1, X2/Y2 and INPUT. Touch to run; output is private to the owner. // Stop / restore: Disable/remove. No scene changes or external calls. // Notes: Distinct input coordinates are required. Extrapolation outside the calibration range may be unreliable. // License: see LICENSE in this distribution. // Original Incoprea. MIT. float X0=0.0; float Y0=1.0; float X1=2.0; float Y1=4.0; float X2=5.0; float Y2=16.0; float INPUT=3.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(llFabs(X0-X1)<0.000001||llFabs(X0-X2)<0.000001||llFabs(X1-X2)<0.000001) { llOwnerSay("Calibration inputs must differ."); return; } float result=Y0*(INPUT-X1)*(INPUT-X2)/((X0-X1)*(X0-X2))+Y1*(INPUT-X0)*(INPUT-X2)/((X1-X0)*(X1-X2))+Y2*(INPUT-X0)*(INPUT-X1)/((X2-X0)*(X2-X1)); llOwnerSay("Interpolated output="+(string)result); } }