• David Flynn's avatar
    maths: allow the usual numeric conversions between Vec3<T> and Vec3<U> · 52848dbf
    David Flynn authored
    This makes Vec3<T> perform more like the usual arithmetic types, in
    order to avoid having to explicitly perform element wise conversions
    when two Vec3<>s have different numeric types.
    
    For instance:
      _i = int16_t() + int()                // typeof(_i) == int
      vi = Vec3<int16_t>() + Vec3<int>()    // typeof(vi) == Vec3<int>
    
      _d = 1 + 2.0                          // typeof(_d) == double
      vd = Vec3<int>(1) + Vec3<double>(2.0) // typeof(vd) == Vec3<double>
    
      vi = Vec3<int>(Vec3<double>())        // typeof(vi) == Vec3<int>
      vd = Vec3<double>(Vec3<int>())        // typeof(vd) == Vec3<double>
    
    Be aware, however, that the usual implicit conversions can result
    in a loss of precision:
    
            int _i = 1 + 1.5                          // _i == 2;
      Vec3<int> vi = Vec3<int>(1) + Vec3<double>(1.5) // vi == Vec3<int>(2)
    52848dbf