From 12a6316ffa897b4ce4205f545b88359195b386d6 Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期三, 25 九月 2024 17:34:24 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0 --- WinFrmUI/Yw.WinFrmUI.Hydro.L3d.Core/00-core/Point3d.cs | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 59 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 cecee15..7c8f60f 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.L3d.Core/00-core/Point3d.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.L3d.Core/00-core/Point3d.cs @@ -102,5 +102,64 @@ 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