/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{rad2deg as n,deg2rad as t}from"../../../core/mathUtils.js";function e(t,e,o,a){const d=o-t,i=a-e;return 90-n(Math.atan2(i,d))}function o(n){let t=n%360;return t<0&&(t+=360),t}function a(n,t){const e={towards:{distance:1/0,node:null},backwards:{distance:1/0,node:null},left:{distance:1/0,node:null},right:{distance:1/0,node:null}};t.forEach(t=>{if(n===t)return;const a=n.getDistanceTo(t),d=n.getDirectionTo(t);a>=e[d].distance||(e[d].node=t,e[d].distance=a,e[d].heading=o(t.heading),e[d].pitch=o(t.pitch))}),n.reset(),n.towards=e.towards.node,n.backwards=e.backwards.node,n.left=e.left.node,n.right=e.right.node}function d(n,t,e,a){const d={towards:{distance:1/0,node:null},backwards:{distance:1/0,node:null},left:{distance:1/0,node:null},right:{distance:1/0,node:null}};t.forEach(t=>{if(n===t)return;const c=n.getDistanceTo(t),r=n.getDirectionTo(t),s=o(n.heading)-o(o(t.heading)),l=o(n.pitch)-o(t.pitch);c>=d[r].distance||null!=e&&!i(s,e)||null!=a&&!i(l,a)||(d[r].node=t,d[r].distance=c,d[r].heading=o(t.heading),d[r].pitch=o(t.pitch))}),n.reset(),n.towards=d.towards.node,n.backwards=d.backwards.node,n.left=d.left.node,n.right=d.right.node}function i(n,t){return Math.abs(n)<=t}function c(n){const e=t(90-n);return{x:Math.cos(e),y:-Math.sin(e)}}export{c as getPixelXYFromRelativeAngle,e as getRelativeAngleBetweenPoints,o as normalizeDegrees,a as updateDirectionalNodesGeneric,d as updateDirectionalNodesWithSameView};
