class LineStringCursor {

    public double getMaxAngleChange(double startOrdinate, double endOrdinate) {
        if (startOrdinate > endOrdinate)
            throw new IllegalArgumentException("Invalid arguments, endOrdinate < starOrdinate");

        // compute the begin and end segments
        LineStringCursor delegate = new LineStringCursor(this);
        delegate.moveTo(startOrdinate);
        int startSegment = delegate.segment;
        delegate.moveTo(endOrdinate);
        int endSegment = delegate.segment;

        // everything inside the same segment
        if (startSegment == endSegment)
            return 0;

        double maxDifference = 0;
        double prevAngle = getSegmentAngle(startSegment);
        for (int i = startSegment + 1; i <= endSegment; i++) {
            double currAngle = getSegmentAngle(i);
            double difference = currAngle - prevAngle;
            // normalize angle, the difference can become 2 * PI 
            if(difference > Math.PI) {
                difference -= 2 * Math.PI;
            } else if(difference < -Math.PI) {
                difference += 2 * Math.PI;
            }
            difference = Math.abs(difference);
            if (difference > maxDifference)
                maxDifference = difference;
            prevAngle = currAngle;
        }

        return maxDifference;
    }

    public  LineStringCursor(LineString ls);
    public  LineStringCursor(LineStringCursor cursor);

}