// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Test overlap of two rotated floor rectangles // Not compiled or tested in-world // Setup: Use a spare owned prim. Set centers, positive half-extents and yaw degrees. Touch for owner-only calculation output. // Stop / restore: Remove/disable. Does not sense, collide with, or modify actual objects. // Notes: Tangency counts as overlap. This is a static test and does not calculate a collision response. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Ideal geometry only. vector A=ZERO_VECTOR; vector B=<3.0,1.0,0.0>; vector HA=<2.0,1.0,0.0>; vector HB=<1.5,1.0,0.0>; float ANGLE_A=20.0; float ANGLE_B=-15.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(HA.x<=0.0||HA.y<=0.0||HB.x<=0.0||HB.y<=0.0) { llOwnerSay("Positive extents required."); return; } float a=ANGLE_A*DEG_TO_RAD; float b=ANGLE_B*DEG_TO_RAD; vector ax=; vector ay=<-ax.y,ax.x,0.0>; vector bx=; vector by=<-bx.y,bx.x,0.0>; list axes=[ax,ay,bx,by]; vector delta=B-A; integer i; for(i=0;i<4;++i) { vector axis=llList2Vector(axes,i); float ra=HA.x*llFabs(ax*axis)+HA.y*llFabs(ay*axis); float rb=HB.x*llFabs(bx*axis)+HB.y*llFabs(by*axis); if(llFabs(delta*axis)>ra+rb) { llOwnerSay("Separated on axis "+(string)i); return; } } llOwnerSay("Rectangles touch or overlap."); } }