public List <Trapezoid> FollowEdge(Edge edge) { List <Trapezoid> trapezoids = new List <Trapezoid>(); trapezoids.Add(Locate(edge)); int j = 0; while (edge.Q.X > trapezoids[j].RightPoint.X) { if (edge.IsAbove(trapezoids[j].RightPoint)) { trapezoids.Add(trapezoids[j].UpperRight); } else { trapezoids.Add(trapezoids[j].LowerRight); } j += 1; } return(trapezoids); }
public override Sink Locate(Edge edge) { if (_edge.IsAbove(edge.P)) { // Move down the graph return(RightChild.Locate(edge)); } if (_edge.IsBelow(edge.P)) { // Move up the graph return(LeftChild.Locate(edge)); } // s and segment share the same endpoint, p if (edge.Slope < _edge.Slope) { // Move down the graph return(RightChild.Locate(edge)); } // Move up the graph return(LeftChild.Locate(edge)); }
// Determines if this point lies inside the trapezoid public bool Contains(Point point) { return(point.X > LeftPoint.X && point.X < RightPoint.X && Top.IsAbove(point) && Bottom.IsBelow(point)); }