MongooseA text-based world full of questionable inventions.

Changelog

All public mailing lists

$math_utils:map similar to c function to convert a value from one range to similar value on another range

2023-01-11 19:34 UTC · daiverd (#2)

Added:

example: I have a list of cardinal directions north, north north est, northeast, east northeat eat, etc. I want to map 360 degrees to this list of cardinal directions.

$math_utils:map(90, {0,360},{0,16}) = 4

Add 1 since moo indexes start at 1 and the 5th item in my list is the correct cardinal direction for this degree..

Note, things might be broken if not use float?

Taken from: https://deepbluembedded.com/map-function-embedded-c/

Back to Changelog