Though doing sequenced “followedBy” calls is a clear way of demonstrating what’s happening, how much is performance affected when needing to create a matrix representing translation/rotation/scale (after optimisations)? It seems like more than enough calculations and creations of floats occur, figuring you could combine translation with either scale or rotation in one call…
Here’s an example of said hand-rolled optimisations:
/** Creates a new AffineTransform matrix, translated and rotated */
static AffineTransform translationAndRotation (float x, float y, float angleRads) noexcept
{
const float cosRad = std::cos (angleRads);
const float sinRad = std::sin (angleRads);
return AffineTransform (cosRad, -sinRad, x,
sinRad, cosRad, y);
}
/** Creates a new AffineTransform matrix, translated and scaled */
static AffineTransform translationAndScale (float x, float y, float scale) noexcept
{
return AffineTransform (scale, 0.0f, x,
scale, 0.0f, y);
}
/** Creates a new AffineTransform matrix, translated and scaled */
static AffineTransform translationAndScale (float x, float y,
float scaleX, float scaleY) noexcept
{
return AffineTransform (scaleX, 0.0f, x,
scaleY, 0.0f, y);
}
Aside from that, why not any SSE usage for the various operations?