Description
The LengthSquared
property of the Vector4
struct provides the squared length (or magnitude) of the vector. This is calculated as the sum of the squares of its components (x, y, z, w). It is often used in performance-sensitive code where the actual length is not required, as it avoids the computational cost of a square root operation.
Usage
Use the LengthSquared
property when you need to compare vector lengths or when the exact length is not necessary. This property is read-only and can be accessed directly from an instance of Vector4
.
Example
Vector4 vector = new Vector4(3, 4, 5, 6);
float squaredLength = vector.LengthSquared;
// squaredLength will be 86 (3*3 + 4*4 + 5*5 + 6*6)