static float Remap( float value, float oldLow, float oldHigh, float newLow, float newHigh )
static float Remap( float value, float oldLow, float oldHigh, float newLow, float newHigh, bool clamp )
static System.Double Remap( System.Double value, System.Double oldLow, System.Double oldHigh, System.Double newLow, System.Double newHigh, bool clamp )
static int Remap( int value, int oldLow, int oldHigh, int newLow, int newHigh )

robot_2Generated
code_blocksInput

Description

The Remap method in the MathX class is used to map a value from one range to another. This is particularly useful when you need to convert a value from one scale to another, such as converting a temperature from Celsius to Fahrenheit, or mapping a game score to a different range for display purposes.

Usage

To use the Remap method, provide the value you want to remap, the current range (oldLow to oldHigh), and the new range (newLow to newHigh). The method will return the value mapped to the new range.

Parameters:

  • value (System.Single): The value to be remapped.
  • oldLow (System.Single): The lower bound of the current range.
  • oldHigh (System.Single): The upper bound of the current range.
  • newLow (System.Single): The lower bound of the new range.
  • newHigh (System.Single): The upper bound of the new range.

Returns:

  • System.Single: The value remapped to the new range.

Example

// Example of using the Remap method
float originalValue = 5.0f;
float remappedValue = MathX.Remap(originalValue, 0.0f, 10.0f, 0.0f, 100.0f);
// remappedValue will be 50.0f, as 5.0 is halfway between 0.0 and 10.0, 
// and thus maps to halfway between 0.0 and 100.0.