/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{dot as t,set as e,add as r,scale as n,squaredDistance as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{planeFromPoints as i}from"../../support/mathUtils.js";function c(t,i){e(i.center,0,0,0);for(let e=0;e<t.length;++e)r(i.center,i.center,t[e]);n(i.center,i.center,1/t.length);let c=0;for(let e=0;e<t.length;++e)c=Math.max(c,o(i.center,t[e]));i.radius=Math.sqrt(c)}function l(t,e){if(t.length<3)throw new Error("need at least 3 points to fit a plane");i(t[0],t[1],t[2],e)}function a(e,r){return t(e,r)+e[3]}function f(t){return"mouse"!==t.pointerType||0===t.button}export{l as bestFitPlane,c as boundingSphere,f as isPrimaryPointerAction,a as planePointDistance};
