Changed tangent calculation

Math.atan() is the appropriate method
Math.atan2() calculates the angle in a different coordinate system.