X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosRotation.java;h=6db0b541595ce37f51acd0f78c413abd07b72c38;hb=7175774c4f60ed3efd54417f2035b50ea0108c7b;hp=c4b07f623b465ef8bd354af14e099c0f48848a33;hpb=618f7ac8f31941fcbb3ed91829de69c0f0be8e0b;p=fw%2Faltos diff --git a/altoslib/AltosRotation.java b/altoslib/AltosRotation.java index c4b07f62..6db0b541 100644 --- a/altoslib/AltosRotation.java +++ b/altoslib/AltosRotation.java @@ -15,9 +15,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_8; +package org.altusmetrum.altoslib_11; -public class AltosRotation { +public class AltosRotation implements AltosJsonable { private AltosQuaternion rotation; public double tilt() { @@ -47,4 +47,23 @@ public class AltosRotation { AltosQuaternion up = new AltosQuaternion(0, 0, 0, sky); rotation = up.vectors_to_rotation(orient); } + + public AltosRotation(AltosJson j) { + rotation = new AltosQuaternion(j); + } + + public AltosRotation() { + rotation = new AltosQuaternion(); + } + + public AltosJson json() { + return rotation.json(); + } + + public static AltosRotation fromJson(AltosJson j, AltosRotation def) { + if (j == null) + return def; + + return new AltosRotation(j); + } }