quat.4f976512.js 3.6 KB

1
  1. import{e as L}from"./mat3f64.6d32a1d7.js";import{e as I}from"./quatf64.4ae3e6f1.js";import{fZ as _,f_ as O,fB as S,f$ as T,g0 as Y,g1 as Z,g2 as w,g3 as B,g4 as D,g5 as W,g6 as X,g7 as k,ft as C,fw as d,g8 as F,fy as G,E as H,ab as b,g9 as J}from"./index.6c049565.js";function K(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function A(n,o,a){a*=.5;const r=Math.sin(a);return n[0]=r*o[0],n[1]=r*o[1],n[2]=r*o[2],n[3]=Math.cos(a),n}function N(n,o){const a=2*Math.acos(o[3]),r=Math.sin(a/2);return r>_()?(n[0]=o[0]/r,n[1]=o[1]/r,n[2]=o[2]/r):(n[0]=1,n[1]=0,n[2]=0),a}function E(n,o,a){const r=o[0],e=o[1],c=o[2],t=o[3],u=a[0],i=a[1],h=a[2],M=a[3];return n[0]=r*M+t*u+e*h-c*i,n[1]=e*M+t*i+c*u-r*h,n[2]=c*M+t*h+r*i-e*u,n[3]=t*M-r*u-e*i-c*h,n}function Q(n,o,a){a*=.5;const r=o[0],e=o[1],c=o[2],t=o[3],u=Math.sin(a),i=Math.cos(a);return n[0]=r*i+t*u,n[1]=e*i+c*u,n[2]=c*i-e*u,n[3]=t*i-r*u,n}function R(n,o,a){a*=.5;const r=o[0],e=o[1],c=o[2],t=o[3],u=Math.sin(a),i=Math.cos(a);return n[0]=r*i-c*u,n[1]=e*i+t*u,n[2]=c*i+r*u,n[3]=t*i-e*u,n}function U(n,o,a){a*=.5;const r=o[0],e=o[1],c=o[2],t=o[3],u=Math.sin(a),i=Math.cos(a);return n[0]=r*i+e*u,n[1]=e*i-r*u,n[2]=c*i+t*u,n[3]=t*i-c*u,n}function V(n,o){const a=o[0],r=o[1],e=o[2];return n[0]=a,n[1]=r,n[2]=e,n[3]=Math.sqrt(Math.abs(1-a*a-r*r-e*e)),n}function $(n,o,a,r){const e=o[0],c=o[1],t=o[2],u=o[3];let i,h,M,s,l,g=a[0],m=a[1],q=a[2],p=a[3];return h=e*g+c*m+t*q+u*p,h<0&&(h=-h,g=-g,m=-m,q=-q,p=-p),1-h>_()?(i=Math.acos(h),M=Math.sin(i),s=Math.sin((1-r)*i)/M,l=Math.sin(r*i)/M):(s=1-r,l=r),n[0]=s*e+l*g,n[1]=s*c+l*m,n[2]=s*t+l*q,n[3]=s*u+l*p,n}function nn(n){const o=J,a=o(),r=o(),e=o(),c=Math.sqrt(1-a),t=Math.sqrt(a);return n[0]=c*Math.sin(2*Math.PI*r),n[1]=c*Math.cos(2*Math.PI*r),n[2]=t*Math.sin(2*Math.PI*e),n[3]=t*Math.cos(2*Math.PI*e),n}function on(n,o){const a=o[0],r=o[1],e=o[2],c=o[3],t=a*a+r*r+e*e+c*c,u=t?1/t:0;return n[0]=-a*u,n[1]=-r*u,n[2]=-e*u,n[3]=c*u,n}function rn(n,o){return n[0]=-o[0],n[1]=-o[1],n[2]=-o[2],n[3]=o[3],n}function j(n,o){const a=o[0]+o[4]+o[8];let r;if(a>0)r=Math.sqrt(a+1),n[3]=.5*r,r=.5/r,n[0]=(o[5]-o[7])*r,n[1]=(o[6]-o[2])*r,n[2]=(o[1]-o[3])*r;else{let e=0;o[4]>o[0]&&(e=1),o[8]>o[3*e+e]&&(e=2);const c=(e+1)%3,t=(e+2)%3;r=Math.sqrt(o[3*e+e]-o[3*c+c]-o[3*t+t]+1),n[e]=.5*r,r=.5/r,n[3]=(o[3*c+t]-o[3*t+c])*r,n[c]=(o[3*c+e]+o[3*e+c])*r,n[t]=(o[3*t+e]+o[3*e+t])*r}return n}function en(n,o,a,r){const e=.5*Math.PI/180;o*=e,a*=e,r*=e;const c=Math.sin(o),t=Math.cos(o),u=Math.sin(a),i=Math.cos(a),h=Math.sin(r),M=Math.cos(r);return n[0]=c*i*M-t*u*h,n[1]=t*u*M+c*i*h,n[2]=t*i*h-c*u*M,n[3]=t*i*M+c*u*h,n}function an(n){return"quat("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+")"}const cn=O,tn=S,un=T,hn=E,Mn=Y,fn=Z,sn=w,v=B,ln=v,z=D,gn=z,y=W,mn=X,qn=k;function pn(n,o,a){const r=C(o,a);return r<-.999999?(d(f,$n,o),F(f)<1e-6&&d(f,dn,o),G(f,f),A(n,f,Math.PI),n):r>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(d(f,o,a),n[0]=f[0],n[1]=f[1],n[2]=f[2],n[3]=1+r,y(n,n))}const f=H(),$n=b(1,0,0),dn=b(0,1,0);function yn(n,o,a,r,e,c){return $(P,o,e,c),$(x,a,r,c),$(n,P,x,2*c*(1-c)),n}const P=I(),x=I();function Pn(n,o,a,r){const e=xn;return e[0]=a[0],e[3]=a[1],e[6]=a[2],e[1]=r[0],e[4]=r[1],e[7]=r[2],e[2]=-o[0],e[5]=-o[1],e[8]=-o[2],y(n,j(n,e))}const xn=L();Object.freeze(Object.defineProperty({__proto__:null,identity:K,setAxisAngle:A,getAxisAngle:N,multiply:E,rotateX:Q,rotateY:R,rotateZ:U,calculateW:V,slerp:$,random:nn,invert:on,conjugate:rn,fromMat3:j,fromEuler:en,str:an,copy:cn,set:tn,add:un,mul:hn,scale:Mn,dot:fn,lerp:sn,length:v,len:ln,squaredLength:z,sqrLen:gn,normalize:y,exactEquals:mn,equals:qn,rotationTo:pn,sqlerp:yn,setAxes:Pn},Symbol.toStringTag,{value:"Module"}));export{mn as K,rn as S,en as k,A as v,N as x,E as y};