help-gnu-emacs
[Top][All Lists]

Oh, no! More Elisp! compute MTB frame size from your height

 From: Emanuel Berg Subject: Oh, no! More Elisp! compute MTB frame size from your height Date: Mon, 06 May 2019 02:45:23 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Description below good enough for IRC, good
enough for gmane.emacs.help, right? Wrong.

Still good enough for government work, right?

<incal> just wrote another simple but
useful program, to compute the
optimal MTB frame size:
<https://dataswamp.org/~incal/emacs-init/frame-size.el>
I should have a 49cm seat tube
(from the top to the middle of the
bottom bracket) - actually I'll go
out right now to see if that's what
I have :)

<incal> math should be right tho?
lineary mapping from one interval
to another

;; This file: http://user.it.uu.se/~embe8573/emacs-init/frame-size.el
;;              https://dataswamp.org/~incal/emacs-init/frame-size.el
;;
;; Updated:   2019-05-06  02:29
;;
;;
;; MTB frame size = length of seat tube
;;
;; measured from the top of the seat tube
;; down to center of bottom bracket
;;
<https://www.ebicycles.com/bicycle-tools/measure-frame/mountain-bike/hardtail>
;;
;;
;;   rider height           MTB frame size
;;
;;            (cm)                       (cm)
;;
;; 4'10" -    148 -     13" - 14"       33 - 37
;; 5'2"       158
;;
;; 5'2"  -    158 -     15" - 16"       38 - 42
;; 5'6"       168
;;
;; 5'6"  -    168 -     17" - 18"       43 - 47
;; 5'10"      178
;;
;; 5'10" -    178 -     19" - 20"       48 - 52
;; 6'1"       185
;;
;; 6'1"  -    185 -     21" - 22"       53 - 57
;; 6'4"       193
;;
;; 6'4"  -    193 -     23" - 24"       58 - 61
;; 6'6"       198
;;
;;
;; Example how to do the interval math for
;; a particular height
;;
;;     height h = 190cm
;;
;;     h \in [185 193] cm so
;;
;;     MTB frame size m \in [53 57] cm
;;
;;     (190 - 185) / (193 - 185.0) * (57 - 53) + 53 = 55.5cm
;;
;;
;; Table data source:
;;   https://www.evanscycles.com/help/bike-sizing-mountain

(defun in-inclusive (a min max)
(and (<= min a)
(<= a max) ))

(defvar *hft*) ; height to frame height table
(setq *hft* '(((148 158) (33 37))
((158 168) (38 42))
((168 178) (43 47))
((178 185) (48 52))
((185 193) (53 57))
((193 198) (58 61)) ))

(defun compute-mtb-frame-size (h)
(interactive "nheight (cm): ")
(let*((intervals (cl-find-if (lambda (e)
(in-inclusive h     (caar e)
*hft*) )
(h-interval  (car  intervals))
(h-min (caar intervals))
(m-min (car  m-interval))
(frame (round (+ (* (/ (- h     h-min)
(- h-max h-min)
1.0)
(- m-max m-min) )
m-min) )))
(message "frame size: %dcm" frame) ))
;; (compute-mtb-frame-size 190)
;; (compute-mtb-frame-size 180)

--
underground experts united
http://user.it.uu.se/~embe8573