public static Extent GetExtents(IList<Vector3D> vectors, Plane plane) { if(vectors == null || vectors.Count == 0) throw new ArgumentException("Vector list cannot be empty or null"); double min = Double.MaxValue; double max = Double.MinValue; Vector3D minPoint = new Vector3D(); Vector3D maxPoint = new Vector3D(); foreach (Vector3D vector in vectors) { double planeDist = plane.Distance(vector); if (min > planeDist) { min = planeDist; } if (max < planeDist) { max = planeDist; } } return new Extent(min,minPoint, max, maxPoint); }
public static Boolean Is3D(IList<Vector3D> vectors, Plane plane) { double maxR = vectors.Max(v => Distance(plane.Projection(v), plane.Center)); double maxZ = vectors.Max(v => plane.Distance(v)); return maxR < maxZ*4; }
private Plane get3DPlane(IEnumerable<Vector3D> vectors, Vector3D center) { Vector3D planeAngle = new Vector3D(Rand.NextDouble(), Rand.NextDouble(), Rand.NextDouble()); planeAngle.Normalize(); Plane newPlane = new Plane(planeAngle, center); Vector3D firstPoint = vectors.Aggregate(center, (v1, v2) => newPlane.Distance(v1) < newPlane.Distance(v2) ? v1 : v2); return newPlane.WithPoint(firstPoint); }