From e73c31ebd6c2a1cc3fe61d8b538b138b66ee4f11 Mon Sep 17 00:00:00 2001 From: wang2006zhi <5432325+wang2006zhi@user.noreply.gitee.com> Date: Mon, 20 Jun 2022 04:20:34 +0000 Subject: [PATCH] =?UTF-8?q?update=20src/IFoxCAD.Cad/ExtensionMethod/Curve3?= =?UTF-8?q?dEx.cs.=20=E6=B7=BB=E5=8A=A0=E7=82=B9=E4=B8=8E=E7=9B=B4?= =?UTF-8?q?=E7=BA=BF=E5=85=B3=E7=B3=BB=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/IFoxCAD.Cad/ExtensionMethod/Curve3dEx.cs | 43 +++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/IFoxCAD.Cad/ExtensionMethod/Curve3dEx.cs b/src/IFoxCAD.Cad/ExtensionMethod/Curve3dEx.cs index 226e5de..870fdbd 100644 --- a/src/IFoxCAD.Cad/ExtensionMethod/Curve3dEx.cs +++ b/src/IFoxCAD.Cad/ExtensionMethod/Curve3dEx.cs @@ -1,4 +1,4 @@ -namespace IFoxCAD.Cad; +namespace IFoxCAD.Cad; /// /// 三维解析类曲线转换为三维实体曲线扩展类 @@ -16,7 +16,46 @@ public static bool IsEqualPoint(this Tolerance tol, double d1, double d2) { return Math.Abs(d1 - d2) < tol.EqualPoint; } - + /// + /// 判断点与另外两点的位置关系 + /// + /// + /// + /// + /// + /// + /// + public static PtOnlineType IsOnLine(this Point3d pt0, Point3d pt1, Point3d pt2, double dTol) + { + var value = PtOnlineType.OutLineP12; + double d12 = Math.Abs(pt1.DistanceTo(pt2)); + double d01 = Math.Abs(pt0.DistanceTo(pt1)); + double d02 = Math.Abs(pt0.DistanceTo(pt2)); + if (d12 == d01+d02) value = 0; + if (d02 == d01+d12) + { + if (d01 <= dTol) + { + value = PtOnlineType.OnLineP1N; + } + else + { + value = PtOnlineType.OnLineP1W; + } + } + if (d01 == d02+d12) + { + if (d02 <= dTol) + { + value = PtOnlineType.OnLineP2N; + } + else + { + value = PtOnlineType.OnLineP2W; + } + } + return value; + } #region Curve3d /// -- Gitee