lixiaojun
2024-09-25 21c97aab9153758bebfc9b3944859b0eec271c76
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);
        }
    }
}