private Plane get2DPlane(IEnumerable<Vector3D> vectors, Plane plane)
        {
            Vector3D center = plane.Center;
            Vector3D start = vectors.Select(plane.Projection).
                Aggregate(center, (v1,v2) =>
                    D3Util.Distance(center,v1) > D3Util.Distance(center,v2)?v1:v2);

            Vector3D normal = start - center;
            return new Plane(normal, start);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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);
        }
        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);
        }