• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics with the tag "measurements". Back to normal view
    1. Piano key dimensions are a math puzzle

      Piano keys are familiar and easy enough to draw if you're not trying to be exact, but if you want label the dimensions with their exact measurements (like in a CAD drawing), it turns into a math...

      Piano keys are familiar and easy enough to draw if you're not trying to be exact, but if you want label the dimensions with their exact measurements (like in a CAD drawing), it turns into a math puzzle. The problem comes from the groups of two and three black keys.

      This article explains it like this:

      If you've ever looked closely at a piano keyboard you may have
      noticed that the widths of the white keys are not all the same
      at the back ends (where they pass between the black keys). Of
      course, if you think about it for a minute, it's clear they
      couldn't possibly all be the same width, assuming the black keys
      are all identical (with non-zero width) and the white keys all
      have equal widths at the front ends, because the only simultaneous
      solution of 3W=3w+2b and 4W=4w+3b is with b=0.

      To unpack that a bit: in that equation, 'W' is the width of each white key at the front (which should all be the same), 'w' is the width of a white key at the back, and 'b' is the width of a black key.) The first equation is for the group of two black keys (separating C, D, and E) and the second equation is for the three black keys separating F through B.

      Since it's mathematically impossible, a constraint needs to be relaxed. The article describes ways to make the white keys have slightly different widths at the back.

      If we set c=e=(W-5B/8) and a=b=d=f=g=(W-3B/4) we have a maximum
      discrepancy of only B/8, and quite a few actual pianos use this
      pattern as well. However, the absolute optimum arrangement is to
      set c=d=e=(W-2B/3) and f=g=a=b=(W-3B/4), which gives a maximum
      discrepancy of just B/12. This pattern is used on many keyboards,
      e.g. the Roland PC-100.

      When actually building a musical instrument (instead of just drawing the keyboard), there is a further constraint, described in this article:

      The black keys on a piano keyboard, instead of always being centered on the dividing line between the two white keys they lie between, are spaced so that the twelve keys which make up an octave are spaced equally as they enter the internal mechanism of the instrument.

      But this means that the "key caps" for the white keys should be slightly off-center compared to whatever rod or lever they're attached to. The author speculates about how to divide this up using various units.

      (They seem quite annoying to 3D print.)

      19 votes
    2. Programming Challenge: Convert between units

      Hi everyone! It's been a long time since last programming challenge list, and here's a nice one I've encountered. If you search for something like 7km to AU, you'll get your answer. But how is it...

      Hi everyone! It's been a long time since last programming challenge list, and here's a nice one I've encountered.

      If you search for something like 7km to AU, you'll get your answer. But how is it done? I don't think they hardcoded all 23 units of distance and every conversion factor between them.

      If you were programming a conversion system - how would you do it?

      First of all, you have input in format that you can specify, for example something like this:

      meter kilometer 1000
      mile kilometer 1.609344
      second minute 60
      ...
      

      Then you should be able answer queries. For example 7 mile meter should convert 7 miles to meters, which is 11265.41.

      Can you design an algorithm that will convert any unit into any other unit?

      Edit: Some conversion rates I extracted from wikipedia:

      ångström
      0.1nm
      astronomical unit
      149597870700m
      attometre
      0.000000000000000001m
      barleycorn
      8.4m
      bohr
      0.00846
      cable length (imperial)
      185.3184m
      cable length
      185.2m
      cable length (US)
      219.456m
      chain (Gunters)
      20.11684m
      cubit
      0.5m
      ell
      1.143m
      fathom
      1.8288m
      femtometre
      0.00000000000001m
      fermi
      0.00000000000001m
      finger
      0.022225m
      finger (cloth)
      0.1143m
      foot (Benoit)
      0.304799735m
      foot (Cape) (H)
      0.314858m
      foot (Clarke's) (H)
      0.3047972654m
      foot (Indian) (H)
      0.304799514m
      foot,metric
      0.31622776602m
      foot,metric (long)
      0.3m
      foot,metric (short)
      0.30m
      foot (International)
      0.3048m
      foot (Sear's) (H)
      0.30479947m
      foot (US Survey)
      0.304800610
      french
      0.0003m
      furlong
      201.168m
      hand
      0.1016m
      inch
      0.0254m
      league
      4828m
      light-day
      25902068371200m
      light-hour
      107925284880m
      light-minute
      17987547480
      light-second
      299792458m
      light-year
      31557600light-second
      line
      0.002116m
      link (Gunter's)
      0.2011684m
      link (Ramsden's; Engineer's)
      0.3048m
      metre
      1m
      m
      1metre
      km
      1000m
      mickey
      0.000127
      micrometre
      0.000001
      mil; thou
      0.0000254
      mil
      10km
      mile (geographical)
      6082foot (International)
      quarter
      0.2286m
      rod
      5.0292m
      rope
      6.096m
      shaku
      0.303 0303m
      span (H)
      0.2286m
      stick (H)
      0.0508m
      toise
      1.949 0363m
      twip
      1.76310
      yard
      0.9144m
      
      17 votes