예제 #1
0
파일: RegionMath.cs 프로젝트: wshanshan/DDD
        public double SlopeTo(GeometricPointType p)
        {
            if (this.x == p.X)
            {
                throw new ApplicationException("Cannot compute vertical slope from "
                    + "(" + this.x.ToString() + this.y.ToString() + ") to "
                    + "(" + p.X.ToString() + p.Y.ToString() + ") in GeometricGeometricPointType.SlopeTo");
            }

            return (p.Y - this.y) / (p.X - this.x);
        }
예제 #2
0
        public double SlopeTo(GeometricPointType p)
        {
            if (this.x == p.X)
            {
                throw new ApplicationException("Cannot compute vertical slope from "
                                               + "(" + this.x.ToString() + this.y.ToString() + ") to "
                                               + "(" + p.X.ToString() + p.Y.ToString() + ") in GeometricGeometricPointType.SlopeTo");
            }

            return((p.Y - this.y) / (p.X - this.x));
        }
예제 #3
0
        /// <summary>
        /// Removes the middle of three collinear points from a polygon
        /// </summary>
        /// <param name="inLine">List of points</param>
        /// <returns>reduced list of points</returns>
        public static List <GeometricPointType> RemoveCollinear(List <GeometricPointType> inLine)
        {
            List <GeometricPointType> outLine = new List <GeometricPointType>();
            int N = inLine.Count;

            outLine.Add(inLine[0]);
            int nextPoint = 1;
            int first     = 0; // represents the first of three successive points

            while (nextPoint < N)
            {
                GeometricPointType start    = inLine[first];
                GeometricPointType middle   = inLine[(nextPoint) % N];
                GeometricPointType endpoint = inLine[(nextPoint + 1) % N];
                if ((middle.X == endpoint.X) && (middle.X == start.X))
                {
                    /* do nothing*/
                    ;
                }
                else if (middle.X == endpoint.X || middle.X == start.X)
                {
                    if (N != nextPoint)
                    {
                        outLine.Add(inLine[nextPoint]);
                        first = nextPoint;
                    }
                }
                else if (middle.SlopeTo(start) == middle.SlopeTo(endpoint))
                {
                    /* do nothing*/
                    ;
                }

                else
                {
                    if (N != nextPoint)
                    {
                        outLine.Add(inLine[nextPoint]);
                        first = nextPoint;
                    }
                }

                nextPoint = nextPoint + 1;
            }//end while
            return(outLine);
        }
예제 #4
0
 public PointType(GeometricPointType g)
 {
     this.x = g.X;
     this.y = g.Y;
 }