|
|
|
@ -229,23 +229,14 @@ export function IntersectLAndLFor3D(p1: Vector3, p2: Vector3, p3: Vector3, p4: V
|
|
|
|
|
let z43 = p4.z - p3.z;
|
|
|
|
|
let z42 = p4.z - p2.z;
|
|
|
|
|
|
|
|
|
|
let pt: Vector3;
|
|
|
|
|
|
|
|
|
|
let v1 = p2.clone().sub(p1).normalize();
|
|
|
|
|
let v2 = p4.clone().sub(p3).normalize();
|
|
|
|
|
let w = p3.clone().sub(p1).normalize();
|
|
|
|
|
|
|
|
|
|
if (equaln(Math.abs(v1.dot(v2)), 1, 1e-6) && (equalv3(w, new Vector3()) || equaln(Math.abs(v1.dot(w)), 1, 1e-6))) //平行共线
|
|
|
|
|
{
|
|
|
|
|
let pts = [p1, p2, p3, p4];
|
|
|
|
|
pts.sort(comparePoint('xyz'));
|
|
|
|
|
pt = midPoint(pts[1], pts[2]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return undefined;
|
|
|
|
|
else if (equaln(Math.abs(v1.dot(v2)), 1, 1e-6)) //平行不共线
|
|
|
|
|
{
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
else if (equaln(getDeterminantFor3V(v1, v2, w), 0, 0.01))
|
|
|
|
|
{
|
|
|
|
|
let t: number;
|
|
|
|
@ -261,9 +252,8 @@ export function IntersectLAndLFor3D(p1: Vector3, p2: Vector3, p3: Vector3, p4: V
|
|
|
|
|
{
|
|
|
|
|
t = (y42 * z43 - y43 * z42) / (y12 * z43 - y43 * z12);
|
|
|
|
|
}
|
|
|
|
|
pt = new Vector3(x12 * t + p2.x, y12 * t + p2.y, z12 * t + p2.z);
|
|
|
|
|
return new Vector3(x12 * t + p2.x, y12 * t + p2.y, z12 * t + p2.z);
|
|
|
|
|
}
|
|
|
|
|
return pt;
|
|
|
|
|
}
|
|
|
|
|
export function IntersectLAndLFor3D1(p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3)
|
|
|
|
|
{
|
|
|
|
|