Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Angle smoothAngle(Angle from, Angle to, float xsmooth, float ysmooth)
- {
- Angle delta = clampAngles(new Angle(from.x - to.x, from.y - to.y));
- delta.x *= xsmooth;
- delta.y *= ysmooth;
- return clampAngles(from.minus(delta));
- }
- public static double normalizeAngle(double angle)
- {
- return (angle % 360.0D + 360.0D) % 360.0D;
- }
- public Angle normalizeAngle(Angle a)
- {
- if (a.x > 180.0F) {
- a.x -= 360.0F;
- }
- if (a.x < -180.0F) {
- a.x += 360.0F;
- }
- if (a.y > 180.0F) {
- a.y -= 360.0F;
- }
- if (a.y < -180.0F) {
- a.y += 360.0F;
- }
- return a;
- }
- public Angle clampAngles(Angle AngleToNormalize)
- {
- Angle vec = AngleToNormalize;
- if ((vec.x() > 89.0F) && (vec.x() <= 180.0F)) {
- vec.setX(89.0F);
- }
- while (vec.x() > 180.0F) {
- vec.setX(vec.x() - 360.0F);
- }
- while (vec.x() < -89.0F) {
- vec.setX(-89.0F);
- }
- while (vec.y() > 180.0F) {
- vec.setY(vec.x() - 360.0F);
- }
- while (vec.y() < -180.0F) {
- vec.setY(vec.y() + 360.0F);
- }
- return vec;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement