Scalar
Summary
The math class containing scalar math operations
Definition
Namespace: SDT4.Managed.Core.Math
Assembly: SDT4.Managed.Core.dll
static class Scalar
Inheritance:
Object ➔ Scalar
Implements:
Fields
| Name | Type | Description |
|---|---|---|
Properties
| Name | Type | Description |
|---|---|---|
Methods
public static Single NormalizeAngle(Single angle)
Summary: Normalises an angle in radians to the range [-pi, pi].
Parameters:
angle(Single): The angle in radians.
Returns:
- Single: The normalised angle in radians.
public static Single DeltaAngle(Single current, Single target)
Summary: Calculates the shortest angular difference in radians from a current angle to a target angle.
Parameters:
Returns:
- Single: The angular difference in radians within [-pi, pi].
public static Double NormalizeAngle(Double angle)
Summary: Normalises an angle in radians to the range [-pi, pi].
Parameters:
angle(Double): The angle in radians.
Returns:
- Double: The normalised angle in radians.
public static Double DeltaAngle(Double current, Double target)
Summary: Calculates the shortest angular difference in radians from a current angle to a target angle.
Parameters:
Returns:
- Double: The angular difference in radians within [-pi, pi].
public static Single ToDeg(Single rad)
Summary: Converts an angle from radians to degrees.
Parameters:
rad(Single): The angle in radians.
Returns:
- Single: The angle converted to degrees.
public static Single ToRad(Single deg)
Summary: Converts an angle from degrees to radians.
Parameters:
deg(Single): The angle in degrees.
Returns:
- Single: The angle converted to radians.
public static Double ToDeg(Double rad)
Summary: Converts an angle from radians to degrees.
Parameters:
rad(Double): The angle in radians.
Returns:
- Double: The angle converted to degrees.
public static Double ToRad(Double deg)
Summary: Converts an angle from degrees to radians.
Parameters:
deg(Double): The angle in degrees.
Returns:
- Double: The angle converted to radians.
public static Boolean Approximately(Single a, Single b)
Summary: Determines whether two single-precision floating-point values are approximately equal within precision tolerance.
Parameters:
Returns:
- Boolean:
if the absolute difference is less than Constants.EpsilonF; otherwise, .
public static Boolean Approximately(Single a, Single b, Single tolerance)
Summary: Determines whether two double-precision floating-point values are approximately equal within a given tolerance.
Parameters:
-
a(Single): The first scalar value. -
b(Single): The second scalar value. -
tolerance(Single): The maximal amount of error allowed.
Returns:
- Boolean:
if the absolute difference is less than toleranceotherwise,.
public static Boolean IsBetween(Single v, Single min, Single max)
Summary: Determines whether a value lies within an inclusive range.
Parameters:
-
v(Single): The value to test. -
min(Single): The inclusive minimum bound. -
max(Single): The inclusive maximum bound.
Returns:
- Boolean:
if vis betweenminandmaxinclusive; otherwise,.
public static Boolean IsBetweenExcl(Single v, Single min, Single max)
Summary: Determines whether a value lies strictly within an exclusive range.
Parameters:
-
v(Single): The value to test. -
min(Single): The exclusive minimum bound. -
max(Single): The exclusive maximum bound.
Returns:
- Boolean:
if vis strictly greater thanminand strictly less thanmax; otherwise,.
public static Boolean Approximately(Double a, Double b)
Summary: Determines whether two double-precision floating-point values are approximately equal within precision tolerance.
Parameters:
Returns:
- Boolean:
if the absolute difference is less than Constants.EpsilonD; otherwise, .
public static Boolean Approximately(Double a, Double b, Double tolerance)
Summary: Determines whether two double-precision floating-point values are approximately equal within a given tolerance.
Parameters:
-
a(Double): The first scalar value. -
b(Double): The second scalar value. -
tolerance(Double): The maximal amount of error allowed.
Returns:
- Boolean:
if the absolute difference is less than toleranceotherwise,.
public static Boolean IsBetween(Double v, Double min, Double max)
Summary: Determines whether a value lies within an inclusive range.
Parameters:
-
v(Double): The value to test. -
min(Double): The inclusive minimum bound. -
max(Double): The inclusive maximum bound.
Returns:
- Boolean:
if vis betweenminandmaxinclusive; otherwise,.
public static Boolean IsBetweenExcl(Double v, Double min, Double max)
Summary: Determines whether a value lies strictly within an exclusive range.
Parameters:
-
v(Double): The value to test. -
min(Double): The exclusive minimum bound. -
max(Double): The exclusive maximum bound.
Returns:
- Boolean:
if vis strictly greater thanminand strictly less thanmax; otherwise,.
public static Single SmoothDamp(Single current, Single target, ref Single currentVelocity, Single smoothTime, Single maxSpeed, Single deltaTime)
Summary: Smoothly transitions a single-precision scalar value towards a target over time using critically damped spring dynamics.
Parameters:
-
current(Single): The current scalar value. -
target(Single): The target destination value. -
currentVelocity(Single): A reference to the current velocity, updated by the method. -
smoothTime(Single): The approximate time required to reach the target. -
maxSpeed(Single): The maximum speed allowed. -
deltaTime(Single): The elapsed time since the previous update.
Returns:
- Single: The smoothed scalar value.
public static Double SmoothDamp(Double current, Double target, ref Double currentVelocity, Double smoothTime, Double maxSpeed, Single deltaTime)
Summary: Smoothly transitions a double-precision scalar value towards a target over time using critically damped spring dynamics.
Parameters:
-
current(Double): The current scalar value. -
target(Double): The target destination value. -
currentVelocity(Double): A reference to the current velocity, updated by the method. -
smoothTime(Double): The approximate time required to reach the target. -
maxSpeed(Double): The maximum speed allowed. -
deltaTime(Single): The elapsed time since the previous update.
Returns:
- Double: The smoothed scalar value.
public static Single Clamp(Single v, Single min, Single max)
Summary: Clamps a single-precision value to a specified inclusive range.
Parameters:
Returns:
- Single: The clamped scalar value.
public static Single Min(Single a, Single b)
Summary: Returns the smaller of two single-precision values.
Parameters:
Returns:
- Single: The smaller value.
public static Single Max(Single a, Single b)
Summary: Returns the larger of two single-precision values.
Parameters:
Returns:
- Single: The larger value.
public static Single Ceil(Single f)
Summary: Computes the smallest integral value that is greater than or equal to the specified single-precision number.
Parameters:
f(Single): The input value.
Returns:
- Single: The ceiling value.
public static Single Floor(Single f)
Summary: Computes the largest integral value that is less than or equal to the specified single-precision number.
Parameters:
f(Single): The input value.
Returns:
- Single: The floor value.
public static Single Round(Single f)
Summary: Rounds a single-precision value to the nearest integer.
Parameters:
f(Single): The input value.
Returns:
- Single: The rounded value.
public static Single Saturate(Single v)
Summary: Clamps a single-precision value to the range [0, 1].
Parameters:
v(Single): The value to saturate.
Returns:
- Single: The saturated value.
public static Single Wrap(Single v, Single min, Single max)
Summary: Wraps a single-precision value into the range [min, max).
Parameters:
-
v(Single): The input value. -
min(Single): The inclusive minimum bound. -
max(Single): The exclusive maximum bound.
Returns:
- Single: The wrapped scalar value.
public static Single PingPong(Single v, Single min, Single max)
Summary: Oscillates a single-precision value back and forth between a minimum and maximum range.
Parameters:
-
v(Single): The progressing value. -
min(Single): The minimum bound. -
max(Single): The maximum bound.
Returns:
- Single: The oscillated value within [min, max].
public static Double Clamp(Double v, Double min, Double max)
Summary: Clamps a double-precision value to a specified inclusive range.
Parameters:
Returns:
- Double: The clamped scalar value.
public static Double Min(Double a, Double b)
Summary: Returns the smaller of two double-precision values.
Parameters:
Returns:
- Double: The smaller value.
public static Double Max(Double a, Double b)
Summary: Returns the larger of two double-precision values.
Parameters:
Returns:
- Double: The larger value.
public static Double Ceil(Double f)
Summary: Computes the smallest integral value that is greater than or equal to the specified double-precision number.
Parameters:
f(Double): The input value.
Returns:
- Double: The ceiling value.
public static Double Floor(Double f)
Summary: Computes the largest integral value that is less than or equal to the specified double-precision number.
Parameters:
f(Double): The input value.
Returns:
- Double: The floor value.
public static Double Round(Double f)
Summary: Rounds a double-precision value to the nearest integer.
Parameters:
f(Double): The input value.
Returns:
- Double: The rounded value.
public static Double Saturate(Double v)
Summary: Clamps a double-precision value to the range [0, 1].
Parameters:
v(Double): The value to saturate.
Returns:
- Double: The saturated value.
public static Double Wrap(Double v, Double min, Double max)
Summary: Wraps a double-precision value into the range [min, max).
Parameters:
-
v(Double): The input value. -
min(Double): The inclusive minimum bound. -
max(Double): The exclusive maximum bound.
Returns:
- Double: The wrapped scalar value.
public static Double PingPong(Double v, Double min, Double max)
Summary: Oscillates a double-precision value back and forth between a minimum and maximum range.
Parameters:
-
v(Double): The progressing value. -
min(Double): The minimum bound. -
max(Double): The maximum bound.
Returns:
- Double: The oscillated value within [min, max].
public static Single Sqrt(Single f)
Summary: Returns the square root of a single-precision number.
Parameters:
f(Single): The input value.
Returns:
- Single: The square root.
public static Single Pow(Single f, Single p)
Summary: Raises a single-precision value to a specified power.
Parameters:
Returns:
- Single: The value of
fraised top.
public static Single Exp(Single power)
Summary: Returns e raised to the specified single-precision power.
Parameters:
power(Single): The exponent.
Returns:
- Single: The mathematical constant e raised to
power.
public static Single Log(Single f, Single p)
Summary: Computes the logarithm of a single-precision number in a specified base.
Parameters:
Returns:
- Single: The logarithm of
fin basep.
public static Single Log(Single f)
Summary: Computes the natural (base e) logarithm of a single-precision number.
Parameters:
f(Single): The input value.
Returns:
- Single: The natural logarithm.
public static Single Log10(Single f)
Summary: Computes the base-10 logarithm of a single-precision number.
Parameters:
f(Single): The input value.
Returns:
- Single: The base-10 logarithm.
public static Double Sqrt(Double f)
Summary: Returns the square root of a double-precision number.
Parameters:
f(Double): The input value.
Returns:
- Double: The square root.
public static Double Pow(Double f, Double p)
Summary: Raises a double-precision value to a specified power.
Parameters:
Returns:
- Double: The value of
fraised top.
public static Double Exp(Double power)
Summary: Returns e raised to the specified double-precision power.
Parameters:
power(Double): The exponent.
Returns:
- Double: The mathematical constant e raised to
power.
public static Double Log(Double f, Double p)
Summary: Computes the logarithm of a double-precision number in a specified base.
Parameters:
Returns:
- Double: The logarithm of
fin basep.
public static Double Log(Double f)
Summary: Computes the natural (base e) logarithm of a double-precision number.
Parameters:
f(Double): The input value.
Returns:
- Double: The natural logarithm.
public static Double Log10(Double f)
Summary: Computes the base-10 logarithm of a double-precision number.
Parameters:
f(Double): The input value.
Returns:
- Double: The base-10 logarithm.
public static Single Lerp(Single a, Single b, Single t)
Summary: Performs a linear interpolation between two single-precision values.
Parameters:
-
a(Single): The starting value. -
b(Single): The destination value. -
t(Single): The interpolation factor.
Returns:
- Single: The interpolated scalar value.
public static Single LerpAngle(Single a, Single b, Single t)
Summary: Interpolates linearly between two angles in radians, correctly wrapping around circle boundaries along the shortest path.
Parameters:
-
a(Single): The starting angle in radians. -
b(Single): The destination angle in radians. -
t(Single): The interpolation factor.
Returns:
- Single: The interpolated angle in radians.
public static Single InvLerp(Single a, Single b, Single x)
Summary: Calculates the inverse linear interpolation factor of a single-precision value within a given range.
Parameters:
-
a(Single): The start of the range. -
b(Single): The end of the range. -
x(Single): The value to query.
Returns:
- Single: The linear interpolation factor t such that Lerp(a, b, t) == x.
public static Single Map(Single srcStart, Single srcEnd, Single targetStart, Single targetEnd, Single x)
Summary: Remaps a single-precision value from an input range to a corresponding target range.
Parameters:
-
srcStart(Single): The start bound of the source range. -
srcEnd(Single): The end bound of the source range. -
targetStart(Single): The start bound of the target range. -
targetEnd(Single): The end bound of the target range. -
x(Single): The value to remap.
Returns:
- Single: The mapped value within the target range.
public static Double Lerp(Double a, Double b, Double t)
Summary: Performs a linear interpolation between two double-precision values.
Parameters:
-
a(Double): The starting value. -
b(Double): The destination value. -
t(Double): The interpolation factor.
Returns:
- Double: The interpolated scalar value.
public static Double LerpAngle(Double a, Double b, Double t)
Summary: Interpolates linearly between two angles in radians, correctly wrapping around circle boundaries along the shortest path.
Parameters:
-
a(Double): The starting angle in radians. -
b(Double): The destination angle in radians. -
t(Double): The interpolation factor.
Returns:
- Double: The interpolated angle in radians.
public static Double InvLerp(Double a, Double b, Double x)
Summary: Calculates the inverse linear interpolation factor of a double-precision value within a given range.
Parameters:
-
a(Double): The start of the range. -
b(Double): The end of the range. -
x(Double): The value to query.
Returns:
- Double: The linear interpolation factor t such that Lerp(a, b, t) == x.
public static Double Map(Double srcStart, Double srcEnd, Double targetStart, Double targetEnd, Double x)
Summary: Remaps a double-precision value from an input range to a corresponding target range.
Parameters:
-
srcStart(Double): The start bound of the source range. -
srcEnd(Double): The end bound of the source range. -
targetStart(Double): The start bound of the target range. -
targetEnd(Double): The end bound of the target range. -
x(Double): The value to remap.
Returns:
- Double: The mapped value within the target range.
public static Single MoveTowards(Single current, Single target, Single maxDelta)
Summary: Advances a single-precision value towards a target by a maximum step delta without overshooting.
Parameters:
-
current(Single): The current value. -
target(Single): The target value to reach. -
maxDelta(Single): The maximum step size allowed.
Returns:
- Single: The updated value moving towards
target.
public static Single MoveTowardsAngle(Single current, Single target, Single maxDelta)
Summary: Advances an angle in radians towards a target angle along the shortest circular path by a maximum step delta.
Parameters:
-
current(Single): The current angle in radians. -
target(Single): The target angle in radians. -
maxDelta(Single): The maximum angular step permitted in radians.
Returns:
- Single: The updated angle in radians moving towards
target.
public static Single Sign(Single value)
Summary: Returns the sign of a single-precision value, returning 1.0f for positive, -1.0f for negative, and 0.0f for zero.
Parameters:
value(Single): The input value.
Returns:
- Single: 1.0f, -1.0f, or 0.0f indicating the sign.
public static Single Abs(Single value)
Summary: Returns the absolute value of a single-precision number.
Parameters:
value(Single): The input value.
Returns:
- Single: The non-negative magnitude of
value.
public static Double Sign(Double value)
Summary: Returns the sign of a double-precision value, returning 1.0d for positive, -1.0d for negative, and 0.0d for zero.
Parameters:
value(Double): The input value.
Returns:
- Double: 1.0d, -1.0d, or 0.0d indicating the sign.
public static Double Abs(Double value)
Summary: Returns the absolute value of a double-precision number.
Parameters:
value(Double): The input value.
Returns:
- Double: The non-negative magnitude of
value.
public static Single Step(Single edge, Single x)
Summary: Generates a step function, returning 1.0f if the value exceeds the threshold edge; otherwise 0.0f.
Parameters:
Returns:
- Single: 1.0f if
x>edge; otherwise, 0.0f.
public static Single LinearStep(Single edgeMin, Single edgeMax, Single x)
Summary: Performs a clamped linear interpolation mapping an input value between two boundary edges to [0, 1].
Parameters:
-
edgeMin(Single): The lower threshold edge. -
edgeMax(Single): The upper threshold edge. -
x(Single): The input value.
Returns:
- Single: The normalised linear interpolation factor clamped to [0, 1].
public static Single SmoothStep(Single edgeMin, Single edgeMax, Single x)
Summary: Performs smooth Hermite interpolation between 0 and 1 when an input value lies within the range [edgeMin, edgeMax].
Parameters:
-
edgeMin(Single): The lower threshold edge. -
edgeMax(Single): The upper threshold edge. -
x(Single): The input value.
Returns:
- Single: A smoothly interpolated S-curve factor between 0.0f and 1.0f.
public static Single HardStep(Single edgeMin, Single edgeMax, Single x)
Summary: Evaluates a scaled, clamped hard step function across a range.
Parameters:
-
edgeMin(Single): The lower threshold edge. -
edgeMax(Single): The scaling multiplier factor. -
x(Single): The input value.
Returns:
- Single: The calculated hard step value clamped at a lower bound of zero.
public static Double Step(Double edge, Double x)
Summary: Generates a step function, returning 1.0d if the value exceeds the threshold edge; otherwise 0.0d.
Parameters:
Returns:
- Double: 1.0d if
x>edge; otherwise, 0.0d.
public static Double LinearStep(Double edgeMin, Double edgeMax, Double x)
Summary: Performs a clamped linear interpolation mapping an input value between two boundary edges to [0, 1].
Parameters:
-
edgeMin(Double): The lower threshold edge. -
edgeMax(Double): The upper threshold edge. -
x(Double): The input value.
Returns:
- Double: The normalised linear interpolation factor clamped to [0, 1].
public static Double SmoothStep(Double edgeMin, Double edgeMax, Double x)
Summary: Performs smooth Hermite interpolation between 0 and 1 when an input value lies within the range [edgeMin, edgeMax].
Parameters:
-
edgeMin(Double): The lower threshold edge. -
edgeMax(Double): The upper threshold edge. -
x(Double): The input value.
Returns:
- Double: A smoothly interpolated S-curve factor between 0.0d and 1.0d.
public static Double HardStep(Double edgeMin, Double edgeMax, Double x)
Summary: Evaluates a scaled, clamped hard step function across a range.
Parameters:
-
edgeMin(Double): The lower threshold edge. -
edgeMax(Double): The scaling multiplier factor. -
x(Double): The input value.
Returns:
- Double: The calculated hard step value clamped at a lower bound of zero.
public static Single Sin(Single f)
Summary: Returns the sine of the specified angle in radians.
Parameters:
f(Single):
Returns:
public static Single Cos(Single f)
Summary: Returns the cosine of the specified angle in radians.
Parameters:
f(Single):
Returns:
public static Single Tan(Single f)
Summary: Returns the tangent of the specified angle in radians.
Parameters:
f(Single):
Returns:
public static Single Asin(Single f)
Summary: Returns the angle in radians whose sine is the specified value.
Parameters:
f(Single):
Returns:
public static Single Acos(Single f)
Summary: Returns the angle in radians whose cosine is the specified value.
Parameters:
f(Single):
Returns:
public static Single Atan(Single f)
Summary: Returns the angle in radians whose tangent is the specified value.
Parameters:
f(Single):
Returns:
public static Single Atan2(Single y, Single x)
Summary: Returns the angle in radians whose tangent is the quotient of two specified numbers.
Parameters:
Returns:
public static Single Sinh(Single f)
Summary: Returns the hyperbolic sine of the specified value.
Parameters:
f(Single):
Returns:
public static Single Cosh(Single f)
Summary: Returns the hyperbolic cosine of the specified value.
Parameters:
f(Single):
Returns:
public static Single Tanh(Single f)
Summary: Returns the hyperbolic tangent of the specified value.
Parameters:
f(Single):
Returns:
public static Single Asinh(Single f)
Summary: Returns the angle whose hyperbolic sine is the specified value.
Parameters:
f(Single):
Returns:
public static Single Acosh(Single f)
Summary: Returns the angle whose hyperbolic cosine is the specified value.
Parameters:
f(Single):
Returns:
public static Single Atanh(Single f)
Summary: Returns the angle whose hyperbolic tangent is the specified value.
Parameters:
f(Single):
Returns:
public static Double Sin(Double f)
Summary: Returns the sine of the specified angle in radians.
Parameters:
f(Double):
Returns:
public static Double Cos(Double f)
Summary: Returns the cosine of the specified angle in radians.
Parameters:
f(Double):
Returns:
public static Double Tan(Double f)
Summary: Returns the tangent of the specified angle in radians.
Parameters:
f(Double):
Returns:
public static Double Asin(Double f)
Summary: Returns the angle in radians whose sine is the specified value.
Parameters:
f(Double):
Returns:
public static Double Acos(Double f)
Summary: Returns the angle in radians whose cosine is the specified value.
Parameters:
f(Double):
Returns:
public static Double Atan(Double f)
Summary: Returns the angle in radians whose tangent is the specified value.
Parameters:
f(Double):
Returns:
public static Double Atan2(Double y, Double x)
Summary: Returns the angle in radians whose tangent is the quotient of two specified numbers.
Parameters:
Returns:
public static Double Sinh(Double f)
Summary: Returns the hyperbolic sine of the specified value.
Parameters:
f(Double):
Returns:
public static Double Cosh(Double f)
Summary: Returns the hyperbolic cosine of the specified value.
Parameters:
f(Double):
Returns:
public static Double Tanh(Double f)
Summary: Returns the hyperbolic tangent of the specified value.
Parameters:
f(Double):
Returns:
public static Double Asinh(Double f)
Summary: Returns the angle whose hyperbolic sine is the specified value.
Parameters:
f(Double):
Returns:
public static Double Acosh(Double f)
Summary: Returns the angle whose hyperbolic cosine is the specified value.
Parameters:
f(Double):
Returns:
public static Double Atanh(Double f)
Summary: Returns the angle whose hyperbolic tangent is the specified value.
Parameters:
f(Double):
Returns: