Jump to content

Can you do quaternion math? Finish my tool.


Recommended Posts

I was in the process of making a better mass-mover tool than aerons. It allows you to move objects in a group no matter how XYZ or rotation x,y,z change.

For example, you might want to put a boat together easily. If you had the original XYZ position of all the objects, you could place it in a custom position in the EXACT SAME way. This would allow you to place one object and mathematically determine all the positions of the other objects.

The problem I have come across is rotation compensation. Its too hard to explain in words, but to put it short, you need to do quanternion math, because objects have 3 different rotations. Heres a picture to briefly show the problem. It is explained in great detail (markings on the picture) in the tool:

http://img47.imageshack.us/img47/1700/3drotationwb8.jpg

Only one more step is needed, but it is the hardest.

Check out the tool here and try to post the formulas or finish it in excel, if you know how: http://rapidshare.com/files/8339331/off ... r.xls.html

Link to comment

I think I may have a solution.

First take the coordinates of the 'main object'.

Subtract these from the coordinates of each piece.

This will center the 'main object' at the origin(0,0,0) and move the other objects along with it.

Rotate each piece in place by the desired rotation angle.

The pieces are now all oriented correctly but in the wrong positions in relation to each other.

Each piece must rotate around the origin(0,0,0) by the specified angle as if fixed to a sphere. In other words, no matter how the point is rotated, it must always be the same distance from the origin(0,0,0). This is the trickiest step. Fortunately I believe I worked it out successfully in Excel.

Finally, decide what final coordinates you want your 'main object' to be at and add these coordinates to each object.

I am at work so I am unable to post the spread sheet at this time. I will put it up in about 1 hour when I get home.

Link to comment

Can someone find out if the rotations over the positive lines of all axises goes clock wise or anticlockwise?, because I had the feeling 1 axis rotation was clockwise and the other 2 anticlockwise or visa versa. (I'm at work right now)

That will explain why my method facks up.

if you look from coordinate 5,0,0 to 0,0,0 and have a object at 0,0,0 and give it rotation .785,0,0 (+45 on X axis) does it move clockwise or anti clockwise?

if you look from coordinate 0,5,0 to 0,0,0 and have a object at 0,0,0 and give it rotation 0,.785.0 (+45 on Y axis) does it move clockwise or anti clockwise?

if you look from coordinate 0,0,5 to 0,0,0 and have a object at 0,0,0 and give it rotation 0,0,.785 (+45 on Z axis) does it move clockwise or anti clockwise?

Link to comment
They should all follow the right hand rule.

In other words, if you are at a positive coordinate on the axis of rotation and you are looking back at the origin, all positive rotations will be counter-clockwise.

They should but does SA/MTA follow it?

Link to comment

Aeron, yes, at least initially. Meaning that assuming the objects has a rotation of (0,0,0) it will follow the right hand rule when rotated. There is, however, some odd behavior that I can not explain.

Give an object a rotation of (0,0,1.57).

The axis of the y rotation is now parallel to the z axis

Now changing the the X or Y rotations have the same affect on the object.

wtf!?!

Link to comment

hrm, im not sure what you guys are saying but I noticed whenever I was trying to do math I had to take in consideration that rotations are done backwards (in radians) in GTA/MTA. Instead of going in a circle right, it circles left ( it is the opposite of the rotation shown on the plane diagram here http://en.wikipedia.org/wiki/Flight_dynamics )

I've pretty much given up, I cant even get the rotation of the actual object right in the new position. I thought I had it right, but with 2 or 3 seperate formulas, I realized eventually they will not work in every scenario. I'm guessing the math is a lot harder than I would like to think for getting rotation right no matter what.

I know aeron has a rotator tool but that just simply rotates everything while maintaining the same position. Its different if you want to change 'how the object is rotated'. IE you rotate one object, and do the math to make sure each other object is rotated properly.

Then on top of that you have all the ways to do qaternions... and frankly I just can't understand it at all. I basically have no chance of getting this anymore. :P Hopefully I bother some uber programmer at my university when I get out of vacation in... two weeks :( Assuming you guys dont figure it out.

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...