// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Distance across a spherical world // Not compiled or tested in-world // Setup: Place in a spare prim. Set RADIUS and both latitude/longitude pairs in degrees. Owner touch prints results without altering the scene. // Stop / restore: Disable or remove. No prim properties are changed. // Notes: Uses the haversine formula with clamping. This is a model-sphere tool; it does not query real-world geolocation. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Owner-only calculation. float RADIUS=10.0; float LAT1=10.0; float LON1=20.0; float LAT2=35.0; float LON2=75.0; default { touch_start(integer detectedCount) { if (llDetectedKey(0)!=llGetOwner()) return; if(RADIUS<=0.0||llFabs(LAT1)>90.0||llFabs(LAT2)>90.0) { llOwnerSay("Invalid radius/latitude."); return; } float p1=LAT1*DEG_TO_RAD; float p2=LAT2*DEG_TO_RAD; float dp=(LAT2-LAT1)*DEG_TO_RAD; float dl=(LON2-LON1)*DEG_TO_RAD; float h=llPow(llSin(dp*0.5),2.0)+llCos(p1)*llCos(p2)*llPow(llSin(dl*0.5),2.0); if(h<0.0)h=0.0; if(h>1.0)h=1.0; llOwnerSay("Surface arc="+(string)(2.0*RADIUS*llAtan2(llSqrt(h),llSqrt(1.0-h)))); } }