private Coordinate averagePoint ( CoordinateSequence seq ) { Coordinate a = new Coordinate ( 0 , 0 , 0 ) ; int n = seq . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a . x += seq . getOrdinate ( i , CoordinateSequence . X ) ; a . y += seq . getOrdinate ( i , CoordinateSequence . Y ) ; a . z += seq . getOrdinate ( i , CoordinateSequence . Z ) ; } a . x /= n ; a . y /= n ; a . z /= n ; return a ; }
Computes a point which is the average of all coordinates in a sequence . If the sequence lies in a single plane , the computed point also lies in the plane .