public boolean checkFlip ( SquareGrid grid ) { if ( grid . columns == 1 || grid . rows == 1 ) return false ; Point2D_F64 a = grid . get ( 0 , 0 ) . center ; Point2D_F64 b = grid . get ( 0 , grid . columns - 1 ) . center ; Point2D_F64 c = grid . get ( grid . rows - 1 , 0 ) . center ; double x0 = b . x - a . x ; double y0 = b . y - a . y ; double x1 = c . x - a . x ; double y1 = c . y - a . y ; double z = x0 * y1 - y0 * x1 ; return z < 0 ; }
Checks to see if it needs to be flipped . Flipping is required if X and Y axis in 2D grid are not CCW .