/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{rad2deg as t,acosClamped as o}from"../../../core/mathUtils.js";import{n as s,g as r,d as e,j as n,e as i,b as a,f as c}from"../../../chunks/vec32.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrap as f}from"../../../geometry/support/lineSegment.js";import{intersectLineSegment as p}from"../../../geometry/support/plane.js";const l=m(),u=m();function g(){return{direction:m(),up:m()}}function h(m,f,p,g,h){let j=s(l,m),b=r(j,g);const d=b>0;b=Math.abs(b),b>.99&&(b=Math.abs(r(f,g)),b<.99?(e(j,f),d&&n(j,j,-1)):j=null);let v=0;if(j){n(u,g,r(g,j)),i(j,j,u);const s=r(j,h)/(a(j)*a(h));c(u,j,h);v=(r(u,g)>0?1:-1)*t(o(s))}const x=t(o(-r(g,m)/a(m)));return p?(p.heading=v,p.tilt=x,p):{heading:v,tilt:x}}function j(t,o,s,r){i(b,s,o),p(r,f(o,b),t)||t===s||e(t,s)}const b=m();export{j as clampLineSegmentToPlane,g as createDirectionUp,h as directionToHeadingTilt};
