]> Pileus Git - ~andy/iBeaconNav/blobdiff - src/edu/ucla/iBeaconNav/Vect.java
Add quaternion and vector code
[~andy/iBeaconNav] / src / edu / ucla / iBeaconNav / Vect.java
diff --git a/src/edu/ucla/iBeaconNav/Vect.java b/src/edu/ucla/iBeaconNav/Vect.java
new file mode 100644 (file)
index 0000000..1949da5
--- /dev/null
@@ -0,0 +1,56 @@
+package edu.ucla.iBeaconNav;
+
+class Vect
+{
+       public double x = 0;
+       public double y = 0;
+       public double z = 0;
+
+       /* Constructors */
+       public Vect()
+       {
+       }
+
+       public Vect(double x, double y, double z)
+       {
+               this.x = x;
+               this.y = y;
+               this.z = z;
+       }
+
+       /* Set functions */
+       public void set(double x, double y, double z)
+       {
+               this.x = x;
+               this.y = y;
+               this.z = z;
+       }
+
+       /* Add functions */
+       public void add(Vect v)
+       {
+               this.x += v.x;
+               this.y += v.y;
+               this.z += v.z;
+       }
+       public void add(double off)
+       {
+               this.x += off;
+               this.y += off;
+               this.z += off;
+       }
+
+       /* Multiply functions (scalar) */
+       public void mul(Vect v)
+       {
+               this.x *= v.x;
+               this.y *= v.y;
+               this.z *= v.z;
+       }
+       public void mul(double sf)
+       {
+               this.x *= sf;
+               this.y *= sf;
+               this.z *= sf;
+       }
+}