summaryrefslogtreecommitdiff
path: root/altoslib/AltosRotation.java
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2017-07-21 17:44:03 -0600
committerBdale Garbee <bdale@gag.com>2017-07-21 17:44:03 -0600
commitc8dbcaf69cd538a31ab6e2b568237ae7c8656a9a (patch)
tree213ec02db2e80f2e8c39772c0bde95d802900e53 /altoslib/AltosRotation.java
parent0cbfa444a9f9159cb509bb47ca5590fc1d709f64 (diff)
parentea3b5815b27005b2f4c3034715f656d28ea8534e (diff)
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
Diffstat (limited to 'altoslib/AltosRotation.java')
-rw-r--r--altoslib/AltosRotation.java31
1 files changed, 28 insertions, 3 deletions
diff --git a/altoslib/AltosRotation.java b/altoslib/AltosRotation.java
index 1235d86b..eec8c529 100644
--- a/altoslib/AltosRotation.java
+++ b/altoslib/AltosRotation.java
@@ -16,11 +16,33 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-package org.altusmetrum.altoslib_11;
+package org.altusmetrum.altoslib_12;
public class AltosRotation extends AltosQuaternion {
private AltosQuaternion rotation;
+ /* Compute pitch angle from vertical by taking the pad
+ * orientation vector and rotating it by the current total
+ * rotation value. That will be a unit vector pointing along
+ * the airframe axis. The Z value will be the cosine of the
+ * angle from vertical.
+ *
+ * rot = ao_rotation * vertical * ao_rotation°
+ * rot = ao_rotation * (0,0,0,1) * ao_rotation°
+ * = ((a.z, a.y, -a.x, a.r) * (a.r, -a.x, -a.y, -a.z)) .z
+ *
+ * = (-a.z * -a.z) + (a.y * -a.y) - (-a.x * -a.x) + (a.r * a.r)
+ * = a.z² - a.y² - a.x² + a.r²
+ *
+ * rot = ao_rotation * (0, 0, 0, -1) * ao_rotation°
+ * = ((-a.z, -a.y, a.x, -a.r) * (a.r, -a.x, -a.y, -a.z)) .z
+ *
+ * = (a.z * -a.z) + (-a.y * -a.y) - (a.x * -a.x) + (-a.r * a.r)
+ * = -a.z² + a.y² + a.x² - a.r²
+ *
+ * tilt = acos(rot) (in radians)
+ */
+
public double tilt() {
double rotz = rotation.z * rotation.z - rotation.y * rotation.y - rotation.x * rotation.x + rotation.r * rotation.r;
@@ -28,8 +50,11 @@ public class AltosRotation extends AltosQuaternion {
return tilt;
}
- public void rotate(double dt, double x, double y, double z) {
- AltosQuaternion rot = AltosQuaternion.half_euler(x * dt / 2.0, y * dt / 2.0, z * dt / 2.0);
+ /* Given euler rotations in three axes, perform a combined rotation using
+ * quaternions
+ */
+ public void rotate(double x, double y, double z) {
+ AltosQuaternion rot = AltosQuaternion.euler(x, y, z);
rotation = rot.multiply(rotation).normalize();
}