// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Angle between two directions // Not compiled or tested in-world // Setup: Edit A and B, then touch as owner. // Stop / restore: Remove or disable the script. It does not change the build. // Notes: The result is unsigned, from zero through 180 degrees. Zero vectors are rejected, and the dot product is clamped to prevent floating-point rounding from breaking acos. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. vector A = <1.0, 0.0, 0.0>; vector B = <1.0, 1.0, 0.0>; default { touch_start(integer count) { if (llDetectedKey(0) != llGetOwner()) return; if (llVecMag(A) < 0.00001 || llVecMag(B) < 0.00001) { llOwnerSay("Both direction vectors must be nonzero."); return; } float dot = llVecNorm(A) * llVecNorm(B); if (dot > 1.0) dot = 1.0; if (dot < -1.0) dot = -1.0; llOwnerSay("Angle: " + (string)(llAcos(dot) * RAD_TO_DEG) + " degrees."); } changed(integer flags) { if (flags & CHANGED_OWNER) llResetScript(); } }