altoslib: Add null constructors to AltosQuaternion and AltosRotation
authorKeith Packard <keithp@keithp.com>
Fri, 17 Jun 2016 06:59:06 +0000 (23:59 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 17 Jun 2016 06:59:06 +0000 (23:59 -0700)
These will be used in the reflection-based JSON code

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosQuaternion.java
altoslib/AltosRotation.java

index 1b4a9419c875799b3abaaca022e0535e75288c61..98c2fe51322851e5b7fb1e5b95723fc173f4655e 100644 (file)
@@ -115,10 +115,17 @@ public class AltosQuaternion implements AltosJsonable {
        }
 
        public AltosQuaternion(AltosQuaternion q) {
-               this.r = q.r;
-               this.x = q.x;
-               this.y = q.y;
-               this.z = q.z;
+               r = q.r;
+               x = q.x;
+               y = q.y;
+               z = q.z;
+       }
+
+       public AltosQuaternion() {
+               r = 1;
+               x = 0;
+               y = 0;
+               z = 0;
        }
 
        static public AltosQuaternion vector(double x, double y, double z) {
index 321a0f304d53d11d49950f2b82db3d277007ad24..6db0b541595ce37f51acd0f78c413abd07b72c38 100644 (file)
@@ -48,14 +48,18 @@ public class AltosRotation implements AltosJsonable {
                rotation = up.vectors_to_rotation(orient);
        }
 
-       public AltosJson json() {
-               return rotation.json();
-       }
-
        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;