Version: Unity 6.5 Alpha (6000.5)
LanguageEnglish
  • C#

math.normalizesafe

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static float2 normalizesafe(float2 x, float2 defaultvalue);

Parameters

Parameter Description
x Vector to normalize.
defaultvalue Vector to return if normalized vector is not finite.

Returns

float2 The normalized vector or the default value if the normalized vector is not finite.

Description

Returns a safe normalized version of the float2 vector x by scaling it by 1 / length(x). Returns the given default value when 1 / length(x) does not produce a finite number.


Declaration

public static float3 normalizesafe(float3 x, float3 defaultvalue);

Parameters

Parameter Description
x Vector to normalize.
defaultvalue Vector to return if normalized vector is not finite.

Returns

float3 The normalized vector or the default value if the normalized vector is not finite.

Description

Returns a safe normalized version of the float3 vector x by scaling it by 1 / length(x). Returns the given default value when 1 / length(x) does not produce a finite number.


Declaration

public static float4 normalizesafe(float4 x, float4 defaultvalue);

Parameters

Parameter Description
x Vector to normalize.
defaultvalue Vector to return if normalized vector is not finite.

Returns

float4 The normalized vector or the default value if the normalized vector is not finite.

Description

Returns a safe normalized version of the float4 vector x by scaling it by 1 / length(x). Returns the given default value when 1 / length(x) does not produce a finite number.


Declaration

public static double2 normalizesafe(double2 x, double2 defaultvalue);

Parameters

Parameter Description
x Vector to normalize.
defaultvalue Vector to return if normalized vector is not finite.

Returns

double2 The normalized vector or the default value if the normalized vector is not finite.

Description

Returns a safe normalized version of the double4 vector x by scaling it by 1 / length(x). Returns the given default value when 1 / length(x) does not produce a finite number.


Declaration

public static double3 normalizesafe(double3 x, double3 defaultvalue);

Parameters

Parameter Description
x Vector to normalize.
defaultvalue Vector to return if normalized vector is not finite.

Returns

double3 The normalized vector or the default value if the normalized vector is not finite.

Description

Returns a safe normalized version of the double4 vector x by scaling it by 1 / length(x). Returns the given default value when 1 / length(x) does not produce a finite number.


Declaration

public static double4 normalizesafe(double4 x, double4 defaultvalue);

Parameters

Parameter Description
x Vector to normalize.
defaultvalue Vector to return if normalized vector is not finite.

Returns

double4 The normalized vector or the default value if the normalized vector is not finite.

Description

Returns a safe normalized version of the double4 vector x by scaling it by 1 / length(x). Returns the given default value when 1 / length(x) does not produce a finite number.


Declaration

public static quaternion normalizesafe(quaternion q);

Parameters

Parameter Description
q The quaternion to normalize.

Returns

quaternion The normalized quaternion or the identity quaternion.

Description

Returns a safe normalized version of the q by scaling it by 1 / length(q). Returns the identity when 1 / length(q) does not produce a finite number.


Declaration

public static quaternion normalizesafe(quaternion q, quaternion defaultvalue);

Parameters

Parameter Description
q The quaternion to normalize.
defaultvalue The default value.

Returns

quaternion The normalized quaternion or the default value.

Description

Returns a safe normalized version of the q by scaling it by 1 / length(q). Returns the given default value when 1 / length(q) does not produce a finite number.