From ad8f813f5eddd66740b4e09801e4ea02ddf70a4a Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期三, 19 二月 2025 15:58:22 +0800 Subject: [PATCH] 继续优化报表 --- WinFrmUI/Yw.WinFrmUI.Hydro.L3d.Core/00-core/Point3d.cs | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 88 insertions(+), 0 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.L3d.Core/00-core/Point3d.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.L3d.Core/00-core/Point3d.cs index 1b3b383..7c8f60f 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.L3d.Core/00-core/Point3d.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.L3d.Core/00-core/Point3d.cs @@ -3,6 +3,7 @@ /// <summary> /// /// </summary> + [TypeConverter(typeof(PropertySorter))] public class Point3d { /// <summary> @@ -31,18 +32,34 @@ } /// <summary> + /// + /// </summary> + public Point3d(Point3d rhs) + { + this.X = rhs.X; + this.Y = rhs.Y; + this.Z = rhs.Z; + } + + /// <summary> /// x /// </summary> + [DisplayName("X")] + [PropertyOrder(1)] public float X { get; set; } /// <summary> /// y /// </summary> + [DisplayName("Y")] + [PropertyOrder(2)] public float Y { get; set; } /// <summary> /// z /// </summary> + [DisplayName("Z")] + [PropertyOrder(3)] public float Z { get; set; } /// <summary> @@ -73,5 +90,76 @@ return !InValid(); } + /// <summary> + /// 璺濈 + /// </summary> + public float Distance(Point3d other) + { + if (other == null) + { + return default; + } + return MathF.Sqrt(MathF.Pow(this.X - other.X, 2) + MathF.Pow(this.Y - other.Y, 2) + MathF.Pow(this.Z - other.Z, 2)); + } + + /// <summary> + /// + /// </summary> + public float LengthSquared() + { + return X * X + Y * Y + Z * Z; + } + + /// <summary> + /// + /// </summary> + public float Length() + { + return (float)Math.Sqrt(LengthSquared()); + } + + /// <summary> + /// + /// </summary> + public void Normalize() + { + float length = Length(); + if (length > 0) + { + X /= length; + Y /= length; + Z /= length; + } + } + + /// <summary> + /// - 杩愮畻 + /// </summary> + public static Point3d operator -(Point3d a, Point3d b) + { + return new Point3d(a.X - b.X, a.Y - b.Y, a.Z - b.Z); + } + + + /// <summary> + /// + /// </summary> + public static float DotProduct(Point3d a, Point3d b) + { + return a.X * b.X + a.Y * b.Y + a.Z * b.Z; + } + + /// <summary> + /// + /// </summary> + public static Point3d CrossProduct(Point3d a, Point3d b) + { + return new Point3d( + a.Y * b.Z - a.Z * b.Y, + a.Z * b.X - a.X * b.Z, + a.X * b.Y - a.Y * b.X); + } + + } } -- Gitblit v1.9.3