public void normalize ( ) { double angle = this . getAngle ( ) ; if ( Utils . within ( angle , 0 , 1 ) || Utils . within ( angle , 180 , 1 ) ) { // almost horizontal this . setLine ( this . x1 , this . y1 , this . x2 , this . y1 ) ; } else if ( Utils . within ( angle , 90 , 1 ) || Utils . within ( angle , 270 , 1 ) ) { // almost vertical this . setLine ( this . x1 , this . y1 , this . x1 , this . y2 ) ; } // else { // System.out.println("oblique: " + this + " ("+ this.getAngle() + ")"); // } }
Normalize almost horizontal or almost vertical lines