When transitioning an angle with value > 180 or < 0, using this function to fix the problem.
function properRotation(target_rotation,my_rotation,smooth) { var rot =target_rotation-my_rotation; while (rot<0) { rot += 360; } while (rot>180) { rot -= 360; } my_rotation += rot/smooth; return my_rotation; } |
Thanks the thread from http://www.mail-archive.com/away3d-dev@googlegroups.com/msg02572.html
Case 2:
Simple as using
var diffAngle:Number = Math.atan2(Math.sin(angleTo - currentAngle), Math.cos(angleTo - currentAngle)); |
Example:
var currentAngle: Number = 0; var angleTo: Number = 120 * Math.PI / 180; var diffAngle:Number = Math.atan2(Math.sin(angleTo - currentAngle), Math.cos(angleTo - currentAngle));
diffAngle = Math.round(diffAngle*180 / Math.PI);
trace("diffAngle: " + diffAngle); |
1 comment:
1377.4181.4356.7349.9314.7097
Post a Comment