// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Triangle coordinate inspector // Not compiled or tested in-world // Setup: Put in a spare prim you own. Edit triangle A/B/C and point P; touch. Use a point in the triangle plane. // Stop / restore: Disable or remove the script. It only reports to its owner and does not change prim properties. Reset clears its temporary state. // Notes: Weights sum to one. Negative weights indicate an outside projection. A noncoplanar input is implicitly projected; degenerate triangles are rejected. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Owner-only calculation; no scene changes. vector A = <0.0, 0.0, 0.0>; vector B = <4.0, 0.0, 0.0>; vector C = <0.0, 3.0, 0.0>; vector P = <1.0, 1.0, 0.0>; default { touch_start(integer detectedCount) { if (llDetectedKey(0) != llGetOwner()) return; vector v0 = B - A; vector v1 = C - A; vector v2 = P - A; float d00 = v0 * v0; float d01 = v0 * v1; float d11 = v1 * v1; float d20 = v2 * v0; float d21 = v2 * v1; float denominator = d00 * d11 - d01 * d01; if (llFabs(denominator) < 0.000001) { llOwnerSay("Degenerate triangle."); return; } float v = (d11 * d20 - d01 * d21) / denominator; float w = (d00 * d21 - d01 * d20) / denominator; llOwnerSay("Weights A/B/C: " + (string)<1.0 - v - w, v, w>); } changed(integer change) { if (change & CHANGED_OWNER) llResetScript(); } }