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); }
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)); }
/// <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); }
public PointType(GeometricPointType g) { this.x = g.X; this.y = g.Y; }