@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 6.82 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{create as t}from"../factories/quatf64.js";import{create as n}from"../factories/vec3f64.js";import{getEpsilon as a}from"./common.js";import{getRotation as r,getTranslation as o}from"./mat4.js";import{copy as e,dot as s,length as u,squaredLength as c,rotateX as i,rotateY as f,rotateZ as h}from"./quat.js";function M(t,n,a){const r=.5*a[0],o=.5*a[1],e=.5*a[2],s=n[0],u=n[1],c=n[2],i=n[3];return t[0]=s,t[1]=u,t[2]=c,t[3]=i,t[4]=r*i+o*c-e*u,t[5]=o*i+e*s-r*c,t[6]=e*i+r*u-o*s,t[7]=-r*s-o*u-e*c,t}function l(t,n){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*n[0],t[5]=.5*n[1],t[6]=.5*n[2],t[7]=0,t}function m(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t}function b(t,n){const a=p;r(a,n);const e=d;return o(e,n),M(t,a,e),t}const p=t(),d=n();function g(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t}function q(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t}function x(t,n,a,r,o,e,s,u,c){return t[0]=n,t[1]=a,t[2]=r,t[3]=o,t[4]=e,t[5]=s,t[6]=u,t[7]=c,t}const j=e;function y(t,n){return t[0]=n[4],t[1]=n[5],t[2]=n[6],t[3]=n[7],t}const T=e;function R(t,n){return t[4]=n[0],t[5]=n[1],t[6]=n[2],t[7]=n[3],t}function _(t,n){const a=n[4],r=n[5],o=n[6],e=n[7],s=-n[0],u=-n[1],c=-n[2],i=n[3];return t[0]=2*(a*i+e*s+r*c-o*u),t[1]=2*(r*i+e*u+o*s-a*c),t[2]=2*(o*i+e*c+a*u-r*s),t}function v(t,n,a){const r=n[0],o=n[1],e=n[2],s=n[3],u=.5*a[0],c=.5*a[1],i=.5*a[2],f=n[4],h=n[5],M=n[6],l=n[7];return t[0]=r,t[1]=o,t[2]=e,t[3]=s,t[4]=s*u+o*i-e*c+f,t[5]=s*c+e*u-r*i+h,t[6]=s*i+r*c-o*u+M,t[7]=-r*u-o*c-e*i+l,t}function A(t,n,a){let r=-n[0],o=-n[1],e=-n[2],s=n[3];const u=n[4],c=n[5],f=n[6],h=n[7],M=u*s+h*r+c*e-f*o,l=c*s+h*o+f*r-u*e,m=f*s+h*e+u*o-c*r,b=h*s-u*r-c*o-f*e;return i(t,n,a),r=t[0],o=t[1],e=t[2],s=t[3],t[4]=M*s+b*r+l*e-m*o,t[5]=l*s+b*o+m*r-M*e,t[6]=m*s+b*e+M*o-l*r,t[7]=b*s-M*r-l*o-m*e,t}function L(t,n,a){let r=-n[0],o=-n[1],e=-n[2],s=n[3];const u=n[4],c=n[5],i=n[6],h=n[7],M=u*s+h*r+c*e-i*o,l=c*s+h*o+i*r-u*e,m=i*s+h*e+u*o-c*r,b=h*s-u*r-c*o-i*e;return f(t,n,a),r=t[0],o=t[1],e=t[2],s=t[3],t[4]=M*s+b*r+l*e-m*o,t[5]=l*s+b*o+m*r-M*e,t[6]=m*s+b*e+M*o-l*r,t[7]=b*s-M*r-l*o-m*e,t}function z(t,n,a){let r=-n[0],o=-n[1],e=-n[2],s=n[3];const u=n[4],c=n[5],i=n[6],f=n[7],M=u*s+f*r+c*e-i*o,l=c*s+f*o+i*r-u*e,m=i*s+f*e+u*o-c*r,b=f*s-u*r-c*o-i*e;return h(t,n,a),r=t[0],o=t[1],e=t[2],s=t[3],t[4]=M*s+b*r+l*e-m*o,t[5]=l*s+b*o+m*r-M*e,t[6]=m*s+b*e+M*o-l*r,t[7]=b*s-M*r-l*o-m*e,t}function B(t,n,a){const r=a[0],o=a[1],e=a[2],s=a[3];let u=n[0],c=n[1],i=n[2],f=n[3];return t[0]=u*s+f*r+c*e-i*o,t[1]=c*s+f*o+i*r-u*e,t[2]=i*s+f*e+u*o-c*r,t[3]=f*s-u*r-c*o-i*e,u=n[4],c=n[5],i=n[6],f=n[7],t[4]=u*s+f*r+c*e-i*o,t[5]=c*s+f*o+i*r-u*e,t[6]=i*s+f*e+u*o-c*r,t[7]=f*s-u*r-c*o-i*e,t}function D(t,n,a){const r=n[0],o=n[1],e=n[2],s=n[3];let u=a[0],c=a[1],i=a[2],f=a[3];return t[0]=r*f+s*u+o*i-e*c,t[1]=o*f+s*c+e*u-r*i,t[2]=e*f+s*i+r*c-o*u,t[3]=s*f-r*u-o*c-e*i,u=a[4],c=a[5],i=a[6],f=a[7],t[4]=r*f+s*u+o*i-e*c,t[5]=o*f+s*c+e*u-r*i,t[6]=e*f+s*i+r*c-o*u,t[7]=s*f-r*u-o*c-e*i,t}function O(t,n,r,o){if(Math.abs(o)<a())return g(t,n);const e=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);o*=.5;const s=Math.sin(o),u=s*r[0]/e,c=s*r[1]/e,i=s*r[2]/e,f=Math.cos(o),h=n[0],M=n[1],l=n[2],m=n[3];t[0]=h*f+m*u+M*i-l*c,t[1]=M*f+m*c+l*u-h*i,t[2]=l*f+m*i+h*c-M*u,t[3]=m*f-h*u-M*c-l*i;const b=n[4],p=n[5],d=n[6],q=n[7];return t[4]=b*f+q*u+p*i-d*c,t[5]=p*f+q*c+d*u-b*i,t[6]=d*f+q*i+b*c-p*u,t[7]=q*f-b*u-p*c-d*i,t}function P(t,n,a){return t[0]=n[0]+a[0],t[1]=n[1]+a[1],t[2]=n[2]+a[2],t[3]=n[3]+a[3],t[4]=n[4]+a[4],t[5]=n[5]+a[5],t[6]=n[6]+a[6],t[7]=n[7]+a[7],t}function Q(t,n,a){const r=n[0],o=n[1],e=n[2],s=n[3],u=a[4],c=a[5],i=a[6],f=a[7],h=n[4],M=n[5],l=n[6],m=n[7],b=a[0],p=a[1],d=a[2],g=a[3];return t[0]=r*g+s*b+o*d-e*p,t[1]=o*g+s*p+e*b-r*d,t[2]=e*g+s*d+r*p-o*b,t[3]=s*g-r*b-o*p-e*d,t[4]=r*f+s*u+o*i-e*c+h*g+m*b+M*d-l*p,t[5]=o*f+s*c+e*u-r*i+M*g+m*p+l*b-h*d,t[6]=e*f+s*i+r*c-o*u+l*g+m*d+h*p-M*b,t[7]=s*f-r*u-o*c-e*i+m*g-h*b-M*p-l*d,t}const S=Q;function X(t,n,a){return t[0]=n[0]*a,t[1]=n[1]*a,t[2]=n[2]*a,t[3]=n[3]*a,t[4]=n[4]*a,t[5]=n[5]*a,t[6]=n[6]*a,t[7]=n[7]*a,t}const Y=s;function Z(t,n,a,r){const o=1-r;return Y(n,a)<0&&(r=-r),t[0]=n[0]*o+a[0]*r,t[1]=n[1]*o+a[1]*r,t[2]=n[2]*o+a[2]*r,t[3]=n[3]*o+a[3]*r,t[4]=n[4]*o+a[4]*r,t[5]=n[5]*o+a[5]*r,t[6]=n[6]*o+a[6]*r,t[7]=n[7]*o+a[7]*r,t}function E(t,n){const a=F(n);return t[0]=-n[0]/a,t[1]=-n[1]/a,t[2]=-n[2]/a,t[3]=n[3]/a,t[4]=-n[4]/a,t[5]=-n[5]/a,t[6]=-n[6]/a,t[7]=n[7]/a,t}function k(t,n){return t[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t[3]=n[3],t[4]=-n[4],t[5]=-n[5],t[6]=-n[6],t[7]=n[7],t}const w=u,C=w,F=c,G=F;function H(t,n){let a=F(n);if(a>0){a=Math.sqrt(a);const r=n[0]/a,o=n[1]/a,e=n[2]/a,s=n[3]/a,u=n[4],c=n[5],i=n[6],f=n[7],h=r*u+o*c+e*i+s*f;t[0]=r,t[1]=o,t[2]=e,t[3]=s,t[4]=(u-r*h)/a,t[5]=(c-o*h)/a,t[6]=(i-e*h)/a,t[7]=(f-s*h)/a}return t}function I(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"}function J(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&t[4]===n[4]&&t[5]===n[5]&&t[6]===n[6]&&t[7]===n[7]}function K(t,n){const r=t[0],o=t[1],e=t[2],s=t[3],u=t[4],c=t[5],i=t[6],f=t[7],h=n[0],M=n[1],l=n[2],m=n[3],b=n[4],p=n[5],d=n[6],g=n[7],q=a();return Math.abs(r-h)<=q*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(o-M)<=q*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(e-l)<=q*Math.max(1,Math.abs(e),Math.abs(l))&&Math.abs(s-m)<=q*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(u-b)<=q*Math.max(1,Math.abs(u),Math.abs(b))&&Math.abs(c-p)<=q*Math.max(1,Math.abs(c),Math.abs(p))&&Math.abs(i-d)<=q*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(f-g)<=q*Math.max(1,Math.abs(f),Math.abs(g))}const N=Object.freeze(Object.defineProperty({__proto__:null,add:P,conjugate:k,copy:g,dot:Y,equals:K,exactEquals:J,fromMat4:b,fromRotation:m,fromRotationTranslation:M,fromTranslation:l,getDual:y,getReal:j,getTranslation:_,identity:q,invert:E,len:C,length:w,lerp:Z,mul:S,multiply:Q,normalize:H,rotateAroundAxis:O,rotateByQuatAppend:B,rotateByQuatPrepend:D,rotateX:A,rotateY:L,rotateZ:z,scale:X,set:x,setDual:R,setReal:T,sqrLen:G,squaredLength:F,str:I,translate:v},Symbol.toStringTag,{value:"Module"}));export{P as add,k as conjugate,g as copy,Y as dot,K as equals,J as exactEquals,b as fromMat4,m as fromRotation,M as fromRotationTranslation,l as fromTranslation,y as getDual,j as getReal,_ as getTranslation,q as identity,E as invert,C as len,w as length,Z as lerp,S as mul,Q as multiply,H as normalize,N as q,O as rotateAroundAxis,B as rotateByQuatAppend,D as rotateByQuatPrepend,A as rotateX,L as rotateY,z as rotateZ,X as scale,x as set,R as setDual,T as setReal,G as sqrLen,F as squaredLength,I as str,v as translate};