fixed atan calculation