float LengthSquared { get; set; }

robot_2Generated
code_blocksInput

Description

The LengthSquared property of the Vector4 struct provides the squared length of the vector. This is a computationally cheaper alternative to calculating the actual length, as it avoids the square root operation. It is useful in scenarios where only a relative comparison of vector lengths is needed, such as in performance-critical code.

Usage

To access the squared length of a Vector4 instance, simply use the LengthSquared property. This property is read-only and returns a float representing the squared length of the vector.

Example

Vector4 vector = new Vector4(3.0f, 4.0f, 0.0f, 0.0f);
float squaredLength = vector.LengthSquared;
// squaredLength will be 25.0f, as (3^2 + 4^2 + 0^2 + 0^2) = 25