Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static double getUnsignedBearingDifference(double a1, double a2) {
        a1 = Math.abs(a1);
        a2 = Math.abs(a2);
        if (a1 > 180)
            a1 -= 180;
        if (a2 > 180)
            a2 -= 180;
        return Math.abs(getBearingDifference(a1, a2));
    }

    public static double getBearingDifference(double a1, double a2) {
        return Math.min((a1 - a2) < 0 ? a1 - a2 + 360 : a1 - a2, (a2 - a1) < 0 ? a2 - a1 + 360 : a2 - a1);
    }
}