GY-63_MS5611/libraries/moduloMap
2023-11-14 11:59:49 +01:00
..
.github 0.1.1 moduloMap + github actions 2023-02-22 10:39:11 +01:00
examples 0.1.2 moduloMap 2023-11-14 11:59:49 +01:00
test 0.1.1 moduloMap 2022-10-23 10:36:41 +02:00
.arduino-ci.yml 0.1.0 moduloMap 2022-10-21 12:17:48 +02:00
CHANGELOG.md 0.1.2 moduloMap 2023-11-14 11:59:49 +01:00
keywords.txt 0.1.2 moduloMap 2023-11-14 11:59:49 +01:00
library.json 0.1.2 moduloMap 2023-11-14 11:59:49 +01:00
library.properties 0.1.2 moduloMap 2023-11-14 11:59:49 +01:00
LICENSE 0.1.1 moduloMap + github actions 2023-02-22 10:39:11 +01:00
moduloMap.h 0.1.2 moduloMap 2023-11-14 11:59:49 +01:00
README.md 0.1.2 moduloMap 2023-11-14 11:59:49 +01:00

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

moduloMap

Arduino library for the moduloMap class.

Description

The moduloMap is an experimental library that optimizes modular mapping.

How do I define modular mapping?

Imagine the mapping of all real numbers on a subset in a modular way. Imagine the real number line rolled around a defined circle with a minimum and maximum value. After one rotation the numbers mapped to start over again.

E.g. moduloMap(7, 13) maps all the real numbers to the interval [7; 13> modulo 6.

So the numbers 7..13 do not change as they are already within the range 7-13. The number 6 is mapped on 12, 5 on 11, 4 on 10, .. 1 on 7, 0 on 12 -1 on 11 etc. Similar the numbers in between e.g 5.5 is mapped on 11.5

Note: there is no scaling.

Other name might be circular mapping, although it might be any shape. (for now circles is complex enough)

Applications

  • modular mapping of rotations to angles.
    This can be on 0-360 degrees or 0-2PI radians or -180-180 degrees or even -90..270 degrees.
  • hoist math
    Imagine a hoist, that needs to roll up / roll off a long rope around a cylinder.
  • wire cutter
    Determine the length of a wire for a wire cutter by moving it between two wheels with known circumference.
  • math fun

Other mapping libraries

Interface

#include "moduloMap.h"
  • moduloMap() constructor.
  • bool begin(float minimum, float maximum) define the range the numbers should be mapped to. Returns true if minimum < maximum, false otherwise.
  • float map(float value) actual mapping of a value to a number within the range.
  • float rotations(float value) how many ranges (maximum - minimum) fit in a given length.
    Think of it as how many rotations must a hoist must make to "free" a rope of given length. Or how many rotations a hoist has to make to roll up a rope of given length. This includes the minimum that already has rolled off / should stay rolled off.

Get internal parameters (for debug)

  • float getMinimum() idem.
  • float getMaximum() idem.
  • float getRange() idem.

Performance

Tested with moduloMap_performance.ino on AVR.

version 1000 x map
0.1.0 44120 us
0.1.1 36340 us

Operation

The examples show the basic working of the functions.

Future

Must

  • elaborate documentation
  • add examples

Should

  • move code to .cpp file

Could

  • are there other than circular modulo?
    • triangular, square, pentagram, fractal?
    • increasing length per rotation (complex)
  • add begin(float radius)
    • assumes circle from 0..max

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,