the bug of non-ending rotation of middle menu was found. i was because of the negetive coordinate of angle.corrected by making all angles positive(adding 360 before taking modulus)