Click or drag to resize

CrestronEnvironmentScaleWithLimits(Int32, Int32, Int32, Int32, Int32) Method

Scales a given input value that lies between a given set of input limits to an output value given a set of output limits. This version works on signed integer arguments.

Namespace: Crestron.SimplSharp
Assembly: SimplSharpHelperInterface (in SimplSharpHelperInterface.dll) Version: 2.21.121
Syntax
C#
public static int ScaleWithLimits(
	int InputValue,
	int InputUpperBound,
	int InputLowerBound,
	int OutputUpperBound,
	int OutputLowerBound
)

Parameters

InputValue  Int32
The int input value to be converted.
InputUpperBound  Int32
The int upper boundary of the domain from which the input value is to be converted.
InputLowerBound  Int32
The int lower boundary of the domain from which the input value is to be converted.
OutputUpperBound  Int32
The int upper boundary of the range into which the input value is to be converted.
OutputLowerBound  Int32
The int lower boundary of the range into which the input value is to be converted.

Return Value

Int32

A scaled int value from the equation :

OutputValue = OutputLowerBound + (( (InputValue - InputLowerBound) * (OutputUpperBound - OutputLowerBound) ) / (InputUpperBound - InputLowerBound))

Exceptions
ExceptionCondition
ArgumentOutOfRangeException

Cause: InputLowerBound >= InputUpperBound

Cause: OutputLowerBound > OutputUpperBound

Cause: InputUpperBound == InputLowerBound.

Output under- or over- flow. (See message for output value.)

Version Information

.NET

Supported in: 6.0

.NET Compact Framework

Supported in: 3.5
See Also