/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{acosClamped as t,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{dot as e,cross as s,scale as h,normalize as r,negate as a,subtract as n,copy as g,add as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{PathFrame2D as f}from"./PathFrame2D.js";class c{constructor(){this.vLeft=m(),this.vRight=m(),this.vMinSiblingLength=0,this.frame=new f}setFrameFromUpVector(t){g(this.frame.up,t),o(x,this.vLeft,this.vRight),r(x,x),h(b,this.frame.up,e(x,this.frame.up)),n(A,x,b),r(A,A),s(this.frame.right,A,this.frame.up)}get foldingAngle(){return Math.PI-this.rotationAngle}}class v extends c{get rotationFrameUp(){return this.frame.up}get rotationAngle(){h(L,this.frame.up,e(this.frame.up,this.vLeft)),n(L,this.vLeft,L),a(L,L),r(L,L),h(R,this.frame.up,e(this.frame.up,this.vRight)),n(R,this.vRight,R),r(R,R),s(M,this.rotationFrameUp,this.vLeft);return Math.sign(e(M,this.vRight))*(Math.PI-t(e(L,R)))}get maxStretchDistance(){return Math.abs(this.vMinSiblingLength/Math.cos(.5*this.foldingAngle))}}class l extends c{get rotationFrameUp(){const t=Math.sign(e(this.frame.right,this.vRight));return s(p,this.vRight,this.vLeft),h(p,p,t),r(p,p)}get rotationAngle(){const i=Math.sign(e(this.frame.right,this.vRight));return a(M,this.vLeft),-i*(Math.PI-t(e(M,this.vRight)))}get maxStretchDistance(){return Math.abs(this.vMinSiblingLength*i(Math.cos(.5*this.foldingAngle)))}}function u(t){switch(t){case 0:return new v;case 1:return new l}}const p=m(),M=m(),L=m(),R=m(),b=m(),x=m(),A=m();export{c as PathVertex,u as newPathVertex};
