I am on my 3rd attempt to point my 3D models using quaternions. Over the years I have failed and I still cannot use quaternions properly.
I created a simple triangle model and placed it in inertial space using the *.xyzv and *.q format.
It appears when my quaternion inertial to body (Qi2b) = 1 0 0 0 entry (no rotation) in the *.q file, the model point towards the vernal equinox (I think). I think that is where is should point because the X axis is defined to point to the vernal equinox. When I turn on the body and frame axis (by right clicking on my triangle) the X axis are 180 apart. I have not presented any rotations so shouldn't the x axes line up? Below is my simple *.scc file.
"SLS_Nom vFS" "Sol/Earth"
{
Class "spacecraft"
Mesh "basic_rot.cmod"
Radius 0.040
Visible true
Clickable true
Color [0.98 0.97 1.0]
# the BodyFixed is for orientation
OrbitFrame { EquatorJ2000 { Center "Sol/Earth" } }
SampledTrajectory
{
Source "nominal_vFS.xyzv"
DoublePrecision true
}
BodyFrame { EquatorJ2000 { Center "Sol/Earth" } }
SampledOrientation "nominal_vFS.q"
}
I turn on the Body and Frame Axis by right clicking on the vehicle and selecting "Reference Marks". Is the frame axis inertial. The z points up parallel to the earth's poles so I assume it is.
My *.q file gradually pitches the triangle up (positive) slowly over time but the model rotates around the Frame Axis' negative y axis. This is negative of what I expected. Then, I roll the vehicle slowly but the model rotates around the Frame Axis' negative x axis.
It appears there needs to be a rotation of 90 deg but the Orientation[] does not work in the *.scc anymore. Do I have to do this in my 3D model or go back and insert the 90 deg rotation in my quaternion? I swapped y and -z in my 3d model and the model now lines up with the red/green/blue body axis.
I have seen suggestions to use quat as w x -z y but surely Chris did not intend for us to do this. Chris posted:
2454025 0 0 1 0
2454026 0.707 0.707 0 0
2454027 0 0 1 0
2454028 1 0 0 0
2454029 0 0 1 0
2454030 0 1 0 0
2454031 0 0 0 1
2454032 1 0 0 0
on https://www.classe.cornell.edu/~seb/celestia/celestia_notes.html#5.9.2
and said that it represents 90 and 180 deg rotations but he never shows it in 3D. I am thinking that there is a bug.
failing to use quaternions to point models
-
Topic authorNASA_SimGuy
- Posts: 24
- Joined: 18.10.2018
- With us: 6 years 1 month
- Sirius_Alpha
- Posts: 223
- Joined: 21.03.2019
- With us: 5 years 8 months
Hey there.
I've recently gotten into quaternions for one of my own projects as well, and like you I referred to Selden's notes on SampledOrientation. I was able to get his example quaternion script to work for me - the test object just rotated through a series of different orientations.
I have had some success with making my own quaternion files under the assumption that the input format is X Y Z W, rather than W X Y Z. I don't know if that's the entirety of the issue, but I think it's worth investigating. I don't know why it's not consistent with Selden's notes, either, tbh. I wrote a programme to create quaternions from pitch, yaw and roll commands and it's possible that a confluence of errors have conspired to cancel out and produce results that I wanted.
I've recently gotten into quaternions for one of my own projects as well, and like you I referred to Selden's notes on SampledOrientation. I was able to get his example quaternion script to work for me - the test object just rotated through a series of different orientations.
I have had some success with making my own quaternion files under the assumption that the input format is X Y Z W, rather than W X Y Z. I don't know if that's the entirety of the issue, but I think it's worth investigating. I don't know why it's not consistent with Selden's notes, either, tbh. I wrote a programme to create quaternions from pitch, yaw and roll commands and it's possible that a confluence of errors have conspired to cancel out and produce results that I wanted.
Exoplanet nerd. I maintain a monthly-updated exoplanet catalogue here:
https://celestiaproject.space/forum/viewtopic.php?f=23&t=18705
https://celestiaproject.space/forum/viewtopic.php?f=23&t=18705
-
Topic authorNASA_SimGuy
- Posts: 24
- Joined: 18.10.2018
- With us: 6 years 1 month
Which 3D model axis is facing your velocity vector? X?
Which way is the Y axis pointing, too? Is it to the right your x axis? Is Z up?
I am using my Qi2b (inertial to body) quaternion in an earth application. My orientation appears to have my pitch and roll backwards. I think I have issues with either my 3D model frame or a frame setup. Did you have to add any Orientation function calls in your ssc file?
Which way is the Y axis pointing, too? Is it to the right your x axis? Is Z up?
I am using my Qi2b (inertial to body) quaternion in an earth application. My orientation appears to have my pitch and roll backwards. I think I have issues with either my 3D model frame or a frame setup. Did you have to add any Orientation function calls in your ssc file?
- Sirius_Alpha
- Posts: 223
- Joined: 21.03.2019
- With us: 5 years 8 months
My convention is to have, at the start, the +Z axis facing the velocity vector. +Y is up. +X is to port. It seems a little strange, but all my spacecraft lead with their north pole forward.Which 3D model axis is facing your velocity vector? X? Which way is the Y axis pointing, too? Is it to the right your x axis? Is Z up?
Code: Select all
SampledOrientation "Tianzhou2_q.q"
BodyFrame
{
TwoVector
{
Center "Sol/Earth/Tianhe"
Primary
{
Axis "-y"
RelativePosition { Target "Sol/Earth" }
}
Secondary
{
Axis "-z"
RelativeVelocity { Target "Sol/Earth" }
}
}
}
Exoplanet nerd. I maintain a monthly-updated exoplanet catalogue here:
https://celestiaproject.space/forum/viewtopic.php?f=23&t=18705
https://celestiaproject.space/forum/viewtopic.php?f=23&t=18705
-
Topic authorNASA_SimGuy
- Posts: 24
- Joined: 18.10.2018
- With us: 6 years 1 month
Quaternions and 3D model
Thanks for your help, Sirius_Alpha,
I built a cmod triangle model manually (like an arrow) with the z-axis pointing down the arrow tip and x-axis port.
vertices 3
2000000 0 0 0 0 1 0 0
-2000000 0 0 0 0 1 0 1
0 0 10000000 0 0 1 1 1
When I view the model in Celestia, the Body Axis has the tip down the y-axis. Why isn't my arrow tip down the z-axis when I view the Body Axis? I like the idea of the old Orientation[] function but it is now deprecated.
Also, I noticed that you use a TwoVector object. I tried copying your TwoVector text (with my object) to my *.ssc file but I could not find my 3D model in the scene. Do I have to use TwoVector with quaternions? Why did you use it? Is your object relative to another satellite?
I built a cmod triangle model manually (like an arrow) with the z-axis pointing down the arrow tip and x-axis port.
vertices 3
2000000 0 0 0 0 1 0 0
-2000000 0 0 0 0 1 0 1
0 0 10000000 0 0 1 1 1
When I view the model in Celestia, the Body Axis has the tip down the y-axis. Why isn't my arrow tip down the z-axis when I view the Body Axis? I like the idea of the old Orientation[] function but it is now deprecated.
Also, I noticed that you use a TwoVector object. I tried copying your TwoVector text (with my object) to my *.ssc file but I could not find my 3D model in the scene. Do I have to use TwoVector with quaternions? Why did you use it? Is your object relative to another satellite?
- Sirius_Alpha
- Posts: 223
- Joined: 21.03.2019
- With us: 5 years 8 months
My apologies in the delay in responding.
Here is my Tianzhou quaternion test. A separate programme I wrote creates quaternions from pitch, yaw and roll commands, and the output .q file is contained herein. Perhaps it will be useful to you to have what should be a successful example of a quaternion being used that you can modify to your liking to experiment around with. The rotations are scheduled to occur in Celestia just before midnight, 05 July 2021 UTC. It works as a stand-alone addon, so you don't need to have Tianhe or anything else.
I'm afraid I don't know the answer to that. I'm not really familiar with how the custom-made CMOD files work. To be rather honest, I just made my mesh in Anim8or and found an orientation that puts its "front" toward the velocity vector. That was the sole motivator in choosing the axes I did.When I view the model in Celestia, the Body Axis has the tip down the y-axis. Why isn't my arrow tip down the z-axis when I view the Body Axis?
Admittedly, I'm not entirely sure what "Center "Sol/Earth/Tianhe"" actually does but if you change this to make it the object itself, that seems to be acceptable, and accomplishes the same thing.Also, I noticed that you use a TwoVector object. I tried copying your TwoVector text (with my object) to my *.ssc file but I could not find my 3D model in the scene.
I'm almost certain the answer is no.Do I have to use TwoVector with quaternions?
I wanted to have control over which side of the spacecraft is the dorsal/ventral side, as well as establish a fixed 3D coordinate system for other nearby spacecraft/objects.Why did you use it?
This one is (Tianhe) but it does't need to be.Is your object relative to another satellite?
Here is my Tianzhou quaternion test. A separate programme I wrote creates quaternions from pitch, yaw and roll commands, and the output .q file is contained herein. Perhaps it will be useful to you to have what should be a successful example of a quaternion being used that you can modify to your liking to experiment around with. The rotations are scheduled to occur in Celestia just before midnight, 05 July 2021 UTC. It works as a stand-alone addon, so you don't need to have Tianhe or anything else.
- Attachments
-
- Tianzhou_Quat.rar
- An addon with a simple functioning quaternion being used.
- (328.51 KiB) Downloaded 220 times
Exoplanet nerd. I maintain a monthly-updated exoplanet catalogue here:
https://celestiaproject.space/forum/viewtopic.php?f=23&t=18705
https://celestiaproject.space/forum/viewtopic.php?f=23&t=18705
- Sirius_Alpha
- Posts: 223
- Joined: 21.03.2019
- With us: 5 years 8 months
More recently, I've had a lot more success assuming the quaternion input format is as stated in Selden's notes though. Don't listen to that Sirius_Alpha person, he has no idea what he's talking about.Sirius_Alpha wrote:I have had some success with making my own quaternion files under the assumption that the input format is X Y Z W, rather than W X Y Z.
Exoplanet nerd. I maintain a monthly-updated exoplanet catalogue here:
https://celestiaproject.space/forum/viewtopic.php?f=23&t=18705
https://celestiaproject.space/forum/viewtopic.php?f=23&t=18705