/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
export { C as Camera, c as ColorMaterial, a as CrossSectioner, I as ItemOperationBuilder, l as LoadableResource, M as ModelViewController, P as PmiAnnotationOperationsBuilder, b as PmiAnnotationsQueryExecutor, k as PmiController, R as Raycaster, d as RootQuery, S as Scene, e as SceneElementQueryExecutor, f as SceneElementsOperationExecutor, g as SceneItemOperationsBuilder, h as SceneItemQueryExecutor, i as SceneItemsOperationExecutor, s as SceneViewStateIdentifier, j as SynchronizedClock } from './queries-DanpzOcX.js';
export { S as SceneTreeController } from './controller-zACO6f4n.js';
export { f as fromNodeProto, i as isLoadedRow } from './row-CiSHWNC4.js';
export { S as SCENE_ITEM_NAME_METADATA_KEY } from './types-BZwvQkyb.js';
export { C as CursorManager, b as boxQueryCursor, l as labelPinCursor, m as measurementCursor, a as measurementWithArrowCursor, p as pinCursor } from './cursors-DImFnILd.js';
export { M as MeasurementController, a as MeasurementEntity } from './entities-DUXv_nvW.js';
export { M as MeasurementModel } from './model-D1YLEyZC.js';
export { M as MeasurementOverlayManager } from './overlays-BlZ9sQii.js';
export { m as makeMinimumDistanceResult } from './results-BQYjtgFJ.js';
import { v as vector3, q as quaternion, m as matrix4 } from './bundle-DfdVaPrt.js';
export { T as TransformController } from './controller-Dos03RTp.js';
export { f as flattenPointArray, a as toDegreesTransform, e as toLocalTransform, b as toMatrix, t as toRadiansTransform, c as toTransform, d as toWorldTransform } from './util-BrZtfp84.js';
export { A as AngleUnits, g as AreaUnits, c as CrossSectioning, D as DistanceUnits, F as FrameCameraBase, O as Orientation, a as ReceivedFrame, b as ReceivedFrameImage, d as ReceivedFrameScene, e as ReceivedOrthographicCamera, f as ReceivedPerspectiveCamera, S as StandardView } from './streamAttributes-B6xi3kRV.js';
export { E as EntityType } from './entities-BAhfr1Nx.js';
export { A as ArrowMarkup, C as CircleMarkup, F as FreeformMarkup } from './markup-DGlCz24T.js';
export { V as Viewport } from './viewport-DbTg_ax4.js';
export { V as VolumeIntersectionQueryController, a as VolumeIntersectionQueryModel } from './model-8GUOMUgr.js';
import './bundle-DLfw87TV.js';
import './_commonjsHelpers-CG9AChtV.js';
import './errors-Cs13_LRq.js';
import './wrappers_pb-Xw_x1jYm.js';
import './representation_pb-CQzLHWhX.js';
import './wrappers_pb-aFAwKqIf.js';
import './grpc-CZAYqbTu.js';
import './bundle-CLE0fYge.js';
import './geometry_pb-BPrLQ_K_.js';

const ALMOST_ONE = 0.9999;
/**
 * For any single normal vector, there are an infinite number of potential orthogonal vectors. This function will
 * calculate a single vector evaluating the length of two candidates, and picking the one with the higher squared magnitude
 * @param normal
 * @returns
 */
function calculateOrthogonalCoordinate(norm) {
    const orthogonalCandidate0 = vector3.create(0, norm.z, -norm.y);
    const orthogonalCandidate1 = vector3.create(-norm.z, 0, norm.x);
    const theChosenOne = vector3.magnitudeSquared(orthogonalCandidate0) >
        vector3.magnitudeSquared(orthogonalCandidate1)
        ? orthogonalCandidate0
        : orthogonalCandidate1;
    return vector3.normalize(vector3.cross(norm, theChosenOne));
}
/**
 * Computes the rotation matrix for two normals. If both normals are neither parallel nor anti-parallel,
 * this will compute the rotation matrix delta based on the angle from both normals.
 * If the normals are anti-parallel, the identity matrix will be returned, as no rotation is necessary in this case.
 * If the normals are parallel, an axis direction based on a chosen orthogonal vector will be used
 * to compute the rotation matrix to rotate the plane 180 degrees.
 * @param normal1
 * @param normal2
 * @returns an anti-parallel rotation Matrix4 between the given normals
 */
function computeRotationMatrix(normal1, normal2) {
    const dot = vector3.dot(normal1, normal2);
    // the angle is almost 0 in this case.
    if (dot > ALMOST_ONE) {
        const axisDirection = calculateOrthogonalCoordinate(normal1);
        const quaternion$1 = quaternion.fromAxisAngle(axisDirection, Math.PI);
        return matrix4.makeRotation(quaternion$1);
    }
    // the angle is almost 180 in this case.
    else if (dot <= -ALMOST_ONE) {
        return matrix4.makeIdentity();
    }
    // the angle is between 0 & 180
    else {
        const angle = vector3.angleTo(normal2, normal1);
        const axisDirection = vector3.normalize(vector3.cross(normal1, normal2));
        return matrix4.makeRotation(quaternion.fromAxisAngle(axisDirection, angle + Math.PI));
    }
}
/**
 * Computes the translation & rotation matrix delta between two world positions and two normals.
 * such that the computed translation matrix will be the delta between position 1 and position 2,
 * and the rotation will be rotated to be anti-parallel.
 *
 * @param normal1
 * @param position1
 * @param normal2
 * @param position2
 *
 * @returns Matrix4 translation matrix delta from position1 to
 * position2 & an anti-parallel rotation delta.
 */
function computeTransformationDelta(normal1, position1, normal2, position2) {
    const rotationMatrix = computeRotationMatrix(normal1, normal2);
    const translationDeltaMatrix = matrix4.makeTranslation(position2);
    return matrix4.multiply(matrix4.multiply(translationDeltaMatrix, rotationMatrix), matrix4.makeTranslation(vector3.negate(position1)));
}

var transformationDelta = /*#__PURE__*/Object.freeze({
    __proto__: null,
    ALMOST_ONE: ALMOST_ONE,
    calculateOrthogonalCoordinate: calculateOrthogonalCoordinate,
    computeRotationMatrix: computeRotationMatrix,
    computeTransformationDelta: computeTransformationDelta
});

export { transformationDelta as TransformationDelta };
//# sourceMappingURL=index.js.map

//# sourceMappingURL=index.js.map