/**
 * Calculate Free Space Path Loss.
 * Universal for all RF frequencies.
 *
 * FSPL(dB) = 20*log10(d_km) + 20*log10(f_MHz) + 32.45
 *
 * @param distanceKm - Distance in kilometers
 * @param frequencyMHz - Frequency in megahertz
 * @returns Path loss in dB
 */
export function calculateFSPL(
  distanceKm: number,
  frequencyMHz: number
): number {
  if (distanceKm <= 0) return 0;
  return (
    20 * Math.log10(distanceKm) +
    20 * Math.log10(frequencyMHz) +
    32.45
  );
}
