The real thing to notice is that the sumOfAngles (both variants) were using Riven’s trig. Using Math.sin/cos it has very little error:
`sumOfAngles
DoubleSummaryStatistics{count=20000, sum=0.025140, min=0.000000, average=0.000001, max=0.000004}
sumOfAnglesSOA
DoubleSummaryStatistics{count=20000, sum=0.025140, min=0.000000, average=0.000001, max=0.000004}
agent
DoubleSummaryStatistics{count=20000, sum=0.250961, min=0.000000, average=0.000013, max=0.000083}
riven
DoubleSummaryStatistics{count=20000, sum=5.018816, min=0.000000, average=0.000251, max=0.000762}
`
Speed is basically unaffected, as expected:
`
N = 10_000
Benchmark Mode Samples Score Score error Units
b.Test.scalarAgentMath avgt 10 50.894 1.278 us/op
b.Test.scalarJavaMath avgt 10 876.978 6.797 us/op
b.Test.scalarRivenMath avgt 10 21.657 0.129 us/op
b.Test.sumOfAngles avgt 10 14.239 0.094 us/op
b.Test.sumOfAnglesSOA avgt 10 4.663 0.041 us/op
`
I probably should have remembered to do this earlier.