// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Reflect a direction from a plane // Not compiled or tested in-world // Setup: Put in a spare prim you own. Set incoming DIRECTION and surface NORMAL, then touch. // 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: The normal is normalized internally. The reflection preserves the original vector magnitude; this is not a physics collision response. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Owner-only calculation; no scene changes. vector DIRECTION = <1.0, -2.0, -3.0>; vector NORMAL = <0.0, 0.0, 1.0>; default { touch_start(integer detectedCount) { if (llDetectedKey(0) != llGetOwner()) return; if (llVecMag(NORMAL) < 0.000001) { llOwnerSay("Normal is zero."); return; } vector n = llVecNorm(NORMAL); vector reflected = DIRECTION - 2.0 * (DIRECTION * n) * n; llOwnerSay("Reflected direction: " + (string)reflected); } changed(integer change) { if (change & CHANGED_OWNER) llResetScript(); } }