float Length { get; set; }

robot_2Generated
code_blocksInput

Description

The Length property of the Vector2 struct returns the magnitude of the vector. The magnitude is a measure of the vector's length in 2D space, calculated as the square root of the sum of the squares of its components.

Usage

Use the Length property when you need to determine the distance of the vector from the origin in a 2D coordinate system. This property is useful in physics calculations, collision detection, and when normalizing vectors.

Example

Vector2 vector = new Vector2(3, 4);
float magnitude = vector.Length;
// magnitude will be 5, as the vector (3, 4) forms a 3-4-5 right triangle.