Vector3 point1 = new Vector3(0, 0, 0); // 3D point, z-coordinate is not used Vector3 point2 = new Vector3(5, 5, 0); float distance = Vector3.Distance2D(point1, point2);
Vector3[] points = new Vector3[] { new Vector3(0, 0, 0), new Vector3(5, 5, 0), new Vector3(10, 10, 0) }; for (int i = 0; i < (points.Length - 1); i++) { float distance = Vector3.Distance2D(points[i], points[i + 1]); Console.WriteLine("Distance between points " + i + " and " + (i+1) + ": " + distance); }In this example, we have an array of three Vector3 points that represent three points on a 2D plane. We then iterate through the array and calculate the distance between each consecutive pair of points using Distance2D. The console output will display the distance between each pair of points. The System Vector3 class is included in the .NET Standard library and is part of the System.Numerics namespace.