calculate extreme points