/** * @param dm7 * A heading value in degree of magnitude 7 (dm7) * @return The built {@link Heading} object using the dm7 value */ public static Heading dm7(final long dm7) { // Roll dm7 value from 0->360 to the -180->180 that the angle expects. // Heading's circle is 180 degree ahead of Angle's long rollingDm7 = (dm7 - DELTA_DM7) % REVOLUTION_DM7; // After the roll operation, dm7 value could fall into (-180, -360) degrees. // This addition of 360 degrees will shift that degree back into (0, 180) if (rollingDm7 < MINIMUM_DM7) { rollingDm7 += REVOLUTION_DM7; } // After the roll operation, dm7 value could fall into [180, 360) degrees. // This subtraction of 360 degrees will shift that degree back into [-180, 0) if (rollingDm7 >= MAXIMUM_DM7) { rollingDm7 -= REVOLUTION_DM7; } return new Heading((int) rollingDm7); }