Is this correct ? If i substitute ValueType for int (so a Point<int>), this is producing incorrect results and warnings all over the place:
Point rotatedAboutOrigin (ValueType angleRadians) const noexcept
{
return Point (x * std::cos (angleRadians) - y * std::sin (angleRadians),
x * std::sin (angleRadians) + y * std::cos (angleRadians));
}
This should have been:
Point rotatedAboutOrigin (FloatType angleRadians) const noexcept
{
return Point (static_cast<ValueType> (x * std::cos (angleRadians) - y * std::sin (angleRadians)),
static_cast<ValueType> (x * std::sin (angleRadians) + y * std::cos (angleRadians)));
}
Or maybe better to return a Point<float> with correct results (it’s then easy to clamp it to a Point<int> and we don’t lose information):
Point<FloatType> rotatedAboutOrigin (FloatType angleRadians) const noexcept
{
return Point (x * std::cos (angleRadians) - y * std::sin (angleRadians),
x * std::sin (angleRadians) + y * std::cos (angleRadians));
}
