需在NuGet中安装NetTopologySuite,版本>=2.3。
csharp
var pt1 = new Point(0, 0, 0);
var pt2 = new Point(1, 0, 0);
var pt3 = new Point(1, 1, 0);
var v1 = new Vector3D(pt2.X - pt1.X, pt2.Y - pt2.Y, pt2.Z - pt1.Z);
var v2 = new Vector3D(pt3.X - pt1.X, pt3.Y - pt2.Y, pt3.Z - pt1.Z);
var normal = v1.Cross(v2).Normalize();
Console.WriteLine($"{normal.X} {normal.Y} {normal.Z}"); // 0 0 1