diff --git a/src/IFoxCAD.Cad/ExtensionMethod/GeometryEx.cs b/src/IFoxCAD.Cad/ExtensionMethod/GeometryEx.cs
index 84b57f7d19dabd27ce64af2a8329fa176dec7526..2c1a45a3a57bcbf88afbb63f19c10c229f21f43c 100644
--- a/src/IFoxCAD.Cad/ExtensionMethod/GeometryEx.cs
+++ b/src/IFoxCAD.Cad/ExtensionMethod/GeometryEx.cs
@@ -1,4 +1,4 @@
-namespace IFoxCAD.Cad;
+namespace IFoxCAD.Cad;
using System.Drawing;
using IFoxCAD.Basal;
@@ -608,6 +608,16 @@ public static Point3d Point3d(this Point2d pt)
{
return new Point3d(pt.X, pt.Y, 0);
}
+ ///
+ /// 将二维点转换为三维点
+ ///
+ /// 二维点
+ /// Z值
+ /// 三维点
+ public static Point3d Point3d(this Point2d pt,double z)
+ {
+ return new Point3d(pt.X, pt.Y, z);
+ }
///
/// 获取两个点之间的中点
@@ -646,4 +656,16 @@ public static Point3d Polar(this Point3d pt, double ang, double len)
{
return pt + Vector3d.XAxis.RotateBy(ang, Vector3d.ZAxis) * len;
}
+ ///
+ /// 计算指定距离和角度的点
+ ///
+ /// 本函数仅适用于x-y平面
+ /// 基点
+ /// 角度,x轴正向逆时针弧度
+ /// 距离
+ /// 目标点
+ public static Point2d Polar(this Point2d pt, double ang, double len)
+ {
+ return pt + Vector2d.XAxis.RotateBy(ang) * len;
+ }
}
diff --git a/src/IFoxCAD.Cad/ExtensionMethod/PointEx.cs b/src/IFoxCAD.Cad/ExtensionMethod/PointEx.cs
index b7010b52eef42271acaeddd18b3f0b262c438037..c534be66a5897f288dc64ff8b86692fac4844813 100644
--- a/src/IFoxCAD.Cad/ExtensionMethod/PointEx.cs
+++ b/src/IFoxCAD.Cad/ExtensionMethod/PointEx.cs
@@ -1,4 +1,4 @@
-namespace IFoxCAD.Cad;
+namespace IFoxCAD.Cad;
public static class PointEx
{
@@ -20,6 +20,27 @@ public static string GetHashString(this Point3d pt, int xyz = 3, int decimalReta
_ => $"({pt.X.ToString(de)},{pt.Y.ToString(de)},{pt.Z.ToString(de)})"
};
}
+ ///
+ /// 两点计算弧度范围0到2Pi
+ ///
+ /// 起点
+ /// 终点
+ /// 方向
+ /// 弧度值
+ public static double GetAngle(this Point3d startPoint, Point3d endPoint, Vector3d? direction = null)
+ {
+ return startPoint.GetVectorTo(endPoint).AngleOnPlane(new Plane(Point3d.Origin, direction ?? Vector3d.ZAxis));
+ }
+ ///
+ /// 两点计算弧度范围0到2Pi
+ ///
+ /// 起点
+ /// 终点
+ /// 弧度值
+ public static double GetAngle(this Point2d startPoint, Point2d endPoint)
+ {
+ return startPoint.GetVectorTo(endPoint).Angle;
+ }
}
\ No newline at end of file