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.
Locations.h
- Committer:
- EricWieser
- Date:
- 2012-02-13
- Revision:
- 0:1deae5ffe9ed
- Child:
- 1:44819562ea31
File content as of revision 0:1deae5ffe9ed:
#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