diff --git a/__test__/Geometry/__snapshots__/intersect.test.ts.snap b/__test__/Geometry/__snapshots__/intersect.test.ts.snap index c622cfc8c..4674cea9c 100644 --- a/__test__/Geometry/__snapshots__/intersect.test.ts.snap +++ b/__test__/Geometry/__snapshots__/intersect.test.ts.snap @@ -1,127 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`三维空间圆圆相交测试 1`] = ` -Array [ - Vector3 { - "x": 3.8465654731285666, - "y": -0.48984005103149847, - "z": 0.3777515851723183, - }, - Vector3 { - "x": 4.518686772594938, - "y": -2.26435797895917, - "z": -0.09066385360916496, - }, -] -`; - -exports[`三维空间圆圆相交测试 2`] = ` -Array [ - Vector3 { - "x": 1.25, - "y": -4.841229182759271, - "z": 0, - }, - Vector3 { - "x": 1.25, - "y": 4.841229182759271, - "z": 0, - }, -] -`; - -exports[`三维空间圆圆相交测试 3`] = ` -Array [ - Vector3 { - "x": 1.25, - "y": 0, - "z": -4.841229182759271, - }, - Vector3 { - "x": 1.25, - "y": 0, - "z": 4.841229182759271, - }, -] -`; - -exports[`三维空间圆圆相交测试 4`] = ` -Array [ - Vector3 { - "x": 0, - "y": -11.313088368701884, - "z": -9.556275638274851, - }, - Vector3 { - "x": 0, - "y": -9.579281670837858, - "z": -2.8986776905615708, - }, -] -`; - -exports[`三维空间圆圆相交测试 5`] = `Array []`; - -exports[`三维空间直线和圆相交测试 1`] = ` -Array [ - Vector3 { - "x": 7.265045456946406, - "y": 0, - "z": 1.5147084845720027, - }, - Vector3 { - "x": 3.9357458826357803, - "y": 0, - "z": 4.789429377336553, - }, -] -`; - -exports[`三维空间直线和圆相交测试 2`] = ` -Array [ - Vector3 { - "x": -3.622627029705465, - "y": -3.4462404738565997, - "z": 0, - }, - Vector3 { - "x": -3.622627029705464, - "y": 3.446240473856601, - "z": 0, - }, -] -`; - -exports[`三维空间直线和圆相交测试 3`] = ` -Array [ - Vector3 { - "x": 9.796270630192112, - "y": -13.16305455920182, - "z": 4.841809080303142, - }, - Vector3 { - "x": 9.796270630192113, - "y": -6.270573611488619, - "z": 4.841809080303142, - }, -] -`; - -exports[`三维空间直线和圆相交测试 4`] = ` -Array [ - Vector3 { - "x": 12.384261138056765, - "y": -13.16305455920182, - "z": 6.346016491847222, - }, - Vector3 { - "x": 12.384261138056765, - "y": -6.27057361148862, - "z": 6.346016491847221, - }, -] -`; - exports[`三维空间直线相交测试 1`] = ` Vector3 { "x": 5, @@ -130,13 +8,7 @@ Vector3 { } `; -exports[`三维空间直线相交测试 2`] = ` -Vector3 { - "x": 4.5, - "y": 4.5, - "z": 4.5, -} -`; +exports[`三维空间直线相交测试 2`] = `undefined`; exports[`三维空间直线相交测试 3`] = ` Vector3 { @@ -145,37 +17,3 @@ Vector3 { "z": 5, } `; - -exports[`直线和圆相切 1`] = ` -Array [ - Vector3 { - "x": 34450.21257120082, - "y": 3606.7814824644443, - "z": 0, - }, -] -`; - -exports[`相交测试 1`] = ` -Vector3 { - "x": 0.5, - "y": 0, - "z": 0, -} -`; - -exports[`相交测试 2`] = ` -Vector3 { - "x": 2, - "y": 0, - "z": 0, -} -`; - -exports[`相交测试 3`] = ` -Vector3 { - "x": 0.5, - "y": 5, - "z": 0, -} -`; diff --git a/__test__/Interest/line.test.ts b/__test__/Interest/line.test.ts index 675393289..0d4799afb 100644 --- a/__test__/Interest/line.test.ts +++ b/__test__/Interest/line.test.ts @@ -20,7 +20,7 @@ test('直线相交,共线', () => expect(pts.length).toBe(0); pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendBoth);//? - expect(pts.length).toBe(1); + expect(pts.length).toBe(0); }); diff --git a/src/GraphicsSystem/IntersectWith.ts b/src/GraphicsSystem/IntersectWith.ts index 0418a17d2..f3d24019d 100644 --- a/src/GraphicsSystem/IntersectWith.ts +++ b/src/GraphicsSystem/IntersectWith.ts @@ -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) {