Answer the question
In order to leave comments, you need to log in
How to rotate an object around a circle without "reversing"?
Hello everyone, tell me how to correctly rotate an object around a circle without a "turn", if it is from 0 to 360 clockwise, for example, the object is rotated by 10 degrees and you need to rotate it by 340, but along a "small" path, i.e. how jump from 0 to 360 if you use JS JS for this?
Answer the question
In order to leave comments, you need to log in
const dir = (aFrom, aTo) => (aTo - aFrom + 360) % 360 > 180 ? 'ccw' : 'cw';
// "ccw" – против часовой,
// "cw" – по часовой
dir(30, 60) // "cw" – из 30° в 60° лучше по часовой стрелке топать
dir(30, 330) // "ccw" – против часовой короче )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question