Last active
August 19, 2019 01:46
-
-
Save privong/3dbb4ba1a81f6643f976dc47bedf8221 to your computer and use it in GitHub Desktop.
Compute a plot speed as a function of cadence for different gear ratios
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require plot) | |
; gearing specifications | |
(define crings (list 36 48)) | |
(define cassette (list 12 13 14 15 17 19 21 23 25)) | |
; wheel circumference in km | |
(define wheelc (/ 2190 1e6)) | |
(define crange (list 75 95)) | |
; compute the distance traveled per one full rotation of pedals | |
; assumes non-accelerating motion | |
; Arguments: | |
; - circ: wheel circumference | |
; - front: number of teeth on front chainring | |
; - rear: number of teeth on rear gear | |
(define (dist-per-turn circ front rear) | |
(* circ (/ front rear))) | |
; speed | |
(define (calc-speed circ front rear cadence) | |
(* 60 (* (dist-per-turn circ front rear) | |
cadence))) | |
(plot-file (list (axes) | |
(map (λ (z) | |
(map (λ (y) | |
(function (λ (x) | |
(calc-speed wheelc z y x)) | |
50 115 | |
#:alpha (- 1 (/ y 40)) | |
#:style (cond | |
[(eq? z (car crings)) 'long-dash] | |
[else 'solid]))) | |
cassette)) | |
crings) | |
(lines-interval (list (vector (car crange) 0) (vector (car (cdr crange)) 60)) | |
(list (vector (car crange) 0) (vector (car (cdr crange)) 60)) | |
#:alpha 0.3 | |
#:label "Typical Cadence")) | |
#:title "Surly Cross-check gearing" | |
#:x-label "Cadence (rpm)" | |
#:y-label "Speed (kph)" | |
#:y-min 15 | |
#:y-max 45 | |
"surly.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment