# shz_vec3_normalize_or

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

```c
SHZ_INLINE shz_vec3_t shz_vec3_normalize_or(shz_vec3_t vec, shz_vec3_t alt) SHZ_NOEXCEPT;
```

Returns a normalized unit vector from the given 3D vector, or an alternate value.

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `vec` | `shz_vec3_t` | The vector to normalize. |
| `alt` | `shz_vec3_t` | The vector to return when `vec` cannot be normalized. |

## Returns

The unit vector pointing in the same direction as `vec`, or `alt`.

## Details

Safely returns `alt` when `vec` has a magnitude of `0.0f` and cannot be normalized.

## Availability

- **C++ equivalent:** [`shz::vec3::direction_or`](https://sh4zam.com/api/cpp/vec3/#direction_or), [`shz::vec3::normalize_or`](https://sh4zam.com/api/cpp/vec3/#normalize_or), [`shz::vec3::normalized_or`](https://sh4zam.com/api/cpp/vec3/#normalized_or)
- **Type-generic form:** [`shz_vec_normalize_or()`](https://sh4zam.com/api/vector/shz_vec_normalize_or/)
- **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation
- **Defined in:** [`sh4zam/shz_vector.h:692`](https://github.com/gyrovorbis/sh4zam/blob/6b22b851ad9ca109049f956dbbbecf7c519c959f/include/sh4zam/shz_vector.h#L692)
- **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude"

## See also

[`shz_vec3_normalize`](https://sh4zam.com/api/vector/shz_vec3_normalize/), [`shz_vec3_normalize_safe`](https://sh4zam.com/api/vector/shz_vec3_normalize_safe/)
