map()

Math / Calculation

Description

Re-maps a number from one range to another.

Syntax

float map(float value, float start1, float stop1, float start2, float stop2)

Parameters

NameTypeDescription
valuefloatthe incoming value to be converted
start1floatlower bound of the input range
stop1floatupper bound of the input range
start2floatlower bound of the output range
stop2floatupper bound of the output range

Returns

float

Related

Under the Hood

From Processing.h:

float map(float,float,float,float,float); return _api::map((float)value,(float)start1,(float)stop1,(float)start2,(float)stop2); static float map(float v,float i0,float i1,float o0,float o1) { return o0+(v-i0)*(o1-o0)/(i1-i0); } inline float map(float v,float i0,float i1,float o0,float o1){ return PApplet::map(v,i0,i1,o0,o1); } inline float map(float v,float i0,float i1,float o0,float o1){ return PApplet::map(v,i0,i1,o0,o1);