The equivalent function of Arduino map in Java
•
Java
Is there a function similar to the map function of Arduino for Java?
I need to map a series of values to another value range, so I want to know if there is something similar in Java, I have been searching, but I only get the map function of Java
Solution
The code of map () from Arduino's library is:
long map(long x,long in_min,long in_max,long out_min,long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }
This will work the same in Java - there is no real magic But standard Java does not have such a predefined
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码