public static Dictionary <float, List <SlicedPlane> > DoLinearSlice(Facet[] facets, LinearArrayDefine define)
        {
            var result = new List <SlicedPlane>();

            var factory = new LinearArrayCreater();
            var planes  = factory.CreateArrayPlane(define);

            foreach (var p in planes)
            {
                var planeInfo = p as LinearSlicePlaneInfo;
                var sp        = new SlicedPlane(planeInfo);

                result.Add(sp);

                foreach (var f in facets)
                {
                    var segs = GetPlaneCross(f, planeInfo.Plane);
                    if (segs.Count > 0)
                    {
                        sp.Lines.AddRange(segs);
                    }
                }
            }

            return(result.OrderBy(m => m.D).GroupBy(m => m.D).ToDictionary(m => m.Key, n => n.ToList()));
        }
        public static Dictionary <LinearArrayDefine, List <SlicedPlane> > DoLinearSlice(Facet[] facets, LinearArrayDefine[] defines)
        {
            var results = new Dictionary <LinearArrayDefine, List <SlicedPlane> >();

            foreach (var define in defines)
            {
                var result = new List <SlicedPlane>();

                var factory = new LinearArrayCreater();
                var planes  = factory.CreateArrayPlane(define);

                foreach (var p in planes)
                {
                    var planeInfo = p as LinearSlicePlaneInfo;
                    var sp        = new SlicedPlane(planeInfo);

                    result.Add(sp);

                    foreach (var f in facets)
                    {
                        var segs = GetPlaneCross(f, planeInfo.Plane);
                        if (segs.Count > 0)
                        {
                            sp.Lines.AddRange(segs);
                        }
                    }
                }

                results.Add(define, result);
            }

            return(results);
        }
        public static Vector2 To2D(SlicedPlane sp, Vector3 p)
        {
            var info = sp.SlicePlane as CircleSlicePlaneInfo;

            var PO = new Vector3(0, 0, 0);

            if (info.Plane.D != 0)
            {
                PO = info.Plane.Normal * info.Plane.D;
            }

            var n = Vector3.Cross(info.Axis, info.Plane.Normal);

            Vector3 vectorX = new Vector3(info.Axis.X, 0, 0);
            Vector3 vectorY = new Vector3(0, info.Axis.Y, 0); // plane.Normal;
            Vector3 vectorZ = new Vector3(0, 0, info.Axis.Z);

            var q = new Matrix4x4()
            {
                M11 = vectorX.X,
                M12 = vectorY.X,
                M13 = vectorZ.X,
                M14 = PO.X,
                M21 = vectorX.Y,
                M22 = vectorY.Y,
                M23 = vectorZ.Y,
                M24 = PO.Y,
                M31 = vectorX.Z,
                M32 = vectorY.Z,
                M33 = vectorZ.Z,
                M34 = PO.Z,
                M41 = 0,
                M42 = 0,
                M43 = 0,
                M44 = 1
            };

            var qq = Quaternion.CreateFromRotationMatrix(q);

            var np = Vector3.Transform(p, qq);

            return(new Vector2(np.X, np.Z));
        }