#include "fgc/Geometry.h"

#include <algorithm>
#include <cmath>

namespace fgc {

long AxisMap::toCounts(double deg) const {
    double clamped = std::clamp(deg, min_deg, max_deg);
    return std::lround(static_cast<double>(zero_count) + clamped * counts_per_deg);
}

double AxisMap::toDeg(long counts) const {
    if (std::abs(counts_per_deg) < 1e-9) return 0.0;
    return (static_cast<double>(counts) - static_cast<double>(zero_count)) / counts_per_deg;
}

}  // namespace fgc
