I've just started working on my Arduino C++ library. You can find it on GitHub: feel free to download it and use it for your projects.
I'll try to build a modern C++ library with advanced techniques and many examples. I'll suggest you a couple of books by which I am inspired:
- Modern C++ Design: Generic Programming and Design Patterns Applied
- Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions
Log Interface
AbstractLog.h contains an abstract class that you can use in your algorithm class to log every operation.
In SerialLog.h you will find a concrete implementation of AbstractLog which write your algorithm log on the Arduino serial port
In the future I'll show you how to log on a LCD display instead!
Vect3d
Vect3d.h contains a class that represent a 3-dimensional vector. You can use it to do some calculation on a generic 3D space (euclidean space, RGB color space ...)
If you install the Arduino Tinker Library you will find into Arduino IDE an example on how to use Vect3d in your code (File -> Examples -> ArduinoTinkerLibrary -> vect3d)
If you open the Arduino Serial Monitor (Tools -> Serial Monitor or Ctrl+Shift+M) you should see the following output
Vect3d Example
Constructor
V[0;0;0]
V[128;128;128]
V[64;64;64]
V[0.00;0.00;0.00]
V[1.00;1.00;1.00]
V[1.00;1.00;1.00]
V[123.00;456.00;789.00]
Copy
V[64.00;64.00;64.00]
V[1.00;1.00;1.00]
Test
f1 == b2
f3 != b2
Sum
V[124.00;457.00;790.00]
V[124.00;458.00;792.00]
V[129;129;129]
V[130;131;132]
Sub
V[122.00;455.00;788.00]
V[122.00;454.00;786.00]
V[129;130;131]
V[127;127;127]
Scalar Mul
V[307.50;1140.00;1972.50]
V[3.00;3.00;3.00]
Scalar Div
V[49.20;182.40;315.60]
V[1.00;1.00;1.00]
External functions
NormL1(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 189.00
NormL2(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 13.86
dot(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 192.00
cross(V[123.00;456.00;789.00] - V[64.00;64.00;64.00]): V[-21312.00;42624.00;-21312.00]