chore(optimization): Tiny optimization with pre-computed cos/sin from angle for QgsEllipse

Some benchmarks here:
https://github.com/lbartoletti/lbartoletti.github.io/tree/master/archives/qgis/ellipse_benchmark
This commit is contained in:
Loïc Bartoletti 2025-01-14 11:35:39 +01:00 committed by Loïc Bartoletti
parent 3ee8614932
commit f08eda1fcc

View File

@ -244,12 +244,12 @@ void QgsEllipse::pointsInternal( unsigned int segments, QVector<double> &x, QVec
const double sinAzimuth = std::sin( azimuth );
for ( double it : t )
{
*xOut++ = centerX +
mSemiMajorAxis * std::cos( it ) * cosAzimuth -
mSemiMinorAxis * std::sin( it ) * sinAzimuth;
*yOut++ = centerY +
mSemiMajorAxis * std::cos( it ) * sinAzimuth +
mSemiMinorAxis * std::sin( it ) * cosAzimuth;
const double cosT{ std::cos( it ) };
const double sinT{ std::sin( it ) };
*xOut++ = centerX + mSemiMajorAxis * cosT * cosAzimuth -
mSemiMinorAxis * sinT * sinAzimuth;
*yOut++ = centerY + mSemiMajorAxis * cosT * sinAzimuth +
mSemiMinorAxis * sinT * cosAzimuth;
if ( zOut )
*zOut++ = centerZ;
if ( mOut )