A library to manipulate 2D arrays, and output them to an LED Dot Matrix Display. The display must be wired up using a shift register combined with a nor latch.

Revision:
0:1deae5ffe9ed
Child:
1:44819562ea31
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Locations.h	Mon Feb 13 22:19:58 2012 +0000
@@ -0,0 +1,31 @@
+#ifndef LOCATIONS_H
+#define LOCATIONS_H
+class FloatLocation;
+class IntLocation {
+public:
+    IntLocation(int x = 0, int y = 0) : x(x), y(y) { }
+    int x, y;
+    operator FloatLocation();
+    bool operator==(IntLocation l) { return l.x == x && l.y == y; }
+    IntLocation operator+(IntLocation l) { return IntLocation(l.x + x, l.y + y); }
+};
+
+class FloatLocation {
+public:
+    FloatLocation(float x = 0, float y = 0) : x(x), y(y) { }
+    float x, y;
+    operator IntLocation() {
+        return IntLocation((int) (x + 0.5), (int) (y + 0.5));
+    }
+    FloatLocation lerp(FloatLocation to, float alpha) {
+        return FloatLocation(
+                   x*(1 - alpha) + to.x*alpha,
+                   y*(1 - alpha) + to.y*alpha
+               );
+    }
+    bool operator==(FloatLocation l) { return l.x == x && l.y == y; }
+};
+IntLocation::operator FloatLocation() {
+    return FloatLocation(x, y);
+}
+#endif
\ No newline at end of file