Answer the question
In order to leave comments, you need to log in
How to find the nearest object if you only know its degrees?
I have a circle and two objects.
On click, I need to determine the nearest object using their degrees. I wrote something like:
Math.abs(A_deg - click_deg) > Math.abs(B_deg - click_deg) ? B_deg : A_deg
Answer the question
In order to leave comments, you need to log in
var diff = Math.min(Math.abs(x - y), 360 - Math.abs(x - y));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question