Added x and y translation, changed abs() to fabs()