Documentation

Unity Engine

Download Unity

Unity Engine

rsqrtsafe

Returns the reciprocal square root of a float value, or zero if the value isn't greater than epsilon.
Read time 4 minutesLast updated 5 days ago

Definition

rsqrtsafe(float, float)

Returns the reciprocal square root of a float value, or zero if the value isn't greater than epsilon.
public static float rsqrtsafe(float x, float epsilon = 1.1754944E-38)

Parameters

Value to use when computing reciprocal square root.

epsilon

Threshold value. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

floatThe reciprocal square root of the input, or zero.

Remarks

Unlike math.rsqrt, this function never divides by zero. Inputs that aren't greater than epsilon, including negative values and NaN, return zero.

rsqrtsafe(float2, float)

Returns the componentwise reciprocal square root of a float2 vector, or zero for each component that isn't greater than epsilon.
public static float2 rsqrtsafe(float2 x, float epsilon = 1.1754944E-38)

Parameters

Value to use when computing reciprocal square root.

epsilon

Threshold value. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float2The componentwise reciprocal square root of the input, or zero.

Remarks

Unlike math.rsqrt, this function never divides by zero. Components that aren't greater than epsilon, including negative values and NaN, return zero.

rsqrtsafe(float3, float)

Returns the componentwise reciprocal square root of a float3 vector, or zero for each component that isn't greater than epsilon.
public static float3 rsqrtsafe(float3 x, float epsilon = 1.1754944E-38)

Parameters

Value to use when computing reciprocal square root.

epsilon

Threshold value. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float3The componentwise reciprocal square root of the input, or zero.

Remarks

Unlike math.rsqrt, this function never divides by zero. Components that aren't greater than epsilon, including negative values and NaN, return zero.

rsqrtsafe(float4, float)

Returns the componentwise reciprocal square root of a float4 vector, or zero for each component that isn't greater than epsilon.
public static float4 rsqrtsafe(float4 x, float epsilon = 1.1754944E-38)

Parameters

Value to use when computing reciprocal square root.

epsilon

Threshold value. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float4The componentwise reciprocal square root of the input, or zero.

Remarks

Unlike math.rsqrt, this function never divides by zero. Components that aren't greater than epsilon, including negative values and NaN, return zero.

rsqrtsafe(double, double)

Returns the reciprocal square root of a double value, or zero if the value isn't greater than epsilon.
public static double rsqrtsafe(double x, double epsilon = 2.2250738585072014E-308)

Parameters

Value to use when computing reciprocal square root.

epsilon

Threshold value. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

doubleThe reciprocal square root of the input, or zero.

Remarks

Unlike math.rsqrt, this function never divides by zero. Inputs that aren't greater than epsilon, including negative values and NaN, return zero.

rsqrtsafe(double2, double)

Returns the componentwise reciprocal square root of a double2 vector, or zero for each component that isn't greater than epsilon.
public static double2 rsqrtsafe(double2 x, double epsilon = 2.2250738585072014E-308)

Parameters

Value to use when computing reciprocal square root.

epsilon

Threshold value. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double2The componentwise reciprocal square root of the input, or zero.

Remarks

Unlike math.rsqrt, this function never divides by zero. Components that aren't greater than epsilon, including negative values and NaN, return zero.

rsqrtsafe(double3, double)

Returns the componentwise reciprocal square root of a double3 vector, or zero for each component that isn't greater than epsilon.
public static double3 rsqrtsafe(double3 x, double epsilon = 2.2250738585072014E-308)

Parameters

Value to use when computing reciprocal square root.

epsilon

Threshold value. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double3The componentwise reciprocal square root of the input, or zero.

Remarks

Unlike math.rsqrt, this function never divides by zero. Components that aren't greater than epsilon, including negative values and NaN, return zero.

rsqrtsafe(double4, double)

Returns the componentwise reciprocal square root of a double4 vector, or zero for each component that isn't greater than epsilon.
public static double4 rsqrtsafe(double4 x, double epsilon = 2.2250738585072014E-308)

Parameters

Value to use when computing reciprocal square root.

epsilon

Threshold value. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double4The componentwise reciprocal square root of the input, or zero.

Remarks

Unlike math.rsqrt, this function never divides by zero. Components that aren't greater than epsilon, including negative values and NaN, return zero.