Post Wed Sep 22, 2004 6:26 am

**Tutorial** - Hardpoints mathematics revealed

I looked at the hardpoint orientation tutorial linked in the sticky, and must say it won't help you in most cases anyway. It mentions that there can be values below 1, but does not really explain how that works etc.

So I am going to give you this small tutorial, which really explains how that works. However, some might not understand because that is 3dimensional geometry, but you can learn it. But I recommend having basic knowledge in vector geometry.


First, I will show you how FL handles 3D coordinates.

It's interesting to know that FL seems to have everything upside down in the data, thus the y-axis points downward.



So what you have is, positive z-coordinates means pointing to the front of something, positive y-coords mean down, and positive x-coords mean right.

THE SHIP AND THE GUNS WORK BY THIS SCHEME!

The 9 numbers in the orientation settings mean this:
x-vector_x-coord

x-vector_y-coord
x-vector_z-coord
y-vector_x-coord
y-vector_y-coord
y-vector_z-coord
z-vector_x-coord
z-vector_y-coord
z-vector_z-coord

The x, y and z VECTORS are the grid axis of the gun!

the x, y and z COORDS are coords in the SHIP'S COORDINATE SYSTEM, BUT WITH THE GUN'S CENTER AS THE ORIGIN!

Now what FL needs is 3 vectors pointing from the gun center in the directions of the 3 axis of the GUN.

Those vectors are described as 1-unit-vectors, that means the length of the vector (imagine it as an arrow) is exactly 1!

So much about the theory. Now let's have a look again at the sketch:


Now what must have a good gemometrical thinking mind. ^^

Imagine the gun in its desired orientation. Where does THE GUN'S X-axis (=right) point to? Draw a vector from the gun's center into that direction, with the length of 1. Now you set the gun's center as the origin of the SHIP'S coordinate system and calculate the coordinates of that 1-lenght-vector. If that vector points exactly in the direction of one of the SHIP'S, for example, you have a vector like
1
0
0
or
0
1
0
or
0
0
1
The first one, for example, means "go 1 unit into x-direction, 0 into y and 0 into z-direction".

If it is not pointing exactly in the direction of a SHIP'S coordinate system, you must use the "enhanced" formula of Pythagoras: a²+b²+c²=d²

Now write that fitting into our scheme:

x²+y²+z²=1

With this formula you can also check whether the orienation values are valid. If not FL will produce really weird results.

If you were able to follow these steps for the gun's x-axis, , do the same for the y and z-axis.

Each vector coords are the coords to enter in utf, here is the scheme again:
x-vector_x-coord *
x-vector_y-coord *
x-vector_z-coord *
y-vector_x-coord #
y-vector_y-coord #
y-vector_z-coord #
z-vector_x-coord /
z-vector_y-coord /
z-vector_z-coord /

You see the triplets much better now that I marked them, they represent each a vector's coords. Also do the x²+y²+z²=1 check on each vector to make sure your calculations were correctly.


I am sorry some might not understand any of this if you don't have basic knowledge in vector calculations, but I am sure google will help you find a tutorial for those mathematical basics.

Edited by - Mephistopheles on 9/22/2004 11:12:57 PM

Edited by - Chips on 10/31/2004 6:50:20 AM