A guide to handling quaternions and angles in axana.
In this guide, you'll:
Represent rotations using quaternions
Apply quaternions to vectors
Calculate both the angle and quaternion between to vectors
Quaternions
Imagine we're writing an autopilot for a rocket in a simulation. In our modifier, we'll need to correct the direction our rocket is heading in. We can calculate the quaternion difference between the current direction and the target direction with axana.
Let's say Bob is trying to explain the orbital state of the Moon around the Earth in a simulation with spherical coordinates (3D polar coordinates). Since Axinite uses the Cartesian coordinate system, Bob will need to calculate the polar and azimuthal angles.
First, Bob will place the origin at (0, 0, 0). Then, Bob will choose that timestep he wants to describe:
import axinite as ax
import axinite.analysis as axana
import numpy as np
TIMESTEP = 0
# ... code ...
state = ax.state(body, TIMESTEP)
Then, he'll calculate the components of the coordinate with: