@@ -1313,22 +1313,49 @@ Ratios: the <<ratio>> type</h3>
13131313Combination of <<ratio>></h4>
13141314
13151315 The interpolation of a <<ratio>> is defined
1316- by converting each <<ratio>> to an equivalent form
1317- with a ''1'' as its second value
1318- (so a ratio of ''3 / 2'' would become ''1.5 / 1'' ),
1319- then interpolating the numbers directly.
1316+ by converting each <<ratio>> to a number
1317+ by dividing the first value by the second
1318+ (so a ratio of ''3 / 2'' would become ''1.5'' ),
1319+ taking the logarithm of that result
1320+ (so the ''1.5'' would become approximately ''0.176'' ),
1321+ then interpolating those values.
1322+ The result during the interpolation
1323+ is converted back to a <<ratio>>
1324+ by inverting the logarithm,
1325+ then interpreting the result as a <<ratio>>
1326+ with the result as the first value and ''1'' as the second value.
13201327
13211328 <div class='example'>
13221329 For example,
13231330 halfway through a linear interpolation from ''5 / 1'' to ''3 / 2'' ,
1324- the result is the ratio ''3.25 / 1'' ,
1325- because 3.25 is halfway between 5 and 1.5.
1331+ the result is approximately the ratio ''2.73 / 1''
1332+ (roughly ''11 / 4'' , slightly taller than a ''3 / 1'' ratio):
13261333
1327- Note that this means the results are <em> not</em> scale-dependent;
1328- interpolating from ''5 / 1'' to ''300 / 200''
1329- gives the same results as the preceding example.
1334+ <pre>
1335+ start = log(5); // ≈ 0.69897
1336+ end = log(1.5); // ≈ 0.17609
1337+ interp = 0.69897*.5 + 0.17609*.5; // ≈ 0.43753
1338+ final = 10^interp; // ≈ 2.73
1339+ </pre>
13301340 </div>
13311341
1342+ Note: Interpolating over the logarithm of the ratio
1343+ means the results are scale-independent
1344+ (''5 / 1'' to ''300 / 200'' would give the same results as above),
1345+ that they're symmetrical over "wide" and "tall" variants
1346+ (interpolating from ''1 / 5'' to ''2 / 3'' would give
1347+ a ratio approximately equal to ''1 / 2.73'' at the halfway point),
1348+ and that they're symmetrical over whether the width is fixed and the height is based on the ratio
1349+ or vice versa.
1350+ These properties are not shared by many other possible interpolation strategies.
1351+
1352+ Note: Due to the properties of logarithms,
1353+ any log can be used;
1354+ the example here uses base-10 log,
1355+ but if, say, the natural log and e was used,
1356+ the intermediate results would be different
1357+ but the final result would be the same.
1358+
13321359 Addition of <<ratio>> s is not possible.
13331360
13341361<!--
0 commit comments