# shz_vec2_normalize_safe

Source: https://sh4zam.com/api/vector/shz_vec2_normalize_safe/

```c
SHZ_INLINE shz_vec2_t shz_vec2_normalize_safe(shz_vec2_t vec) SHZ_NOEXCEPT;
```

SAFELY returns a normalized unit vector from the given 2D vector.

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `vec` | `shz_vec2_t` |  |

## Returns

`shz_vec2_t`

## Details

If the vector's magnitude is not `> 0.0f`, safely returns a zero vector.

## Naming and requirements

- `_safe`: Guards degenerate input (zero-length vectors, zero denominators) at a small cost. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/))

## Availability

- **C++ equivalent:** [`shz::vec2::direction_safe`](https://sh4zam.com/api/cpp/vec2/#direction_safe), [`shz::vec2::normalize_safe`](https://sh4zam.com/api/cpp/vec2/#normalize_safe), [`shz::vec2::normalized_safe`](https://sh4zam.com/api/cpp/vec2/#normalized_safe)
- **Type-generic form:** [`shz_vec_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec_normalize_safe/)
- **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation
- **Defined in:** [`sh4zam/shz_vector.h:444`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L444)
- **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude"
