X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosQuaternion.java;h=af9eb47558c701ad273753934826a4f6a5638854;hp=351685f8c578708243f0f038962f1bb5177a5b3a;hb=b1a90adac9f6e2a609ce1ccd6749462bb5c9adbe;hpb=b13037fad0905c5933d1ff579122ba1357b02eea 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); + } }