@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 807 B
JavaScript
import{flipAngle as h,getRotation as y,shouldFlip as u}from"../update-def";export function isInnerInsideOuter(t,n){if(!n)return!1;const o=Math.cos(n.rotation),s=Math.sin(n.rotation),i=n.size.x/2,r=n.size.y/2;return f(t,t.rotation+Math.PI/2).every(e=>{const a=e.x-n.center.x,x=e.y-n.center.y,c=a*o+x*s,d=x*o-a*s;return Math.abs(c)<=i&&Math.abs(d)<=r})}function f(t,n=t.rotation){const o=t.size.x/2,s=t.size.y/2,i=Math.sin(n),r=Math.cos(n),e=t.center.x,a=t.center.y;return[{x:-o,y:-s},{x:o,y:-s},{x:o,y:s},{x:-o,y:s}].map(c=>({x:e+c.x*r-c.y*i,y:a+c.x*i+c.y*r}))}export function flipImageDef(t,n){const o=t.bounds.rotation;return u(n,o)&&(t.bounds.rotation=h(t.bounds.rotation)),t}export function rotateImageDef(t,n){const o=y(n,t.bounds.rotation);return o!==void 0&&(t.bounds.rotation=t.bounds.rotation+o),t}