summaryrefslogtreecommitdiff
path: root/altoslib/AltosQuaternion.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-05-12 23:33:53 -0700
committerKeith Packard <keithp@keithp.com>2016-05-12 23:41:55 -0700
commitb1a90adac9f6e2a609ce1ccd6749462bb5c9adbe (patch)
tree107b6491d8ffc507609f9923353d5454c0664323 /altoslib/AltosQuaternion.java
parentb13037fad0905c5933d1ff579122ba1357b02eea (diff)
altoslib: Store saved state in version-independent format
Use AltosHashSet for AltosState so that AltosDroid doesn't lose tracker information when the application is upgraded. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosQuaternion.java')
-rw-r--r--altoslib/AltosQuaternion.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/altoslib/AltosQuaternion.java b/altoslib/AltosQuaternion.java
index 351685f8..af9eb475 100644
--- a/altoslib/AltosQuaternion.java
+++ b/altoslib/AltosQuaternion.java
@@ -17,7 +17,7 @@
package org.altusmetrum.altoslib_11;
-public class AltosQuaternion {
+public class AltosQuaternion implements AltosHashable {
double r; /* real bit */
double x, y, z; /* imaginary bits */
@@ -147,4 +147,24 @@ public class AltosQuaternion {
c_x * s_y * c_z + s_x * c_y * s_z,
c_x * c_y * s_z - s_x * s_y * c_z);
}
+
+ public AltosHashSet hashSet() {
+ AltosHashSet h = new AltosHashSet();
+
+ h.putDouble("r", r);
+ h.putDouble("x", x);
+ h.putDouble("y", y);
+ h.putDouble("z", z);
+ return h;
+ }
+
+ public AltosQuaternion(AltosHashSet h) {
+ if (h == null)
+ return;
+
+ r = h.getDouble("r", 1);
+ x = h.getDouble("x", 0);
+ y = h.getDouble("y", 0);
+ z = h.getDouble("z", 0);
+ }
}