From 6f7935e42fba47c1b12758854946e80ba212bf21 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Mon, 1 Apr 2024 17:56:22 +1030 Subject: [PATCH] Add inverse fret number function --- common.scad | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common.scad b/common.scad index c3e8273..719a8b3 100644 --- a/common.scad +++ b/common.scad @@ -1,3 +1,6 @@ Guitar_Scale_Length_mm = 648; +ln2 = ln(2); +function log2(x) = ln(x)/ln2; function fret_scale_length(n) = Guitar_Scale_Length_mm * 2^(-n/12); +function mm_to_fret_number(mm) = -log2(mm/Guitar_Scale_Length_mm)*12; function lerp(start, end, amount) = start + (end-start)*amount;