public static int OrientationIndex(Coordinate p1, Coordinate p2, Coordinate q) { // travelling along p1->p2, turn counter clockwise to get to q return 1, // travelling along p1->p2, turn clockwise to get to q return -1, // p1, p2 and q are colinear return 0. double dx1 = p2.X - p1.X; double dy1 = p2.Y - p1.Y; double dx2 = q.X - p2.X; double dy2 = q.Y - p2.Y; return(RobustDeterminant.SignOfDet2x2(dx1, dy1, dx2, dy2)); } // public static int OrientationIndex(Coordinate p1, Coordinate p2, Coordinate q)
private void TestLineSegment(Coordinate p, LineSegment seg) { double xInt; // x intersection of segment with ray double x1; // translated coordinates double y1; double x2; double y2; // // Test if segment crosses ray from test point in positive x direction. // Coordinate p1 = seg.P0; Coordinate p2 = seg.P1; x1 = p1.X - p.X; y1 = p1.Y - p.Y; x2 = p2.X - p.X; y2 = p2.Y - p.Y; if (((y1 > 0) && (y2 <= 0)) || ((y2 > 0) && (y1 <= 0))) { // // segment straddles x axis, so compute intersection. // xInt = RobustDeterminant.SignOfDet2x2(x1, y1, x2, y2) / (y2 - y1); //xsave = xInt; // // crosses ray if strictly positive intersection. // if (0.0 < xInt) { _crossings++; } } }