UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.69 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{c as t,i as e,f as r,n,h as o,e as s,g as i,s as f}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import a from"../../../../geometry/Polygon.js";import{a as u}from"../../../../chunks/sphere.js";import{planeFromPoints as c}from"../../support/mathUtils.js";function h(t,n){const o=u(n);e(o,0,0,0);for(let e=0;e<t.length;++e)r(o,o,t[e]);i(o,o,1/t.length);let s=0;for(let e=0;e<t.length;++e)s=Math.max(s,f(o,t[e]));n[3]=Math.sqrt(s)}function g(t,e){if(t.length<3)throw new Error("need at least 3 points to fit a plane");c(t[0],t[1],t[2],e)}function m(t,e){return s(t,e)+t[3]}function p(e,r,n,o,{geodesicArea:s}){const i=x;return t(i.rings[0][0],e),t(i.rings[0][1],r),t(i.rings[0][2],n),t(i.rings[0][3],e),i.spatialReference=o,i.clearCache(),s(i)}function j(i,f=null,l=!0){const a=(t,e)=>{if(0===e[0]&&0===e[1]&&0===e[2])return!1;for(let r=0;r<t.length;++r)if(s(e,t[r])<-1e-6)return!1;return!0};if(0===i.length)return!1;if(1===i.length)return f&&t(f,i[0]),!0;e(y,0,0,0);for(let t=0;t<i.length;++t)r(y,y,i[t]);if(n(y,y),a(i,y))return f&&t(f,y),!0;if(!l)return!1;for(let e=0;e<i.length;++e)for(let r=0;r<i.length;++r)if(e!==r&&(o(y,i[e],i[r]),n(y,y),a(i,y)))return f&&t(f,y),!0;return!1}function w(t){return"mouse"!==t.pointerType||0===t.button}const x=new a({hasM:!1,hasZ:!0,rings:[[l(),l(),l(),l()]],spatialReference:null}),y=l();export{g as bestFitPlane,h as boundingSphere,j as fitHemisphere,w as isPrimaryPointerAction,m as planePointDistance,p as triangleAreaGeodesic};