Documentation

Unity Engine

Download Unity

Unity Engine

rcpsafe

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

Definition

rcpsafe(float, float)

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

Parameters

Input value.

epsilon

Threshold magnitude. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

floatThe reciprocal of the input, or zero.

Remarks

Unlike math.rcp, this function never divides by zero. Inputs with a magnitude that isn't greater than epsilon, including NaN, return zero.

rcpsafe(float2, float)

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

Parameters

Input value.

epsilon

Threshold magnitude. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float2The componentwise reciprocal of the input, or zero.

Remarks

Unlike math.rcp, this function never divides by zero. Components with a magnitude that isn't greater than epsilon, including NaN, return zero.

rcpsafe(float3, float)

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

Parameters

Input value.

epsilon

Threshold magnitude. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float3The componentwise reciprocal of the input, or zero.

Remarks

Unlike math.rcp, this function never divides by zero. Components with a magnitude that isn't greater than epsilon, including NaN, return zero.

rcpsafe(float4, float)

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

Parameters

Input value.

epsilon

Threshold magnitude. Defaults to math.FLT_MIN_NORMAL.

Returns

Type

Description

float4The componentwise reciprocal of the input, or zero.

Remarks

Unlike math.rcp, this function never divides by zero. Components with a magnitude that isn't greater than epsilon, including NaN, return zero.

rcpsafe(double, double)

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

Parameters

Input value.

epsilon

Threshold magnitude. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

doubleThe reciprocal of the input, or zero.

Remarks

Unlike math.rcp, this function never divides by zero. Inputs with a magnitude that isn't greater than epsilon, including NaN, return zero.

rcpsafe(double2, double)

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

Parameters

Input value.

epsilon

Threshold magnitude. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double2The componentwise reciprocal of the input, or zero.

Remarks

Unlike math.rcp, this function never divides by zero. Components with a magnitude that isn't greater than epsilon, including NaN, return zero.

rcpsafe(double3, double)

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

Parameters

Input value.

epsilon

Threshold magnitude. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double3The componentwise reciprocal of the input, or zero.

Remarks

Unlike math.rcp, this function never divides by zero. Components with a magnitude that isn't greater than epsilon, including NaN, return zero.

rcpsafe(double4, double)

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

Parameters

Input value.

epsilon

Threshold magnitude. Defaults to math.DBL_MIN_NORMAL.

Returns

Type

Description

double4The componentwise reciprocal of the input, or zero.

Remarks

Unlike math.rcp, this function never divides by zero. Components with a magnitude that isn't greater than epsilon, including NaN, return zero.