Skip to content

format

typescript
Vector3.sqrMagnitude

class: Vector3

description

(Read Only) The square magnitude of the current vector.

Returns the square magnitude of the vector. It is calculated by summing the squares of each component, without involving square root calculations. Because there is no square root operation, it is faster than magnitude. It is commonly used for comparing lengths without needing the exact length value.

parameter

param_nametypedescription

reture

typedescription
numberThe square magnitude of the current vector.

code example

typescript
let lhs = new Vector3(1,-2,-3);
Debug.Log("(1,-2,-3) sqrMagnitude is",lhs.sqrMagnitude);