[Utility] 3d Math Library

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
Posts: 2279
Joined: Thu, 29. Jan 04, 09:19

[Utility] 3d Math Library

Post by AalaarDB » Tue, 13. Dec 05, 01:33

A work in progress.
So far all I have is RotateAlongAxis.
3d Math Library
Last edited by AalaarDB on Thu, 15. Dec 05, 11:56, edited 1 time in total.

Posts: 2279
Joined: Thu, 29. Jan 04, 09:19

Post by AalaarDB » Thu, 15. Dec 05, 11:20

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!

Posts: 20
Joined: Tue, 5. Dec 06, 22:27

Post by -IH- » Fri, 16. Feb 07, 12:58

Both links are broken. Does anybody have the scripts?
I'm looking for 3D transformation stuff and would be happy to get the work done by other pilot :)

Post Reply

Return to “X³: Reunion - Scripts and Modding”