Beispiel #1
0
        public static Extents3d Offset(this Extents3d ext, double percent = 50)
        {
            var dX = ext.GetLength() * (percent / 100) * 0.5;
            var dY = ext.GetHeight() * (percent / 100) * 0.5;

            return(new Extents3d(
                       new Point3d(ext.MinPoint.X - dX, ext.MinPoint.Y - dY, 0),
                       new Point3d(ext.MaxPoint.X + dX, ext.MaxPoint.Y + dY, 0)
                       ));
        }
Beispiel #2
0
        public static List <Point3d> GetRegularGridPoints(this Extents3d ext, double len)
        {
            var ptsGrid = new List <Point3d>();
            var extL    = ext.GetLength();
            var extH    = ext.GetHeight();
            var iX      = (int)(extL / len) + 1;
            var iY      = (int)(extH / len) + 1;
            var dX      = extL / iX;
            var dY      = extH / iY;

            for (var x = 0; x < iX; x++)
            {
                for (var y = 0; y < iY; y++)
                {
                    ptsGrid.Add(new Point3d(ext.MinPoint.X + len * 0.5 + x * dX, ext.MinPoint.Y + len * 0.5 + y * dY, 0));
                }
            }

            return(ptsGrid);
        }
Beispiel #3
0
        public static Line GetExtentLine(Extents3d ext, bool isWindow)
        {
            var      diag = ext.MaxPoint - ext.MinPoint;
            Vector3d vec;

            if (ext.GetLength() > ext.GetHeight())
            {
                vec = diag.OrthoProjectTo(Vector3d.XAxis) * 0.5;
            }
            else
            {
                vec = diag.OrthoProjectTo(Vector3d.YAxis) * 0.5;
            }
            var startPt = ext.MinPoint + vec;
            var endPt   = ext.MaxPoint - vec;

            if (isWindow)
            {
                var dir = (endPt - startPt).GetNormal();
                return(new Line(startPt + dir * 25, endPt - dir * 25));
            }
            return(new Line(startPt, endPt));
        }