Hello,
I am working on some trajectory calculations, and having a strange
compiler error. First, great that I should get a compiler error at
all! Second, what am I missing?
quantity<acceleration> g() {
static const auto gValue = static_cast<double>(9.812);
static const auto metersPerSecondPerSecond = meters / second / second;
static const quantity<acceleration> g = gValue*metersPerSecondPerSecond;
return g;
}
double Class1::CalculateZeta(double timeMilliseconds, double heightMeters) {
static const auto two = static_cast<double>(2);
static const auto milliseconds = milli*seconds;
const auto t = timeMilliseconds*milliseconds;
const auto h = heightMeters*meters;
const auto g_ = g();
auto result = -(g_ / two)*(t*t) + h;
return result.value();
}
Just if I did the dimensional analysis, I might expect the time
components (i.e. T^2) to cancel themselves out, which should leave me
with length+length, no?
This is exposed via a C++ CLR (VS2013), but the Boost.Units are done internally.
What am I missing here? I need to normalize the units, say to meters, etc?
Best regards,
Michael Powell
Errors:
Error 4 error C2676: binary '+' :
'boost::units::quantity>,boost::units::dimensionless_type>,boost::units::heterogeneous_system>,boost::units::dimensionless_type>,boost::units::list>,boost::units::dimensionless_type>,boost::units::list>>,void>,double>'
does not define this operator or a conversion to a type acceptable to
the predefined operator
I:\Source\Spikes\Kingdom.Physics\src\Kingdom.Physics.Calculators\Class1.cpp
43 1 Kingdom.Physics.Calculators
Error 2 error C2784:
'add_typeof_helper,boost::units::unit>::type
boost::units::operator +(const boost::units::unit
&,const boost::units::unit &)' : could not deduce
template argument for 'const boost::units::unit &'
from 'boost::units::quantity>,boost::units::dimensionless_type>,boost::units::heterogeneous_system>,boost::units::dimensionless_type>,boost::units::list>,boost::units::dimensionless_type>,boost::units::list>>,void>,double>'
I:\Source\Spikes\Kingdom.Physics\src\Kingdom.Physics.Calculators\Class1.cpp
43 1 Kingdom.Physics.Calculators
Error 3 error C2893: Failed to specialize function template
'add_typeof_helper,boost::units::quantity>::type
boost::units::operator +(const boost::units::quantity &,const
boost::units::quantity &)'
I:\Source\Spikes\Kingdom.Physics\src\Kingdom.Physics.Calculators\Class1.cpp
43 1 Kingdom.Physics.Calculators
5 IntelliSense: no operator "+" matches these operands
operand types are:
boost::units::quantity>,
boost::units::dimensionless_type>,
boost::units::heterogeneous_system>,
boost::units::dimensionless_type>,
boost::units::list>,
boost::units::dimensionless_type>,
boost::units::list>>,
boost::units::dimensionless_type>>>, void>, double> + const
boost::units::quantity, double>
i:\Source\Spikes\Kingdom.Physics\src\Kingdom.Physics.Calculators\Class1.cpp
43 49 Kingdom.Physics.Calculators