private Coordinate displaceFromSeg(LineSegment nearSeg, double dist) { double frac = nearSeg.projectionFactor(vertexPt); // displace away from the segment on the same side as the original point int side = nearSeg.orientationIndex(vertexPt); if (side == Orientation.RIGHT) dist = -dist; return nearSeg.pointAlongOffset(frac, dist); }
int orientIndex = upwardSeg.orientationIndex(other.upwardSeg); if (orientIndex != 0) return orientIndex; orientIndex = -1 * other.upwardSeg.orientationIndex(upwardSeg); if (orientIndex != 0) return orientIndex;
void checkOrientationIndex(LineSegment seg, double px, double py, int expectedOrient) { Coordinate p = new Coordinate(px, py); int orient = seg.orientationIndex(p); assertTrue(orient == expectedOrient); }
void checkOrientationIndex(LineSegment seg, double s0x, double s0y, double s1x, double s1y, int expectedOrient) { LineSegment seg2 = new LineSegment(s0x, s0y, s1x, s1y); int orient = seg.orientationIndex(seg2); assertTrue(orient == expectedOrient); }
/** * Defines a comparison operation on DepthSegments * which orders them left to right * * <pre> * DS1 < DS2 if DS1.seg is left of DS2.seg * DS1 > DS2 if DS1.seg is right of DS2.seg * </pre> * * @param obj * @return the comparison value */ public int compareTo(Object obj) { DepthSegment other = (DepthSegment) obj; if (! envelopesOverlap(upwardSeg, other.upwardSeg)) return upwardSeg.compareTo(other.upwardSeg); // check orientations int orientIndex = upwardSeg.orientationIndex(other.upwardSeg); if (orientIndex != 0) return orientIndex; orientIndex = - other.upwardSeg.orientationIndex(upwardSeg); if (orientIndex != 0) return orientIndex; // segments cross or are collinear. Use segment ordering return upwardSeg.compareTo(other.upwardSeg); }
int orientIndex = upwardSeg.orientationIndex(other.upwardSeg); orientIndex = -1 * other.upwardSeg.orientationIndex(upwardSeg);