How could I find the shortest distance between two angles? Like say the distance between 359 degrees and 1 degree is 2 not 358. Any ideas?
if(angleone - angletwo <= 180){
shortestDistance = angleone - angletwo;
} else {
shortestDistance = (angletwo+360) - angleone;
}
sweet thanx alot
ok that dosen’t seem to work so good. I have it so its springing to a certain angle and sometimes it just goes nuts. When I get about 280 degrees.
[AS]
function getShortAngle(a1, a2)
{
var angle = (Math.abs(a1 - a2))%360;
if(angle > 180)
angle = 360 - angle;
return angle;
};
trace(getShortAngle(360, 720));
[/AS]