UNPKG

@itwin/core-frontend

Version:
28 lines 1.2 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Utils */ /** @internal */ export function linePlaneIntersect(outP, linePt, lineNormal, planePt, planeNormal, perpendicular) { let dot = 0; if (lineNormal) dot = lineNormal.dotProduct(planeNormal); else perpendicular = true; let temp; if (perpendicular || Math.abs(dot) < .001) { const t = linePt.vectorTo(planePt).dotProduct(planeNormal); temp = planeNormal.scale(t); } else { const t = (planeNormal.dotProduct(planePt) - planeNormal.dotProduct(linePt)) / dot; // If lineNormal is undefined, perpendicular will be true, so we can't get here. // eslint-disable-next-line @typescript-eslint/no-non-null-assertion temp = lineNormal.scale(t); } outP.setFrom(temp.plus(linePt)); } //# sourceMappingURL=LinePlaneIntersect.js.map