# shz_vec4_normalize_or

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

```c
SHZ_INLINE shz_vec4_t shz_vec4_normalize_or(shz_vec4_t vec, shz_vec4_t alt) SHZ_NOEXCEPT;
```

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

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `vec` | `shz_vec4_t` | The vector to normalize. |
| `alt` | `shz_vec4_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::vec4::direction_or`](https://sh4zam.com/api/cpp/vec4/#direction_or), [`shz::vec4::normalize_or`](https://sh4zam.com/api/cpp/vec4/#normalize_or), [`shz::vec4::normalized_or`](https://sh4zam.com/api/cpp/vec4/#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:704`](https://github.com/gyrovorbis/sh4zam/blob/6b22b851ad9ca109049f956dbbbecf7c519c959f/include/sh4zam/shz_vector.h#L704)
- **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude"

## See also

[`shz_vec4_normalize`](https://sh4zam.com/api/vector/shz_vec4_normalize/), [`shz_vec4_normalize_safe`](https://sh4zam.com/api/vector/shz_vec4_normalize_safe/)
