# shz_vec2_project_safe

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

```c
SHZ_INLINE shz_vec2_t shz_vec2_project_safe(shz_vec2_t vec, shz_vec2_t onto) SHZ_NOEXCEPT;
```

Returns the resulting vector from projecting the given 2D vector along the given (unit) axis.

## Parameters

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

## Returns

`shz_vec2_t`

## Notes

- This routine should safely return the zero vector when `vec` has a magnitude of 0.0f.

## 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::project_safe`](https://sh4zam.com/api/cpp/vec2/#project_safe)
- **Type-generic form:** [`shz_vec_project_safe()`](https://sh4zam.com/api/vector/shz_vec_project_safe/)
- **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation
- **Defined in:** [`sh4zam/shz_vector.h:572`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L572)
- **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations"
