// Copyright (C) 2026 Jason M. Schwefel. All Rights Reserved.
package com.coldboreballisticsllc.scopedope.data.sensor

object WindBearingConverter {
    /**
     * Convert an absolute compass bearing to a shooter-relative wind angle.
     *
     * @param compassBearing  Direction the wind is coming FROM (0–359°, true North = 0°).
     * @param firingAzimuthDeg  Direction the shooter is firing (0–359°, true North = 0°).
     * @return Shooter-relative angle in [0, 360): 0° = headwind, 90° = R→L crosswind,
     *         180° = tailwind, 270° = L→R crosswind.
     */
    fun toShooterRelative(compassBearing: Double, firingAzimuthDeg: Double): Double =
        ((compassBearing - firingAzimuthDeg) % 360.0 + 360.0) % 360.0
}
