UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.89 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{ObjectStack as t}from"../../core/ObjectStack.js";import{d as e,l as n,h as r,c as o,e as c,g as s,f as p}from"../../chunks/vec32.js";import{create as i,clone as a}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as f,distance2 as u,fromValues as g}from"./lineSegment.js";import{sv3d as m}from"./vectorStacks.js";function j(t){return t?{p0:a(t.p0),p1:a(t.p1),p2:a(t.p2)}:{p0:i(),p1:i(),p2:i()}}function l(t,e,n){const r=x.get();return r.p0=t,r.p1=e,r.p2=n,r}function h(t,e=j()){return b(t.p0,t.p1,t.p2,e)}function b(t,e,n,r=j()){return o(r.p0,t),o(r.p1,e),o(r.p2,n),r}function d(t,n){const o=t.p0,s=t.p1,p=t.p2,i=e(m.get(),s,o),a=e(m.get(),p,s),f=e(m.get(),o,p),j=e(m.get(),n,o),l=e(m.get(),n,s),h=e(m.get(),n,p),b=r(i,i,f),d=c(r(m.get(),i,b),j),k=c(r(m.get(),a,b),l),v=c(r(m.get(),f,b),h);if(d>0&&k>0&&v>0){const t=c(b,j);return t*t/c(b,b)}const S=u(g(o,i,w.get()),n),x=u(g(s,a,w.get()),n),M=u(g(p,f,w.get()),n);return Math.min(S,x,M)}function k(t,e,n){const r=1e-5,{direction:o,origin:c}=e,{p0:i,p1:a,p2:f}=t,u=a[0]-i[0],g=a[1]-i[1],m=a[2]-i[2],j=f[0]-i[0],l=f[1]-i[1],h=f[2]-i[2],b=o[1]*h-l*o[2],d=o[2]*j-h*o[0],k=o[0]*l-j*o[1],v=u*b+g*d+m*k;if(v>-1e-5&&v<r)return!1;const S=1/v,w=c[0]-i[0],x=c[1]-i[1],M=c[2]-i[2],O=S*(w*b+x*d+M*k);if(O<0||O>1)return!1;const V=x*m-g*M,q=M*u-m*w,y=w*g-u*x,z=S*(o[0]*V+o[1]*q+o[2]*y);if(z<0||O+z>1)return!1;if(n){s(n,o,S*(j*V+l*q+h*y)),p(n,c,n)}return!0}function v(t,e,n){const r=e[0]-t[0],o=e[1]-t[1],c=n[0]-t[0],s=n[1]-t[1];return.5*Math.abs(r*s-o*c)}function S(t,o,c){return e(M,o,t),e(O,c,t),.5*n(r(M,M,O))}const w=new t(f),x=new t((()=>j())),M=i(),O=i();export{v as areaPoints2d,S as areaPoints3d,h as copy,j as create,d as distance2,b as fromValues,k as intersectRay,l as wrap};