This simulator of the CURTA mechanical calculator is written in SVG and JavaScript. We don't try to do better than Jan Meyer's flash simulator from 2008 (http://www.curta.de/kr34/curta_simulator_en.htm).
A CURTA model II is used for this simulator: 11 input digits, 15 result digits, 8 counter digits and 8 shift positions. Parts shown are:
The commas/thousands separators are not shown.
Thus, for the cap:
The object hierarchy is:
register I of 11 input cursors I01 to I11
register R of 15 result digits R01 to R15
register C of 8 counter digits C01 to C08
crank or drum handle H
counting direction switch D
clearing handle E
Values:
register R shift position S
clearing handle position P
All objects are generated around 0,0 as their object centre, then transformed as needed.
There are 15+8+11 = 34 digit wheels. Each digit wheel on the cap is represented as a black background rectangle with a white digit. Since the digits need to change, each digit is a clone of one of ten digit glyphs.
Top circle: (in 0.1mm)
inner diameter: 510
digit width: 25, inter-digit space: 42 inter register space: 72
angle between digits: 15º
15x(14+7)=315, leaves 360-315=45, or 22.5º on each side between the registers.
Let 0º pass through the centre of the result register's first digit. Let angles increase clockwise (they do so in SVG anyway). Then:
This helps in deciding when to set a digit to 0 as the reset handle passes over it.
In the real machine there is something sophisticated going on: when the clearing handle turns clockwise, digits are cleard slightly ahead of the handle, if it turns counterclockwise they are cleard slightly after the handle passes over them. But this happens only at the start of the clearing operation, towards the end (before the handle reaches its resting position) digits closer to the handle and finally under the handle are cleard. This is very difficult to simulate, decide to do it under the handle so that we don't even have to simulate the rotation of the digit wheels.
The handle has two resting positions: one in each of the centres of the register separation spaces (which themselves are -22.5/2 = -11.25º away from a digit's centre). These positions are at 337.5º (resting position 1) and 232.5º (resting position 2). However:
The problem with clearing the result could also be solved by using two different values for resting position 1: 337.5 for the counter and -11.5 for the result. This solution is effectively used by comparing with cRegisterDivide1-360 in the result procedures.
To make it easier to decide when to clear a digit as the clearhandle passes over it, we move the clear handle in increments of 5º but because it starts at either -11.25º or 221.25º we begin by putting it at a whole multiple of 5º: -10 or 220º . Then, as its angle modulo 15 is zero, we clear the digit corresponding to its position.
Both resting positions are taken to be at positive angles. After clearing the handle has to be in the other resting position. This makes a more general mechanism so difficult that it is easier to use four unfortunately very similar routines rather than trying to fold them up into one.
At first the digits were taken from Helvetica, no font was found to be closer to the Curta's digits. A possible solution would be to use a path for each digit instead of a font glyph, and this was ultimately adopted. There is no noticeable increase of processing time.
SVG filters were used to show some 3D and lighting effects. These do introduce a noticeable delay when clearing registers because the clearing handle has to be redrawn with a different lighting at each position, and furthermore the two little buttons have to be separate with a separate filter.