Esempio n. 1
0
        /// <summary>
        /// Checks whether point is inside rectangle
        /// </summary>
        /// <param name="pnt">Point to check</param>
        /// <returns>True if point at least on a border</returns>
        public bool Includes(crawlPoint3d pnt)
        {
            if (this.MinPoint.X > pnt.X)
            {
                return(false);
            }
            if (this.MinPoint.Y > pnt.Y)
            {
                return(false);
            }
            if (this.MinPoint.Z > pnt.Z)
            {
                return(false);
            }

            if (this.MaxPoint.X < pnt.X)
            {
                return(false);
            }
            if (this.MaxPoint.Y < pnt.Y)
            {
                return(false);
            }
            if (this.MaxPoint.Z < pnt.Z)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a Rectangle from the string of coordinates
        /// </summary>
        /// <param name="stringCoords">string like 'x1;y1;z1;x2;y2;z2'</param>
        public Rectangle(string stringCoords)
        {
            try
            {
                string[] xyz = stringCoords.Split(';');
                if (xyz.Length != 6)
                {
                    Debug.WriteLine("Wrong input in rectangle constructor from string coordinates");
                }

                double x1;
                TryParse(xyz[0], out x1);

                double y1;
                TryParse(xyz[1], out y1);

                double x2;
                TryParse(xyz[3], out x2);

                double y2;
                TryParse(xyz[4], out y2);

                this.pointA = new crawlPoint3d(x1, y1, 0);
                this.pointC = new crawlPoint3d(x2, y2, 0);
            }
            catch
            {
                // Initialization failed
            }
        }
Esempio n. 3
0
        public RectangleIntersection(Rectangle rectangle1, Rectangle rectangle2)
        {
            this.Rectangle1 = rectangle1;
            this.Rectangle2 = rectangle2;

            double minX = Math.Min(this.Rectangle1.MinPoint.X, this.Rectangle2.MinPoint.X);
            double maxX = Math.Max(this.Rectangle1.MaxPoint.X, this.Rectangle2.MaxPoint.X);
            double minY = Math.Min(this.Rectangle1.MinPoint.Y, this.Rectangle2.MinPoint.Y);
            double maxY = Math.Max(this.Rectangle1.MaxPoint.Y, this.Rectangle2.MaxPoint.Y);


            if (this.Rectangle1.MaxPoint.X < this.Rectangle2.MinPoint.X ||
                this.Rectangle2.MaxPoint.X < this.Rectangle1.MinPoint.X ||
                this.Rectangle1.MaxPoint.Y < this.Rectangle2.MinPoint.Y ||
                this.Rectangle2.MaxPoint.Y < this.Rectangle1.MinPoint.Y)
            {
                this.HasIntersection = false;

                this.pointA = new crawlPoint3d(minX, minY, 0);
                this.pointC = new crawlPoint3d(maxX, maxY, 0);

                this.IntersectionArea = this.Area;
            }
            else
            {
                this.pointA = new crawlPoint3d(minX, minY, 0);
                this.pointC = new crawlPoint3d(maxX, maxY, 0);

                this.HasIntersection = true;

                double minXi = Math.Max(this.Rectangle1.MinPoint.X, this.Rectangle2.MinPoint.X);
                double maxXi = Math.Min(this.Rectangle1.MaxPoint.X, this.Rectangle2.MaxPoint.X);
                double minYi = Math.Max(this.Rectangle1.MinPoint.Y, this.Rectangle2.MinPoint.Y);
                double maxYi = Math.Min(this.Rectangle1.MaxPoint.Y, this.Rectangle2.MaxPoint.Y);

                crawlPoint3d intersectionA = new crawlPoint3d(minXi, minYi, 0);
                crawlPoint3d intersectionC = new crawlPoint3d(maxXi, maxYi, 0);
            }
        }
Esempio n. 4
0
 public bool Equals(crawlPoint3d otherPoint3d)
 {
     return(this.ToString().Equals(otherPoint3d.ToString()));
 }
Esempio n. 5
0
 public Rectangle(crawlPoint3d bottomLeftCorner, crawlPoint3d topRightCorner)
 {
     this.pointA = bottomLeftCorner;
     this.pointC = topRightCorner;
 }
Esempio n. 6
0
 public Rectangle(double pointAx, double pointAy, double pointCx, double pointCy)
 {
     this.pointA = new crawlPoint3d(pointAx, pointAy, 0);
     this.pointC = new crawlPoint3d(pointCx, pointCy, 0);
 }