Quaternions.
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
-
- Posts: 2974
- Joined: Fri, 18. Nov 05, 00:41
Quaternions.
I am giving ship modding another try and i've made some progress but ive ran into an issue (surprise). I have my ship working with an engine, turrets etc but I need to rotate some of the components.
I am doing this all manually in the xml and then testing in-game, as exporting component position out of blender just doesnt work (afaik).
How do these quaternions work? Can it even be done manually? I did some tests just randomly changing the quaternion values but it was a real mess. I have turrets that need to be rotated about 30* on the X axis.
The values I am finding in other xmls are crazy values like 1.7320510330969933e-07
Also - while messing around with random values I managed to squash a shield generator on one axis, can these quaternions be used to scale components? (I would love to be able to make the L engines much smaller on my ship).
I am doing this all manually in the xml and then testing in-game, as exporting component position out of blender just doesnt work (afaik).
How do these quaternions work? Can it even be done manually? I did some tests just randomly changing the quaternion values but it was a real mess. I have turrets that need to be rotated about 30* on the X axis.
The values I am finding in other xmls are crazy values like 1.7320510330969933e-07
Also - while messing around with random values I managed to squash a shield generator on one axis, can these quaternions be used to scale components? (I would love to be able to make the L engines much smaller on my ship).
-
- Moderator (Script&Mod)
- Posts: 7411
- Joined: Mon, 15. Dec 03, 18:53
Re: Quaternions.
I did a lot of this back in X rebirth and I am trying to recall. Quaternians was definitely one way to move the piece maybe inward or outward or something. Or maybe it was moving it along the same plane but in a different position. I just can't recall honestly. I remember having to do a lot of testing in game to see exactly where each thing was after putting the numbers in.Axeface wrote: ↑Mon, 27. Jul 20, 00:02I am giving ship modding another try and i've made some progress but ive ran into an issue (surprise). I have my ship working with an engine, turrets etc but I need to rotate some of the components.
I am doing this all manually in the xml and then testing in-game, as exporting component position out of blender just doesnt work (afaik).
How do these quaternions work? Can it even be done manually? I did some tests just randomly changing the quaternion values but it was a real mess. I have turrets that need to be rotated about 30* on the X axis.
The values I am finding in other xmls are crazy values like 1.7320510330969933e-07
Also - while messing around with random values I managed to squash a shield generator on one axis, can these quaternions be used to scale components? (I would love to be able to make the L engines much smaller on my ship).
-
- Moderator (English)
- Posts: 4787
- Joined: Fri, 21. Dec 18, 18:23
Re: Quaternions.
I suggest reading the Wikipedia article about them. It does provide the mathematics needed to convert them into human-relatable space.
They are intended for machine or calculation use only. This is because some operations can be executed using fewer clock cycles or mathematical operations on them as well as they are more compact since they do not suffer from problems like gimbal lock when describing rotations. Without a lot of experience with advanced mathematics they will make no sense to humans.
They are technically a type of complex number that has 3 "imaginary" fields on top of the usual 1 real field. Much like conventional complex numbers with 1 imaginary field, each field is perpendicular within multi-dimensional space of the numeric plane from its neighbours. This property means they have properties related to 4 dimensional vectors, which modern computer hardware is optimized to manipulate efficiently. Most humans, such as myself, have problem imagining 4 dimensional structures which is why non-calculated manipulation of them is seemingly impossible.
They are intended for machine or calculation use only. This is because some operations can be executed using fewer clock cycles or mathematical operations on them as well as they are more compact since they do not suffer from problems like gimbal lock when describing rotations. Without a lot of experience with advanced mathematics they will make no sense to humans.
They are technically a type of complex number that has 3 "imaginary" fields on top of the usual 1 real field. Much like conventional complex numbers with 1 imaginary field, each field is perpendicular within multi-dimensional space of the numeric plane from its neighbours. This property means they have properties related to 4 dimensional vectors, which modern computer hardware is optimized to manipulate efficiently. Most humans, such as myself, have problem imagining 4 dimensional structures which is why non-calculated manipulation of them is seemingly impossible.
-
- Posts: 1463
- Joined: Wed, 27. Jun 18, 19:05
Re: Quaternions.
Quaternions are a different mathematical representation for rotations. For 3d calculations they are often more practical but for us they are more difficult to read.
Instead of quaternions you can also use the rotation tag.
Instead of
(values are just examples and dont match to each other)
You can write this: (in degrees)
Brumbear gave me the hint and I use these only if I rotate something out of blender in the xml file directly.
Btw exporting components positions (and rotations) work perfect if you use the tool and the correct settings:
https://www.nexusmods.com/x4foundations ... t=66174131
Instead of quaternions you can also use the rotation tag.
Instead of
Code: Select all
<quaternion qw="-0.32366016388529006" qx="0.018206271709074604" qy="0.005126368367101456" qz="-0.945984328798087"/>
You can write this:
Code: Select all
<rotation pitch="0" yaw="0" roll="0"/>
Brumbear gave me the hint and I use these only if I rotate something out of blender in the xml file directly.
Btw exporting components positions (and rotations) work perfect if you use the tool and the correct settings:
https://www.nexusmods.com/x4foundations ... t=66174131
-
- Posts: 2974
- Joined: Fri, 18. Nov 05, 00:41
Re: Quaternions.
Thank you everyone!
Can something similar be done with size/scale?
The more you know! Thats so much easier! Got my turrets rotated correctly within a few minutes. Approaching something I might consider good enough for a release now.Max Bain wrote: ↑Mon, 27. Jul 20, 01:22You can write this:(in degrees)Code: Select all
<rotation pitch="0" yaw="0" roll="0"/>
Can something similar be done with size/scale?
I had seen that before but I think I had an issue with it or it didnt work in blender 2.8. I'll have another look.Max Bain wrote: ↑Mon, 27. Jul 20, 01:22Btw exporting components positions (and rotations) work perfect if you use the tool and the correct settings:
https://www.nexusmods.com/x4foundations ... t=66174131
-
- Moderator (Script&Mod)
- Posts: 7411
- Joined: Mon, 15. Dec 03, 18:53
Re: Quaternions.
I completely forgot about that. That is right, I had used the rotation pitch/yaw/roll and removed quaternions. I forgot so much, sigh. That's what happens when you stop doing something for several years.Axeface wrote: ↑Mon, 27. Jul 20, 02:10Thank you everyone!
The more you know! Thats so much easier! Got my turrets rotated correctly within a few minutes. Approaching something I might consider good enough for a release now.Max Bain wrote: ↑Mon, 27. Jul 20, 01:22You can write this:(in degrees)Code: Select all
<rotation pitch="0" yaw="0" roll="0"/>
Can something similar be done with size/scale?
I had seen that before but I think I had an issue with it or it didnt work in blender 2.8. I'll have another look.Max Bain wrote: ↑Mon, 27. Jul 20, 01:22Btw exporting components positions (and rotations) work perfect if you use the tool and the correct settings:
https://www.nexusmods.com/x4foundations ... t=66174131
-
- Posts: 2974
- Joined: Fri, 18. Nov 05, 00:41
Re: Quaternions.
That happens to me overnight (I swear im brain damaged), its why I value tutorials so much, especially visual ones.
And i've made a lot of progress if anyone is interested.
https://steamcommunity.com/sharedfiles/ ... 2179163275
https://steamcommunity.com/sharedfiles/ ... 2179163258
https://steamcommunity.com/sharedfiles/ ... 2179582202
Last edited by Axeface on Mon, 27. Jul 20, 18:04, edited 1 time in total.
-
- Posts: 308
- Joined: Fri, 3. Oct 08, 20:43
Re: Quaternions.
Nah. Not as far as i know. But "rezising" something shouldnt be much of a problem. Is there something specific u want to have bigger or smaller?
Gebt mir einen Spiegel dann schlage ich ihn mit seinem eigenen Gesicht
-
- Posts: 2974
- Joined: Fri, 18. Nov 05, 00:41
Re: Quaternions.
Im making a small L so I wanted to resize the engine as I originally planned to have 3 engines on it - only 1 fits. I've already started remodeling the ship to fit the oversized engine but still i'de like to know if its possible.BrummBear02 wrote: ↑Mon, 27. Jul 20, 12:47Nah. Not as far as i know. But "rezising" something shouldnt be much of a problem. Is there something specific u want to have bigger or smaller?
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
Re: Quaternions.
you would need to basically make a resized clone of all engines you want to choose between, and make them compatible with the slots by using a different set of tags (like "engine medim_large component", note the _ because space is a seperator between diffrent tags) than the vanilla ones. An alternative with less work involved would be to use M Engines instead, but a few more of them..
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
-
- Posts: 2974
- Joined: Fri, 18. Nov 05, 00:41
Re: Quaternions.
Thanks for the confirmation. Its a shame its not possible in the xmls like rotation.UniTrader wrote: ↑Mon, 27. Jul 20, 20:50you would need to basically make a resized clone of all engines you want to choose between, and make them compatible with the slots by using a different set of tags (like "engine medim_large component", note the _ because space is a seperator between diffrent tags) than the vanilla ones. An alternative with less work involved would be to use M Engines instead, but a few more of them..
-
- Posts: 308
- Joined: Fri, 3. Oct 08, 20:43
Re: Quaternions.
i know that feeling on the other hand its really not too much work. one engine takes about 15minutes to copy and resize.Axeface wrote: ↑Tue, 28. Jul 20, 05:15Thanks for the confirmation. Its a shame its not possible in the xmls like rotation.UniTrader wrote: ↑Mon, 27. Jul 20, 20:50you would need to basically make a resized clone of all engines you want to choose between, and make them compatible with the slots by using a different set of tags (like "engine medim_large component", note the _ because space is a seperator between diffrent tags) than the vanilla ones. An alternative with less work involved would be to use M Engines instead, but a few more of them..
Gebt mir einen Spiegel dann schlage ich ihn mit seinem eigenen Gesicht
-
- Posts: 1032
- Joined: Fri, 25. Jan 19, 03:26
Re: Quaternions.
Not sure if this will help much but this is what I used for gate rotation:
https://www.andre-gaschler.com/rotationconverter/
https://www.andre-gaschler.com/rotationconverter/
-
- Moderator (Script&Mod)
- Posts: 13307
- Joined: Sun, 15. Feb 04, 20:12
Re: Quaternions.
That link is a nice find DeadAirRT, thanks
Just my 10 pence on this:
1# Quarternions are normalized, i.e. for q = q_0+q_1+q_2+q_3 we have |q|=1. This explains the sometimes "odd" values (like very small) of some of them.
2# Quarternions are associate with a rotation around an axis by the following expression
q_0 = cos(alpha/2)
q_1 = sin(alpha/2)*cos(beta_x)
q_2 = sin(alpha/2)*cos(beta_y)
q_3 = sin(alpha/2)*cos(beta_z)
where alpha is a simple rotation angle (the value in radians of the angle of rotation) and cos(beta_x), cos(beta_y) and cos(beta_z) are the "direction cosines" locating the axis of rotation (Euler's Theorem).
3# Alternatively we use the Tait–Bryan angles (in terms of flight dynamics):
Roll – \phi: rotation about the X-axis
Pitch – \theta: rotation about the Y-axis
Yaw – \psi: rotation about the Z-axis
where the X-axis points forward, Y-axis to the right and Z-axis downward.
Cheers Euclid
Just my 10 pence on this:
1# Quarternions are normalized, i.e. for q = q_0+q_1+q_2+q_3 we have |q|=1. This explains the sometimes "odd" values (like very small) of some of them.
2# Quarternions are associate with a rotation around an axis by the following expression
q_0 = cos(alpha/2)
q_1 = sin(alpha/2)*cos(beta_x)
q_2 = sin(alpha/2)*cos(beta_y)
q_3 = sin(alpha/2)*cos(beta_z)
where alpha is a simple rotation angle (the value in radians of the angle of rotation) and cos(beta_x), cos(beta_y) and cos(beta_z) are the "direction cosines" locating the axis of rotation (Euler's Theorem).
3# Alternatively we use the Tait–Bryan angles (in terms of flight dynamics):
Roll – \phi: rotation about the X-axis
Pitch – \theta: rotation about the Y-axis
Yaw – \psi: rotation about the Z-axis
where the X-axis points forward, Y-axis to the right and Z-axis downward.
Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
Re: Quaternions.
Not sure how this affects the other stuff but the convention in X4 and earlier games is
X points Up (up on your monitor; up from the ecliptic; Up of a Ship)
Y points Right (right on your monitoy; East on the Ecliptic; Right of a Ship)
Z points forward (into your monitor; North on the Ecliptic; Front of a Ship)
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help