# shz_quat_normalize_or

Source: https://sh4zam.com/api/quat/shz_quat_normalize_or/

```c
SHZ_INLINE shz_quat_t shz_quat_normalize_or(shz_quat_t quat, shz_quat_t alt) SHZ_NOEXCEPT;
```

Returns the normalized form of the given quaternion, or an alternate value.

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `quat` | `shz_quat_t` | The quaternion to normalize. |
| `alt` | `shz_quat_t` | The quaternion to return when `quat` cannot be normalized. |

## Returns

The unit quaternion in the same direction as `quat`, or `alt`.

## Details

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

## Availability

- **C++ equivalent:** [`shz::quat::normalized_or`](https://sh4zam.com/api/cpp/quat/#normalized_or)
- **Type-generic form:** none
- **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation
- **Defined in:** [`sh4zam/shz_quat.h:331`](https://github.com/gyrovorbis/sh4zam/blob/6b22b851ad9ca109049f956dbbbecf7c519c959f/include/sh4zam/shz_quat.h#L331)
- **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Modifiers"

## See also

[`shz_quat_normalize`](https://sh4zam.com/api/quat/shz_quat_normalize/), [`shz_quat_normalize_safe`](https://sh4zam.com/api/quat/shz_quat_normalize_safe/)
