CurveLinearizer { boolean isClockwise( Point p0, Point p1, Point p2 ) throws IllegalArgumentException { if ( areCollinear( p0, p1, p2 ) ) { throw new IllegalArgumentException( "Cannot evaluate isClockwise(). The three points are collinear." ); } double res = ( p2.get0() - p0.get0() ) * ( ( p2.get1() + p0.get1() ) / 2 ) + ( p1.get0() - p2.get0() ) * ( ( p1.get1() + p2.get1() ) / 2 ) + ( p0.get0() - p1.get0() ) * ( ( p0.get1() + p1.get1() ) / 2 ); return res < 0.0 ? true : false; } CurveLinearizer( GeometryFactory geomFac ); Curve linearize( Curve curve, LinearizationCriterion crit ); LineStringSegment linearize( CurveSegment segment, LinearizationCriterion crit ); LineStringSegment linearizeArc( Arc arc, LinearizationCriterion crit ); LineStringSegment linearizeArcString( ArcString arcString, LinearizationCriterion crit ); LineStringSegment linearizeCubicSpline( CubicSpline spline, LinearizationCriterion crit ); static boolean areCollinear( Point p0, Point p1, Point p2 );  }
@Test public void testIsClockwise() { Point p0 = geomFac.createPoint( null, new double[] { -2, 0 }, null ); Point p1 = geomFac.createPoint( null, new double[] { 0, 2 }, null ); Point p2 = geomFac.createPoint( null, new double[] { 2, 0 }, null ); Assert.assertTrue( linearizer.isClockwise( p0, p1, p2 ) ); Assert.assertFalse( linearizer.isClockwise( p0, p2, p1 ) ); p0 = geomFac.createPoint( null, new double[] { -2, 0 }, null ); p1 = geomFac.createPoint( null, new double[] { 0, -2 }, null ); p2 = geomFac.createPoint( null, new double[] { 2, 0 }, null ); Assert.assertFalse( linearizer.isClockwise( p0, p1, p2 ) ); }