A work in progress.
So far all I have is RotateAlongAxis.
3d Math Library
Mirror
[Utility] 3d Math Library
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
[Utility] 3d Math Library
Last edited by AalaarDB on Thu, 15. Dec 05, 10:56, edited 1 time in total.
The library has been updated. It's still the same 3 functions but they are much improved.
I did some tests, comparing calculator, this library, the previous version of this library, and Reven's X2 library.
I tested 4 different angles, 4096, 8148, 15, 16000 and 2 positions, 32768, 0 and 23073, 23073. Both were in the higher precision range, but I later changed the 23073 to be in the lesser precision range, to make things faster.
I took the differences in the 2 dimensions and added them, then averaged that.
New version was off by an average of 1.375 meters
Old version was off by 34.75 meters
Reven's version was off by 78.25 meters
I then tested the lesser precision range, but only for the position 327680, 0.
It averaged 14.375 meters off, but remember that was range x10 so it's barely worse than the higher precision.
The maximum range is also higher for the new library than Reven's.
The speed is also faster than before.
Lasty, there is no rounding. Reven rounded, but in error made the negative numbers off by 1. I don't think adding an if statement plus an add is worth 1 more meter judging by how good it is already.
I am not planning on doing any more work, unless people request it. I am definately not doing a normalize or a rotate along arbitrary axis function...
Edit: I just realized I forgot to include the Asteroid Rotate script that I had in there as before. But this brings up a good point. If you want things to go faster, and are repetitively rotating the same angle, cache the sin and cos, then modify the script to accept precomputed sin and cos values. That would have been an awesome optimization to the previous hack job of a demo. Now that precision is so high I can afford to rotate the previous results by the same angle, with little loss in precision, rather than rotate the original position by a different angle each time. But not indefinately, for one revoultion only!
I did some tests, comparing calculator, this library, the previous version of this library, and Reven's X2 library.
I tested 4 different angles, 4096, 8148, 15, 16000 and 2 positions, 32768, 0 and 23073, 23073. Both were in the higher precision range, but I later changed the 23073 to be in the lesser precision range, to make things faster.
I took the differences in the 2 dimensions and added them, then averaged that.
New version was off by an average of 1.375 meters
Old version was off by 34.75 meters
Reven's version was off by 78.25 meters
I then tested the lesser precision range, but only for the position 327680, 0.
It averaged 14.375 meters off, but remember that was range x10 so it's barely worse than the higher precision.
The maximum range is also higher for the new library than Reven's.
The speed is also faster than before.
Lasty, there is no rounding. Reven rounded, but in error made the negative numbers off by 1. I don't think adding an if statement plus an add is worth 1 more meter judging by how good it is already.
I am not planning on doing any more work, unless people request it. I am definately not doing a normalize or a rotate along arbitrary axis function...
Edit: I just realized I forgot to include the Asteroid Rotate script that I had in there as before. But this brings up a good point. If you want things to go faster, and are repetitively rotating the same angle, cache the sin and cos, then modify the script to accept precomputed sin and cos values. That would have been an awesome optimization to the previous hack job of a demo. Now that precision is so high I can afford to rotate the previous results by the same angle, with little loss in precision, rather than rotate the original position by a different angle each time. But not indefinately, for one revoultion only!