In convertRadiansToDegrees and convertDegreesToRadians methods, we are creating BigDecimals of PI/180 and 180/PI. These values have high precision and BigDecimal is too slow. We move these into a static variable to avoid repeated creations.
This change nets us about 50-66% speedup. The following table contains the testing on my machine.
Index
In
convertRadiansToDegrees
andconvertDegreesToRadians
methods, we are creatingBigDecimal
s ofPI/180
and180/PI
. These values have high precision and BigDecimal is too slow. We move these into a static variable to avoid repeated creations.