We previously supported multiplication between Measurables, but specifically the inner product:
(Measured::Length(2, :cm) * Measured::Length(3, :cm)).to_s
> 6 cm
This is convenient, but not (mathematically) correct. When multiplying two measured values we should combine units from the same system, raising the exponent, and then multiplying/dividing the other units:
Measured::Length(2, :cm) * Measured::Length(3, :cm)
> 6 cm^2
Measured::Length(2, :m) * Measured::Length(0.002, :km) / Measured::Time(0.1, :seconds)
> 40 m/s
This change should not come at a performance penalty for any current use cases:
unit + unit
unit.scale(scalar)
unit.convert_to(:simple_unit)
- etc
We previously supported multiplication between
Measurables, but specifically the inner product:This is convenient, but not (mathematically) correct. When multiplying two measured values we should combine units from the same system, raising the exponent, and then multiplying/dividing the other units:
This change should not come at a performance penalty for any current use cases:
unit + unitunit.scale(scalar)unit.convert_to(:simple_unit)