/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: auUnitUtils.hpp Date: 2022-3-13 Author: Reece ***/ #pragma once /** It is not unusual for one to desire a unit-conversion constant when the developer understands [*] An FPU isn't available [*] Using a framework to normalize to a base unit(?), apply a translation, and return the desired reuslt is considered overkill These functions are not to be converted into such a convoluted templated potentially-constexpr castable mess The intention is to keep these utility functions as simple as the dumb operations they implement */ template constexpr const Inch AuFeetToInch(Feet feet) { return Inch(Precision(feet) * Precision(12)); } template constexpr const Feet AuInchToFeet(Inch inch) { return Feet(Precision(inch) / Precision(12)); } template constexpr const Inch AuCMToInch(CM cm) { return Inch(Inch(cm) * Inch(100) / Inch(254)); } template constexpr const CM AuInchToCM(Inch inch) { return CM(Inch(inch) * Inch(254) / Inch(100)); } template constexpr const M AuCMToM(CM cm) { return M(CM(cm) / CM(100)); } template constexpr const CM AuMToCM(M m) { return CM(CM(m) * CM(100)); } template constexpr const CM AuMMToCM(MM mm) { return CM(MM(mm) / MM(10)); } template constexpr const MM AuCMToMM(CM cm) { return MM(MM(cm) * MM(10)); } template constexpr const S AuMSToS(MS ms) { return S(MS(ms) / MS(1'000)); } template constexpr const MS AuSToMS(S s) { return MS(MS(s) * MS(1'000)); } template constexpr const MS AuNSToMS(NS ns) { return MS(NS(ns) / NS(1'000'000)); } template constexpr const NS AuMSToNS(MS ms) { return NS(NS(ms) * NS(1'000'000)); } template constexpr const F AuCToF(C c) { return F(Precision((Precision(c) * Precision(100)) / Precision(5) * Precision(9) + Precision(3200)) / Precision(100)); } template constexpr const C AuFToC(F f) { return C(((Precision(f) * Precision(100)) - Precision(3200)) * Precision(5) / Precision(9) / Precision(100)); } template constexpr const K AuCToK(C c) { return C(Precision(c) + Precision(273.15)); } template constexpr const C AuKToC(K k) { return C(Precision(k) - Precision(273.15)); }