# vec2_length()

## Description

Returns the length of a Vec2 as a float.

#### Parameters

vec2_length(Vec2 vec)

• vec - (Vec2) The vector to find the length of.

## Example

```Vec2 vector1;
Vec2 vector2;

void init()
{
vector1 = vec2_set(randomRangeFloat(0.0f, 50.0f), randomRangeFloat(0.0f, 50.0f));
vector2 = vec2_set(randomRangeFloat(0.0f, 50.0f), randomRangeFloat(0.0f, 50.0f));
textFont(defaultFont, 30);
fill(color(0, 0, 0, 255));
}

void update()
{
// Print out the randomly generated vectors
char vec_text[128] = { 0 };
sprintf_s(vec_text, 128, "1st Vector: [%.2f, %.2f]", vector1.x, vector1.y);
text(vec_text, 0, 50);
sprintf_s(vec_text, 128, "2st Vector: [%.2f, %.2f]", vector2.x, vector2.y);
text(vec_text, 0, 100);

// Print out finding the angle with a function
float angle = vec2_angle(vector1, vector2);
sprintf_s(vec_text, 128, "Angle (Function): %.2f", angle);
text(vec_text, 0, 150);

// Manually figure out the angle of the two vectors
float dot = vec2_dot(vector1, vector2);
float length1 = vec2_length(vector1);
float length2 = vec2_length(vector2);
angle = degrees((float)acos((double)(dot/(length1*length2))));

// Print out the manual angle between the two vectors
sprintf_s(vec_text, 128, "Angle (Manual): %.2f", angle);
text(vec_text, 0, 200);

text("They are the same!", 0, 250);
}
```