Exemple #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Rectangle2d" /> class from a polyline.
        /// </summary>
        /// <param name="polyline">Polyline.</param>
        public Rectangle2d(Polyline2d polyline)
        {
            var xMin = polyline.Vertices[0].X;
            var yMin = polyline.Vertices[0].Y;
            var xMax = polyline.Vertices[0].X;
            var yMax = polyline.Vertices[0].Y;

            polyline.Vertices.ForEach(
                vertex =>
            {
                if (vertex.X < xMin)
                {
                    xMin = vertex.X;
                }
                if (vertex.X > xMax)
                {
                    xMax = vertex.X;
                }

                if (vertex.Y < yMin)
                {
                    yMin = vertex.Y;
                }
                if (vertex.X > yMax)
                {
                    yMax = vertex.Y;
                }
            });

            this.XDomain = new Interval(xMin, xMax);
            this.YDomain = new Interval(yMin, yMax);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BoundingBox2d"/> class from a polyline.
        /// </summary>
        /// <param name="polyline">Polyline.</param>
        public BoundingBox2d(Polyline2d polyline)
        {
            double xMin = polyline.Vertices[0].X;
            double yMin = polyline.Vertices[0].Y;
            double xMax = polyline.Vertices[0].X;
            double yMax = polyline.Vertices[0].Y;

            polyline.Vertices.ForEach(vertex =>
            {
                if (vertex.X < xMin)
                {
                    xMin = vertex.X;
                }
                if (vertex.X > xMax)
                {
                    xMax = vertex.X;
                }

                if (vertex.Y < yMin)
                {
                    yMin = vertex.Y;
                }
                if (vertex.X > yMax)
                {
                    yMax = vertex.Y;
                }
            });

            this.XDomain = new Interval(xMin, xMax);
            this.YDomain = new Interval(yMin, yMax);
        }