Here you can find the source of angularDifference(double hdg, double brg)
Parameter | Description |
---|---|
hdg | angle 1 in degrees (typically the heading) |
brg | angle 2 in degrees (typically the bearing) |
public static double angularDifference(double hdg, double brg)
//package com.java2s; public class Main { /** Calculate the absolute angular difference between the two headings * /* w w w .ja v a 2 s . c o m*/ * @param hdg angle 1 in degrees (typically the heading) * @param brg angle 2 in degrees (typically the bearing) * @return difference between hdg and brg in degrees */ public static double angularDifference(double hdg, double brg) { double absDiff = Math.abs(hdg - brg); if (absDiff > 180) { return 360 - absDiff; } return absDiff; } }