# SH4ZAM: API reference Source: https://sh4zam.com/ Generated from upstream commit ba1e30c88d49df0311870b229e1dd860ef26c477 (v0.9.1). Each section below is one page; its URL is on the line after its title. --- # API Reference Source: https://sh4zam.com/api/ > Every public SH4ZAM symbol, one page each, grouped by module SH4ZAM 0.9.1 exposes 794 public C symbols across 10 modules, plus a C++ API in `namespace shz`. Every symbol has its own page at `/api///` with a Markdown twin at `/api//.md`. | Module | Header | Symbols | Description | | --- | --- | --- | --- | | [Scalar](https://sh4zam.com/api/scalar/) | `sh4zam/shz_scalar.h` | 56 | Scalar functions and utilities, including faster replacements. | | [Trigonometry](https://sh4zam.com/api/trig/) | `sh4zam/shz_trig.h` | 51 | Trig functions and utilities built around the SH4 FSCA instruction. | | [Vector](https://sh4zam.com/api/vector/) | `sh4zam/shz_vector.h` | 229 | API for vector math: 2D, 3D and 4D vector types and operations. | | [Quaternion](https://sh4zam.com/api/quat/) | `sh4zam/shz_quat.h` | 47 | Routines for quaternion math. | | [Matrix](https://sh4zam.com/api/matrix/) | `sh4zam/shz_matrix.h` | 120 | In-memory matrix manipulation for 4x4 and smaller matrices. | | [XMTRX](https://sh4zam.com/api/xmtrx/) | `sh4zam/shz_xmtrx.h` | 140 | API for managing the SH4's "active matrix", the 16 back-bank FP registers. | | [Complex](https://sh4zam.com/api/complex/) | `sh4zam/shz_complex.h` | 52 | API for representing and operating on complex numbers, plus an SH4-optimized FFT. | | [Memory](https://sh4zam.com/api/memory/) | `sh4zam/shz_mem.h` | 23 | Routines for copying memory, store queues, cache operations and prefetching. | | [Compiler Definitions](https://sh4zam.com/api/cdefs/) | `sh4zam/shz_cdefs.h` | 67 | Preprocessor definitions: back-end and target detection, TLS model, utilities and aliasing types. | | [Version](https://sh4zam.com/api/version/) | `sh4zam/shz_version.h` | 9 | Compile-time and link-time version checking of the SH4ZAM library. | ## Other ways in - [C++ API](https://sh4zam.com/api/cpp/): `shz::vec3`, `shz::quat`, `shz::xmtrx` and the free-function aliases, mapped back to the C functions. - [Cheatsheet](https://sh4zam.com/cheatsheet/): the whole API on one page, signature plus one line each. - [`/api/index.json`](https://sh4zam.com/api/index.json): machine-readable symbol index ([schema](https://sh4zam.com/api/schema.json)). Per-module files live at `/api/.json`. - Search (top of every page) indexes symbol names and descriptions. ## Naming in one line C functions are `shz__[_]`, types are `shz__t`, C++ lives in `namespace shz` with the `shz_` prefix dropped. Suffixes such as `_fsrra`, `_safe`, `_deg` and `_unaligned` change behavior; see [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). --- # Compiler Definitions API Source: https://sh4zam.com/api/cdefs/ > Preprocessor definitions: back-end and target detection, TLS model, utilities and aliasing types This file contains commonly used preprocessor definitions used throughout the project: library-wide configuration defines, compiler detection, compiler attributes, the TLS model and conversion utilities. `SHZ_TARGET` is auto-detected from compiler macros, and `SHZ_BACKEND` selects the implementation: the SH4 back-end is chosen only when targeting SH4 in single-precision FPU mode, otherwise the portable software back-end is used. `SHZ_CONVERT()` performs a zero-cost conversion between layout-compatible types and is what the `_from()` and `_to()` adapters are built on. Upstream keeps the compiler attribute macros (`SHZ_INLINE`, `SHZ_FORCE_INLINE`, `SHZ_ALIGNAS`, ...) out of its reference; they appear here only when Doxygen exposes them. - **C header:** `#include ` - **C++ header:** `#include ` - **Symbols:** 67 ## Back-Ends List of architectures which SH4ZAM can auto-detect. | Symbol | Description | | --- | --- | | [`SHZ_SH4`](https://sh4zam.com/api/cdefs/SHZ_SH4/) | Back-end for the Dreamcast's SH4. | | [`SHZ_PPC`](https://sh4zam.com/api/cdefs/SHZ_PPC/) | Back-end for the Gamecube/Wii's Gekko PPC. | | [`SHZ_MIPS`](https://sh4zam.com/api/cdefs/SHZ_MIPS/) | Back-end for MIPS architectures. | | [`SHZ_ARM`](https://sh4zam.com/api/cdefs/SHZ_ARM/) | Back-end for ARM architectures. | | [`SHZ_X86_64`](https://sh4zam.com/api/cdefs/SHZ_X86_64/) | Back-end for x86_64 architectures. | | [`SHZ_SPU`](https://sh4zam.com/api/cdefs/SHZ_SPU/) | Back-end for the Cell B/E SPU architecture. | | [`SHZ_WASM`](https://sh4zam.com/api/cdefs/SHZ_WASM/) | Back-end for WebAssembly. | | [`SHZ_SW`](https://sh4zam.com/api/cdefs/SHZ_SW/) | Generic C-based software back-end. | ## TLS Models Defines for different mechanisms for thread-local storage. | Symbol | Description | | --- | --- | | [`SHZ_TLS_DISABLED`](https://sh4zam.com/api/cdefs/SHZ_TLS_DISABLED/) | No thread-local variables. | | [`SHZ_TLS_IMPLICIT`](https://sh4zam.com/api/cdefs/SHZ_TLS_IMPLICIT/) | Use `thread_local` keyword for TLS. | | [`SHZ_TLS_PTHREAD`](https://sh4zam.com/api/cdefs/SHZ_TLS_PTHREAD/) | Use pthread unique keys for TLS. | | [`SHZ_TLS_CTHREAD`](https://sh4zam.com/api/cdefs/SHZ_TLS_CTHREAD/) | Use C11 thread TSS keys for TLS. | ## Compiler Detection Defines for identifying the detected compiler. | Symbol | Description | | --- | --- | | [`SHZ_GNUC`](https://sh4zam.com/api/cdefs/SHZ_GNUC/) | Defined when building with a GCC-compatible compiler. | ## Utilities Miscellaneous function-like macros | Symbol | Description | | --- | --- | | [`SHZ_STRINGIFY_LITERAL`](https://sh4zam.com/api/cdefs/SHZ_STRINGIFY_LITERAL/) | Stringifies a literal expression. | | [`SHZ_STRINGIFY`](https://sh4zam.com/api/cdefs/SHZ_STRINGIFY/) | Stringifies an expression *after* preprocessing, supporting macro expansion. | | [`SHZ_COUNT_OF`](https://sh4zam.com/api/cdefs/SHZ_COUNT_OF/) | Returns the number of elements within a statically sized array. | | [`SHZ_CONTAINER_OF`](https://sh4zam.com/api/cdefs/SHZ_CONTAINER_OF/) | Returns the containing structure from a pointer to one of its members. | | [`SHZ_SWAP`](https://sh4zam.com/api/cdefs/SHZ_SWAP/) | Macro which swaps the two values held by `a` and `b`. | | [`SHZ_DECLARE_STRUCT`](https://sh4zam.com/api/cdefs/SHZ_DECLARE_STRUCT/) | Macro which forward declares a struct and its typedef. | | [`SHZ_DECLARE_STRUCT_ALIGNED`](https://sh4zam.com/api/cdefs/SHZ_DECLARE_STRUCT_ALIGNED/) | Macro which forward declares a manually aligned struct and its typedef. | ## TLS Utilities Macros for declaring and managing thread-local variables. | Symbol | Description | | --- | --- | | [`SHZ_TLS_DECL`](https://sh4zam.com/api/cdefs/SHZ_TLS_DECL/) | Declares a TLS variable with disabled model (so not thread-local). | | [`SHZ_TLS_REF`](https://sh4zam.com/api/cdefs/SHZ_TLS_REF/) | References a TLS variable, with disabled model. | ## Aliasing Types Types which may break C/C++'s strict aliasing rules | Symbol | Description | | --- | --- | | [`shz_alias_int16_t`](https://sh4zam.com/api/cdefs/shz_alias_int16_t/) | int16_t type whose value may be aliased as another type. | | [`shz_alias_uint16_t`](https://sh4zam.com/api/cdefs/shz_alias_uint16_t/) | uint16_t type whose value may be aliased as another type. | | [`shz_alias_int32_t`](https://sh4zam.com/api/cdefs/shz_alias_int32_t/) | int32_t type whose value may be aliased as another type. | | [`shz_alias_uint32_t`](https://sh4zam.com/api/cdefs/shz_alias_uint32_t/) | uint32_t type whose value may be aliased as another type. | | [`shz_alias_float_t`](https://sh4zam.com/api/cdefs/shz_alias_float_t/) | float type whose value may be aliased as another type. | | [`shz_alias_int64_t`](https://sh4zam.com/api/cdefs/shz_alias_int64_t/) | int64_t type whose value may be aliased as another type. | | [`shz_alias_uint64_t`](https://sh4zam.com/api/cdefs/shz_alias_uint64_t/) | uint64_t type whose value may be aliased as another type. | | [`shz_alias_double_t`](https://sh4zam.com/api/cdefs/shz_alias_double_t/) | double type whose value may be aliased as another type. | ## Macros | Symbol | Description | | --- | --- | | [`SHZ_TARGET`](https://sh4zam.com/api/cdefs/SHZ_TARGET/) | Target architecture Determines the actual architecture we're building for. | | [`SHZ_BACKEND`](https://sh4zam.com/api/cdefs/SHZ_BACKEND/) | SH4ZAM back-end Selects which SH4ZAM implementation to use for a given target. | | [`SHZ_TLS_MODEL`](https://sh4zam.com/api/cdefs/SHZ_TLS_MODEL/) | thread_local storage. | ## Not in upstream reference Public declarations that upstream keeps out of its Doxygen reference. Listed for completeness; prefer the documented API. | Symbol | Description | | --- | --- | | [`SHZ_MSVC`](https://sh4zam.com/api/cdefs/SHZ_MSVC/) | Defined when building with Microsoft Visual C++. | | [`SHZ_CLANG`](https://sh4zam.com/api/cdefs/SHZ_CLANG/) | Defined when bulding with Clang. | | [`SHZ_MINGW64`](https://sh4zam.com/api/cdefs/SHZ_MINGW64/) | Defined when bulding with MinGW-w64. | | [`SHZ_MINGW32`](https://sh4zam.com/api/cdefs/SHZ_MINGW32/) | Defined when building for 32-bit MinGW or other MinGW compiler(s). | | [`SHZ_GCC`](https://sh4zam.com/api/cdefs/SHZ_GCC/) | Defined when building for GCC. | | [`SHZ_ALIGNAS`](https://sh4zam.com/api/cdefs/SHZ_ALIGNAS/) | Forces a function or type to be aligned by `N` bytes. | | [`SHZ_SIMD`](https://sh4zam.com/api/cdefs/SHZ_SIMD/) | Tells GCC that a scalar type is to be treated as a vector of size `N.` | | [`SHZ_HOT`](https://sh4zam.com/api/cdefs/SHZ_HOT/) | Tells GCC that a particular function should be optimized for performance. | | [`SHZ_COLD`](https://sh4zam.com/api/cdefs/SHZ_COLD/) | Tells GCC that a particular function should be optimized for size. | | [`SHZ_FAST_MATH`](https://sh4zam.com/api/cdefs/SHZ_FAST_MATH/) | Put this before a function definition to tell GCC to use fast math optimizations on a specific function. | | [`SHZ_NO_FAST_MATH`](https://sh4zam.com/api/cdefs/SHZ_NO_FAST_MATH/) | Put this before a function definition to tell GCC to NOT use fast math optimizations on a specific function. | | [`SHZ_NO_UNROLL_LOOPS`](https://sh4zam.com/api/cdefs/SHZ_NO_UNROLL_LOOPS/) | Put this before a function definition to tell GCC to NOT unroll loops in a specific function. | | [`SHZ_NO_OPTIMIZATION`](https://sh4zam.com/api/cdefs/SHZ_NO_OPTIMIZATION/) | Tells GCC to disable any optimizations when compiling a function. | | [`SHZ_FUNC_ALIGNAS`](https://sh4zam.com/api/cdefs/SHZ_FUNC_ALIGNAS/) | Aligns a function within the .text segment by `N` bytes. | | [`SHZ_FORCE_INLINE`](https://sh4zam.com/api/cdefs/SHZ_FORCE_INLINE/) | Forces GCC to inline the given function. | | [`SHZ_NO_INLINE`](https://sh4zam.com/api/cdefs/SHZ_NO_INLINE/) | Prevents GCC from inlining the given function. | | [`SHZ_FLATTEN`](https://sh4zam.com/api/cdefs/SHZ_FLATTEN/) | Forces GCC to inline all calls to other functions made within the tagged function. | | [`SHZ_PACKED`](https://sh4zam.com/api/cdefs/SHZ_PACKED/) | Tells GCC not to introduce any extra padding for the given type. | | [`SHZ_PURE`](https://sh4zam.com/api/cdefs/SHZ_PURE/) | Tells GCC the function has no effects other than returning a value that depends on its arguments and global variables. | | [`SHZ_CONST`](https://sh4zam.com/api/cdefs/SHZ_CONST/) | Tells GCC the function has no effects other than returning a value that depends only on its arguments. | | [`SHZ_ALIASING`](https://sh4zam.com/api/cdefs/SHZ_ALIASING/) | Tells GCC that the decorated pointer may be breaking strict aliasing rules for C and C++ | | [`SHZ_DEPRECATED`](https://sh4zam.com/api/cdefs/SHZ_DEPRECATED/) | Emits a warning that a symbol has been deprecated with a message, upon use. | | [`SHZ_LIKELY`](https://sh4zam.com/api/cdefs/SHZ_LIKELY/) | Tells GCC that the expression is likely to be true (used for conditional and loop optimizations) | | [`SHZ_UNLIKELY`](https://sh4zam.com/api/cdefs/SHZ_UNLIKELY/) | Tells GCC that the expression is likely to be false (used for conditional and loop optimizations) | | [`SHZ_RESTRICT`](https://sh4zam.com/api/cdefs/SHZ_RESTRICT/) | Tells GCC the pointer paraemter is unique and is not aliased by another parameter | | [`SHZ_MEMORY_BARRIER_SOFT`](https://sh4zam.com/api/cdefs/SHZ_MEMORY_BARRIER_SOFT/) | Creates a software memory barrier beyond which any loads or stores may not be reordered | | [`SHZ_MEMORY_BARRIER_HARD`](https://sh4zam.com/api/cdefs/SHZ_MEMORY_BARRIER_HARD/) | Creates a hardware memory barrier beyond which any loads or stores may not be reordered | | [`SHZ_INSTR_BARRIER`](https://sh4zam.com/api/cdefs/SHZ_INSTR_BARRIER/) | Prevents the compiler from reordering instructions beyond the barrier. | | [`SHZ_DECLS_BEGIN`](https://sh4zam.com/api/cdefs/SHZ_DECLS_BEGIN/) | Dummy define provided for C++ compatibility | | [`SHZ_DECLS_END`](https://sh4zam.com/api/cdefs/SHZ_DECLS_END/) | Dummy define provided for C++ compatibility | | [`SHZ_INLINE`](https://sh4zam.com/api/cdefs/SHZ_INLINE/) | Requests a function or member to be inlined (nonforcibly) OR to have static linkage. | | [`SHZ_NOEXCEPT`](https://sh4zam.com/api/cdefs/SHZ_NOEXCEPT/) | Dummy define provided for C++ compatibility | | [`SHZ_INIT`](https://sh4zam.com/api/cdefs/SHZ_INIT/) | Temporary struct initialization statement to use within C. | | [`SHZ_CONVERT`](https://sh4zam.com/api/cdefs/SHZ_CONVERT/) | Conversion macro for zero-overhead conversions, taking the given `value` to a value of the given `type.` | --- # shz_alias_double_t Source: https://sh4zam.com/api/cdefs/shz_alias_double_t/ ```c typedef SHZ_ALIASING double shz_alias_double_t; ``` double type whose value may be aliased as another type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:402`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L402) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Aliasing Types" --- # shz_alias_float_t Source: https://sh4zam.com/api/cdefs/shz_alias_float_t/ ```c typedef SHZ_ALIASING float shz_alias_float_t; ``` float type whose value may be aliased as another type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:396`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L396) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Aliasing Types" --- # shz_alias_int16_t Source: https://sh4zam.com/api/cdefs/shz_alias_int16_t/ ```c typedef SHZ_ALIASING int16_t shz_alias_int16_t; ``` int16_t type whose value may be aliased as another type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:388`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L388) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Aliasing Types" --- # shz_alias_int32_t Source: https://sh4zam.com/api/cdefs/shz_alias_int32_t/ ```c typedef SHZ_ALIASING int32_t shz_alias_int32_t; ``` int32_t type whose value may be aliased as another type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:392`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L392) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Aliasing Types" --- # shz_alias_int64_t Source: https://sh4zam.com/api/cdefs/shz_alias_int64_t/ ```c typedef SHZ_ALIASING int64_t shz_alias_int64_t; ``` int64_t type whose value may be aliased as another type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:398`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L398) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Aliasing Types" --- # shz_alias_uint16_t Source: https://sh4zam.com/api/cdefs/shz_alias_uint16_t/ ```c typedef SHZ_ALIASING uint16_t shz_alias_uint16_t; ``` uint16_t type whose value may be aliased as another type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:390`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L390) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Aliasing Types" --- # shz_alias_uint32_t Source: https://sh4zam.com/api/cdefs/shz_alias_uint32_t/ ```c typedef SHZ_ALIASING uint32_t shz_alias_uint32_t; ``` uint32_t type whose value may be aliased as another type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:394`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L394) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Aliasing Types" --- # shz_alias_uint64_t Source: https://sh4zam.com/api/cdefs/shz_alias_uint64_t/ ```c typedef SHZ_ALIASING uint64_t shz_alias_uint64_t; ``` uint64_t type whose value may be aliased as another type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:400`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L400) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Aliasing Types" --- # SHZ_ALIASING Source: https://sh4zam.com/api/cdefs/SHZ_ALIASING/ ```c #define SHZ_ALIASING __attribute__((__may_alias__)) ``` Tells GCC that the decorated pointer may be breaking strict aliasing rules for C and C++ ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:181`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L181) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_ALIGNAS Source: https://sh4zam.com/api/cdefs/SHZ_ALIGNAS/ > Forces a function or type to be aligned by N bytes ```c #define SHZ_ALIGNAS(N) __attribute__((aligned((N)))) ``` Forces a function or type to be aligned by `N` bytes. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:151`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L151) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_ARM Source: https://sh4zam.com/api/cdefs/SHZ_ARM/ ```c #define SHZ_ARM 4 ``` Back-end for ARM architectures. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:33`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L33) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Back-Ends" --- # SHZ_BACKEND Source: https://sh4zam.com/api/cdefs/SHZ_BACKEND/ ```c #define SHZ_BACKEND SHZ_SPU ``` SH4ZAM back-end Selects which SH4ZAM implementation to use for a given target. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:72`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L72) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Macros" --- # SHZ_CLANG Source: https://sh4zam.com/api/cdefs/SHZ_CLANG/ ```c #define SHZ_CLANG 1 ``` Defined when bulding with Clang. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:111`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L111) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_COLD Source: https://sh4zam.com/api/cdefs/SHZ_COLD/ ```c #define SHZ_COLD __attribute__((cold)) ``` Tells GCC that a particular function should be optimized for size. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:157`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L157) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_CONST Source: https://sh4zam.com/api/cdefs/SHZ_CONST/ ```c #define SHZ_CONST __attribute__((const)) ``` Tells GCC the function has no effects other than returning a value that depends only on its arguments. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:179`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L179) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_CONTAINER_OF Source: https://sh4zam.com/api/cdefs/SHZ_CONTAINER_OF/ ```c #define SHZ_CONTAINER_OF(ptr, type, member) ((type*)((char*)(ptr) - offsetof(type, member))) ``` Returns the containing structure from a pointer to one of its members. ## Parameters | Name | Type | Description | | --- | --- | --- | | `ptr` | | | | `type` | | | | `member` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:135`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L135) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Utilities" --- # SHZ_CONVERT Source: https://sh4zam.com/api/cdefs/SHZ_CONVERT/ > Conversion macro for zero-overhead conversions, taking the given value to a value of the given type ```c #define SHZ_CONVERT(type, value) ``` Conversion macro for zero-overhead conversions, taking the given `value` to a value of the given `type.` ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:261`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L261) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_COUNT_OF Source: https://sh4zam.com/api/cdefs/SHZ_COUNT_OF/ ```c #define SHZ_COUNT_OF(array) (sizeof(array) / sizeof((array)[0])) ``` Returns the number of elements within a statically sized array. ## Parameters | Name | Type | Description | | --- | --- | --- | | `array` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:133`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L133) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Utilities" --- # SHZ_DECLARE_STRUCT_ALIGNED Source: https://sh4zam.com/api/cdefs/SHZ_DECLARE_STRUCT_ALIGNED/ ```c #define SHZ_DECLARE_STRUCT_ALIGNED(n, t, a) struct SHZ_ALIGNAS(a) n; typedef struct n t ``` Macro which forward declares a manually aligned struct and its typedef. ## Parameters | Name | Type | Description | | --- | --- | --- | | `n` | | | | `t` | | | | `a` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:141`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L141) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Utilities" --- # SHZ_DECLARE_STRUCT Source: https://sh4zam.com/api/cdefs/SHZ_DECLARE_STRUCT/ ```c #define SHZ_DECLARE_STRUCT(n, t) struct n; typedef struct n t ``` Macro which forward declares a struct and its typedef. ## Parameters | Name | Type | Description | | --- | --- | --- | | `n` | | | | `t` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:139`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L139) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Utilities" --- # SHZ_DECLS_BEGIN Source: https://sh4zam.com/api/cdefs/SHZ_DECLS_BEGIN/ ```c #define SHZ_DECLS_BEGIN ``` Dummy define provided for C++ compatibility ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:247`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L247) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_DECLS_END Source: https://sh4zam.com/api/cdefs/SHZ_DECLS_END/ ```c #define SHZ_DECLS_END ``` Dummy define provided for C++ compatibility ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:249`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L249) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_DEPRECATED Source: https://sh4zam.com/api/cdefs/SHZ_DEPRECATED/ ```c #define SHZ_DEPRECATED(m) __attribute__((deprecated(m))) ``` Emits a warning that a symbol has been deprecated with a message, upon use. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:183`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L183) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_FAST_MATH Source: https://sh4zam.com/api/cdefs/SHZ_FAST_MATH/ ```c #define SHZ_FAST_MATH __attribute__((optimize("fast-math"))) ``` Put this before a function definition to tell GCC to use fast math optimizations on a specific function. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:159`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L159) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_FLATTEN Source: https://sh4zam.com/api/cdefs/SHZ_FLATTEN/ ```c #define SHZ_FLATTEN __attribute__((flatten)) ``` Forces GCC to inline all calls to other functions made within the tagged function. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:173`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L173) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_FORCE_INLINE Source: https://sh4zam.com/api/cdefs/SHZ_FORCE_INLINE/ ```c #define SHZ_FORCE_INLINE __attribute__((always_inline)) SHZ_INLINE ``` Forces GCC to inline the given function. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:169`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L169) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_FUNC_ALIGNAS Source: https://sh4zam.com/api/cdefs/SHZ_FUNC_ALIGNAS/ > Aligns a function within the .text segment by N bytes ```c #define SHZ_FUNC_ALIGNAS(N) __attribute__((aligned(N))) ``` Aligns a function within the .text segment by `N` bytes. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:167`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L167) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_GCC Source: https://sh4zam.com/api/cdefs/SHZ_GCC/ ```c #define SHZ_GCC 1 ``` Defined when building for GCC. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:117`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L117) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_GNUC Source: https://sh4zam.com/api/cdefs/SHZ_GNUC/ ```c #define SHZ_GNUC 1 ``` Defined when building with a GCC-compatible compiler. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:120`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L120) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Compiler Detection" --- # SHZ_HOT Source: https://sh4zam.com/api/cdefs/SHZ_HOT/ ```c #define SHZ_HOT __attribute__((hot)) ``` Tells GCC that a particular function should be optimized for performance. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:155`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L155) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_INIT Source: https://sh4zam.com/api/cdefs/SHZ_INIT/ ```c #define SHZ_INIT(type, ...) ((type){ __VA_ARGS__ }) ``` Temporary struct initialization statement to use within C. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:256`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L256) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_INLINE Source: https://sh4zam.com/api/cdefs/SHZ_INLINE/ ```c #define SHZ_INLINE inline static ``` Requests a function or member to be inlined (nonforcibly) OR to have static linkage. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:251`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L251) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_INSTR_BARRIER Source: https://sh4zam.com/api/cdefs/SHZ_INSTR_BARRIER/ ```c #define SHZ_INSTR_BARRIER() asm volatile("") ``` Prevents the compiler from reordering instructions beyond the barrier. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:195`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L195) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_LIKELY Source: https://sh4zam.com/api/cdefs/SHZ_LIKELY/ ```c #define SHZ_LIKELY(e) __builtin_expect(!!(e), 1) ``` Tells GCC that the expression is likely to be true (used for conditional and loop optimizations) ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:185`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L185) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_MEMORY_BARRIER_HARD Source: https://sh4zam.com/api/cdefs/SHZ_MEMORY_BARRIER_HARD/ ```c #define SHZ_MEMORY_BARRIER_HARD() __sync_synchronize() ``` Creates a hardware memory barrier beyond which any loads or stores may not be reordered ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:193`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L193) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_MEMORY_BARRIER_SOFT Source: https://sh4zam.com/api/cdefs/SHZ_MEMORY_BARRIER_SOFT/ ```c #define SHZ_MEMORY_BARRIER_SOFT() asm volatile("" : : : "memory") ``` Creates a software memory barrier beyond which any loads or stores may not be reordered ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:191`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L191) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_MINGW32 Source: https://sh4zam.com/api/cdefs/SHZ_MINGW32/ ```c #define SHZ_MINGW32 1 ``` Defined when building for 32-bit MinGW or other MinGW compiler(s). ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:115`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L115) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_MINGW64 Source: https://sh4zam.com/api/cdefs/SHZ_MINGW64/ ```c #define SHZ_MINGW64 1 ``` Defined when bulding with MinGW-w64. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:113`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L113) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_MIPS Source: https://sh4zam.com/api/cdefs/SHZ_MIPS/ ```c #define SHZ_MIPS 3 ``` Back-end for MIPS architectures. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:32`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L32) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Back-Ends" --- # SHZ_MSVC Source: https://sh4zam.com/api/cdefs/SHZ_MSVC/ ```c #define SHZ_MSVC 1 ``` Defined when building with Microsoft Visual C++. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:107`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L107) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_NO_FAST_MATH Source: https://sh4zam.com/api/cdefs/SHZ_NO_FAST_MATH/ ```c #define SHZ_NO_FAST_MATH __attribute__((optimize("no-fast-math"))) ``` Put this before a function definition to tell GCC to NOT use fast math optimizations on a specific function. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:161`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L161) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_NO_INLINE Source: https://sh4zam.com/api/cdefs/SHZ_NO_INLINE/ ```c #define SHZ_NO_INLINE __attribute__((noinline)) ``` Prevents GCC from inlining the given function. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:171`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L171) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_NO_OPTIMIZATION Source: https://sh4zam.com/api/cdefs/SHZ_NO_OPTIMIZATION/ ```c #define SHZ_NO_OPTIMIZATION __attribute__((optimize("O0"))) ``` Tells GCC to disable any optimizations when compiling a function. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:165`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L165) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_NO_UNROLL_LOOPS Source: https://sh4zam.com/api/cdefs/SHZ_NO_UNROLL_LOOPS/ ```c #define SHZ_NO_UNROLL_LOOPS __attribute__((optimize("no-unroll-loops"))) ``` Put this before a function definition to tell GCC to NOT unroll loops in a specific function. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:163`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L163) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_NOEXCEPT Source: https://sh4zam.com/api/cdefs/SHZ_NOEXCEPT/ ```c #define SHZ_NOEXCEPT ``` Dummy define provided for C++ compatibility ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:253`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L253) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_PACKED Source: https://sh4zam.com/api/cdefs/SHZ_PACKED/ ```c #define SHZ_PACKED __attribute__((packed)) ``` Tells GCC not to introduce any extra padding for the given type. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:175`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L175) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_PPC Source: https://sh4zam.com/api/cdefs/SHZ_PPC/ ```c #define SHZ_PPC 2 ``` Back-end for the Gamecube/Wii's Gekko PPC. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:31`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L31) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Back-Ends" --- # SHZ_PURE Source: https://sh4zam.com/api/cdefs/SHZ_PURE/ ```c #define SHZ_PURE __attribute__((pure)) ``` Tells GCC the function has no effects other than returning a value that depends on its arguments and global variables. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:177`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L177) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_RESTRICT Source: https://sh4zam.com/api/cdefs/SHZ_RESTRICT/ ```c #define SHZ_RESTRICT __restrict__ ``` Tells GCC the pointer paraemter is unique and is not aliased by another parameter ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:189`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L189) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_SH4 Source: https://sh4zam.com/api/cdefs/SHZ_SH4/ ```c #define SHZ_SH4 1 ``` Back-end for the Dreamcast's SH4. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:30`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L30) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Back-Ends" --- # SHZ_SIMD Source: https://sh4zam.com/api/cdefs/SHZ_SIMD/ > Tells GCC that a scalar type is to be treated as a vector of size N ```c #define SHZ_SIMD(N) __attribute__((vector_size((N)))) ``` Tells GCC that a scalar type is to be treated as a vector of size `N.` ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:153`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L153) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_SPU Source: https://sh4zam.com/api/cdefs/SHZ_SPU/ ```c #define SHZ_SPU 6 ``` Back-end for the Cell B/E SPU architecture. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:35`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L35) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Back-Ends" --- # SHZ_STRINGIFY_LITERAL Source: https://sh4zam.com/api/cdefs/SHZ_STRINGIFY_LITERAL/ ```c #define SHZ_STRINGIFY_LITERAL(a) #a ``` Stringifies a literal expression. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:129`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L129) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Utilities" --- # SHZ_STRINGIFY Source: https://sh4zam.com/api/cdefs/SHZ_STRINGIFY/ > Stringifies an expression after preprocessing, supporting macro expansion ```c #define SHZ_STRINGIFY(a) SHZ_STRINGIFY_LITERAL(a) ``` Stringifies an expression *after* preprocessing, supporting macro expansion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:131`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L131) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Utilities" --- # SHZ_SW Source: https://sh4zam.com/api/cdefs/SHZ_SW/ ```c #define SHZ_SW ~0 ``` Generic C-based software back-end. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:37`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L37) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Back-Ends" --- # SHZ_SWAP Source: https://sh4zam.com/api/cdefs/SHZ_SWAP/ > Macro which swaps the two values held by a and b ```c #define SHZ_SWAP(a, b) do { typeof(a) tmp = a; a = b; b = tmp; } while(false) ``` Macro which swaps the two values held by `a` and `b`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | | | | `b` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:137`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L137) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Utilities" --- # SHZ_TARGET Source: https://sh4zam.com/api/cdefs/SHZ_TARGET/ ```c #define SHZ_TARGET SHZ_SW ``` Target architecture Determines the actual architecture we're building for. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:60`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L60) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Macros" --- # SHZ_TLS_CTHREAD Source: https://sh4zam.com/api/cdefs/SHZ_TLS_CTHREAD/ ```c #define SHZ_TLS_CTHREAD 3 ``` Use C11 thread TSS keys for TLS. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:85`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L85) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "TLS Models" --- # SHZ_TLS_DECL Source: https://sh4zam.com/api/cdefs/SHZ_TLS_DECL/ ```c #define SHZ_TLS_DECL(type, name, ...) static type name = __VA_ARGS__; ``` Declares a TLS variable with disabled model (so not thread-local). ## Parameters | Name | Type | Description | | --- | --- | --- | | `type` | | | | `name` | | | | `...` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:313`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L313) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "TLS Utilities" --- # SHZ_TLS_DISABLED Source: https://sh4zam.com/api/cdefs/SHZ_TLS_DISABLED/ ```c #define SHZ_TLS_DISABLED 0 ``` No thread-local variables. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:82`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L82) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "TLS Models" --- # SHZ_TLS_IMPLICIT Source: https://sh4zam.com/api/cdefs/SHZ_TLS_IMPLICIT/ > Use thread_local keyword for TLS ```c #define SHZ_TLS_IMPLICIT 1 ``` Use `thread_local` keyword for TLS. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:83`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L83) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "TLS Models" --- # SHZ_TLS_MODEL Source: https://sh4zam.com/api/cdefs/SHZ_TLS_MODEL/ ```c #define SHZ_TLS_MODEL SHZ_TLS_IMPLICIT ``` thread_local storage. ## Details Selects the model used to declare access thread-local variables. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:94`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L94) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Macros" --- # SHZ_TLS_PTHREAD Source: https://sh4zam.com/api/cdefs/SHZ_TLS_PTHREAD/ ```c #define SHZ_TLS_PTHREAD 2 ``` Use pthread unique keys for TLS. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:84`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L84) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "TLS Models" --- # SHZ_TLS_REF Source: https://sh4zam.com/api/cdefs/SHZ_TLS_REF/ ```c #define SHZ_TLS_REF(name) (&name) ``` References a TLS variable, with disabled model. ## Parameters | Name | Type | Description | | --- | --- | --- | | `name` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:315`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L315) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "TLS Utilities" --- # SHZ_UNLIKELY Source: https://sh4zam.com/api/cdefs/SHZ_UNLIKELY/ ```c #define SHZ_UNLIKELY(e) __builtin_expect(!!(e), 0) ``` Tells GCC that the expression is likely to be false (used for conditional and loop optimizations) ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:187`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L187) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Not in upstream reference" --- # SHZ_WASM Source: https://sh4zam.com/api/cdefs/SHZ_WASM/ ```c #define SHZ_WASM 8 ``` Back-end for WebAssembly. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:36`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L36) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Back-Ends" --- # SHZ_X86_64 Source: https://sh4zam.com/api/cdefs/SHZ_X86_64/ ```c #define SHZ_X86_64 5 ``` Back-end for x86_64 architectures. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_cdefs.h:34`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_cdefs.h#L34) - **Module:** [Compiler Definitions](https://sh4zam.com/api/cdefs/), section "Back-Ends" --- # Complex API Source: https://sh4zam.com/api/complex/ > API for representing and operating on complex numbers, plus an SH4-optimized FFT The complex number API serves as a replacement for C and C++'s ``, offering fast, accelerated approximations for each routine. The API is mostly modeled after C99's ``, although it also supports being used from C++ via `shz::complex`. The API also features `shz_fft()`, an SH4 optimized fast-fourier transform. - **C header:** `#include ` - **C++ header:** `#include ` - **C++ types:** [`shz::complex`](https://sh4zam.com/api/cpp/complex/) - **Symbols:** 52 ## Suffixes Suffixes used in this module. The full list is in [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ## Preprocessor Macros and preprocessor constants. | Symbol | Description | | --- | --- | | [`SHZ_CMPLXF`](https://sh4zam.com/api/complex/SHZ_CMPLXF/) | Initializes a complex number. | | [`SHZ_CMPLXF32`](https://sh4zam.com/api/complex/SHZ_CMPLXF32/) | Initializes a complex number. | | [`SHZ_I`](https://sh4zam.com/api/complex/SHZ_I/) | Unit imaginary constant, 'I'. | ## Basic Basic operations on complex numbers. | Symbol | Description | | --- | --- | | [`shz_cinitf`](https://sh4zam.com/api/complex/shz_cinitf/) | Returns a complex number which has been initialized to contain the given component values. | | [`shz_cpolarf`](https://sh4zam.com/api/complex/shz_cpolarf/) | Returns a complex number with a magnitude of `r`, and a phase angle of `theta` (in radians). | | [`shz_cequalf`](https://sh4zam.com/api/complex/shz_cequalf/) | Checks for equality between two complex numbers with either an absolute or relative tolerance. | | [`shz_crealf`](https://sh4zam.com/api/complex/shz_crealf/) | Returns the real component of a complex number. | | [`shz_cimagf`](https://sh4zam.com/api/complex/shz_cimagf/) | Returns the imaginary component of a complex number. | ## Arithmetic Arithmetic operations on complex numbers. | Symbol | Description | | --- | --- | | [`shz_caddf`](https://sh4zam.com/api/complex/shz_caddf/) | Adds two complex numbers together and returns the result. | | [`shz_csubf`](https://sh4zam.com/api/complex/shz_csubf/) | Subtracts `rhs` from `lhs` and returns the complex result. | | [`shz_cmulf`](https://sh4zam.com/api/complex/shz_cmulf/) | Multiplies two complex numbers together, returning the complex result. | | [`shz_cdivf`](https://sh4zam.com/api/complex/shz_cdivf/) | Divides `lhs` by `rhs`, returning the complex result. | | [`shz_cscalef`](https://sh4zam.com/api/complex/shz_cscalef/) | Scales both componets of the complex number, `c`, by the value, `v`, returning the result. | | [`shz_crecipf`](https://sh4zam.com/api/complex/shz_crecipf/) | Returns the multiplicative inverse or reciprocal of the complex number, `c`. | ## Manipulation Extract or modify complex components. | Symbol | Description | | --- | --- | | [`shz_cabsf`](https://sh4zam.com/api/complex/shz_cabsf/) | Returns the absolute value (or magnitude) of the complex number, `c`. | | [`shz_inv_cabsf`](https://sh4zam.com/api/complex/shz_inv_cabsf/) | Returns the inverse of the absolute value (or inverse of the magnitude) of the complex number, `c`. | | [`shz_cnormf`](https://sh4zam.com/api/complex/shz_cnormf/) | Returns the squared magnitude of the complex number, `c`. | | [`shz_cargf`](https://sh4zam.com/api/complex/shz_cargf/) | Returns the phase angle of the complex number, `c`. | | [`shz_conjf`](https://sh4zam.com/api/complex/shz_conjf/) | Returns the complex conjugate of `c`. | | [`shz_cprojf`](https://sh4zam.com/api/complex/shz_cprojf/) | Calculates the projection of the complex number, `c`, onto the Riemann sphere. | ## Transcendental Complex transcendental functions. | Symbol | Description | | --- | --- | | [`shz_csqrtf`](https://sh4zam.com/api/complex/shz_csqrtf/) | Computes and returns the complex square root of `c`. | | [`shz_cpowf`](https://sh4zam.com/api/complex/shz_cpowf/) | Raises the complex `base` to the complex `exp` power, returning a complex result. | | [`shz_cexpf`](https://sh4zam.com/api/complex/shz_cexpf/) | Returns the complex base `e` exponential of `c`. | | [`shz_clogf`](https://sh4zam.com/api/complex/shz_clogf/) | Computes and returns the complex natural logarithm of `c`. | | [`shz_clog10f`](https://sh4zam.com/api/complex/shz_clog10f/) | Computes and returns the complex base 10 logarithm of `c`. | ## Spherical Trigonometry Complex spherical trigonometric functions. | Symbol | Description | | --- | --- | | [`shz_csinf`](https://sh4zam.com/api/complex/shz_csinf/) | Calculates and returns the complex sine of `c`. | | [`shz_ccosf`](https://sh4zam.com/api/complex/shz_ccosf/) | Calculates and returns the complex cosine of `c`. | | [`shz_ctanf`](https://sh4zam.com/api/complex/shz_ctanf/) | Calculates and returns the complex tangent of `c`. | | [`shz_ccscf`](https://sh4zam.com/api/complex/shz_ccscf/) | Calculates and returns the complex cosecant of `c`. | | [`shz_csecf`](https://sh4zam.com/api/complex/shz_csecf/) | Calculates and returns the complex secant of `c`. | | [`shz_ccotf`](https://sh4zam.com/api/complex/shz_ccotf/) | Calculates and returns the complex cotangent of `c`. | | [`shz_casinf`](https://sh4zam.com/api/complex/shz_casinf/) | Calculates and returns the complex arcsine of `c`. | | [`shz_cacosf`](https://sh4zam.com/api/complex/shz_cacosf/) | Calculates and returns the complex arccosine of `c`. | | [`shz_catanf`](https://sh4zam.com/api/complex/shz_catanf/) | Calculates and returns the complex arctangent of `c`. | | [`shz_cacscf`](https://sh4zam.com/api/complex/shz_cacscf/) | Calculates and returns the complex arccosecant of `c`. | | [`shz_casecf`](https://sh4zam.com/api/complex/shz_casecf/) | Calculates and returns the complex arcsecant of `c`. | | [`shz_cacotf`](https://sh4zam.com/api/complex/shz_cacotf/) | Calculates and returns the complex arccotangent of `c`. | ## Hyperbolic Trigonometry Complex hyperbolic trigonometric functions. | Symbol | Description | | --- | --- | | [`shz_csinhf`](https://sh4zam.com/api/complex/shz_csinhf/) | Calculates and returns the complex hyperbolic sine of `c`. | | [`shz_ccoshf`](https://sh4zam.com/api/complex/shz_ccoshf/) | Calculates and returns the complex hyperbolic cosine of `c`. | | [`shz_ctanhf`](https://sh4zam.com/api/complex/shz_ctanhf/) | Calculates and returns the complex hyperbolic tangent of `c`. | | [`shz_ccschf`](https://sh4zam.com/api/complex/shz_ccschf/) | Calculates and returns the complex hyperbolic cosecant of `c`. | | [`shz_csechf`](https://sh4zam.com/api/complex/shz_csechf/) | Calculates and returns the complex hyperbolic secant of `c`. | | [`shz_ccothf`](https://sh4zam.com/api/complex/shz_ccothf/) | Calculates and returns the complex hyperbolic cotangent of `c`. | | [`shz_casinhf`](https://sh4zam.com/api/complex/shz_casinhf/) | Calculates and returns the complex hyperbolic arcsine of `c`. | | [`shz_cacoshf`](https://sh4zam.com/api/complex/shz_cacoshf/) | Calculates and returns the complex hyperbolic arccosine of `c`. | | [`shz_catanhf`](https://sh4zam.com/api/complex/shz_catanhf/) | Calculates and returns the complex hyperbolic arctangent of `c`. | | [`shz_cacschf`](https://sh4zam.com/api/complex/shz_cacschf/) | Calculates and returns the complex hyperbolic arccosecant of `c`. | | [`shz_casechf`](https://sh4zam.com/api/complex/shz_casechf/) | Calculates and returns the complex hyperbolic arcsecant of `c`. | | [`shz_cacothf`](https://sh4zam.com/api/complex/shz_cacothf/) | Calculates and returns the complex hyperbolic arccotangent of `c`. | ## Signal Processing Functions for processing complex signals. | Symbol | Description | | --- | --- | | [`shz_fft`](https://sh4zam.com/api/complex/shz_fft/) | Fast Fourier Transform. | ## Types | Symbol | Description | | --- | --- | | [`shz_complex_t`](https://sh4zam.com/api/complex/shz_complex_t/) | Represents a floating-point complex number real/imaginary pair. | | [`shz_complex`](https://sh4zam.com/api/complex/shz_complex/) | [`shz_complex_t`](https://sh4zam.com/api/complex/shz_complex_t/) alias for those who don't like POSIX-style. | --- # shz_cabsf Source: https://sh4zam.com/api/complex/shz_cabsf/ > Returns the absolute value (or magnitude) of the complex number, c ```c SHZ_INLINE float shz_cabsf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the absolute value (or magnitude) of the complex number, `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cabsf`](https://sh4zam.com/api/cpp/#shzcabsf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:108`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L108) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Manipulation" --- # shz_cacosf Source: https://sh4zam.com/api/complex/shz_cacosf/ > Calculates and returns the complex arccosine of c ```c SHZ_INLINE shz_complex_t shz_cacosf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex arccosine of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cacosf`](https://sh4zam.com/api/cpp/#shzcacosf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:176`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L176) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_cacoshf Source: https://sh4zam.com/api/complex/shz_cacoshf/ > Calculates and returns the complex hyperbolic arccosine of c ```c SHZ_INLINE shz_complex_t shz_cacoshf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic arccosine of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cacoshf`](https://sh4zam.com/api/cpp/#shzcacoshf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:219`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L219) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_cacotf Source: https://sh4zam.com/api/complex/shz_cacotf/ > Calculates and returns the complex arccotangent of c ```c SHZ_INLINE shz_complex_t shz_cacotf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex arccotangent of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cacotf`](https://sh4zam.com/api/cpp/#shzcacotf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:188`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L188) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_cacothf Source: https://sh4zam.com/api/complex/shz_cacothf/ > Calculates and returns the complex hyperbolic arccotangent of c ```c SHZ_INLINE shz_complex_t shz_cacothf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic arccotangent of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cacothf`](https://sh4zam.com/api/cpp/#shzcacothf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:231`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L231) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_cacscf Source: https://sh4zam.com/api/complex/shz_cacscf/ > Calculates and returns the complex arccosecant of c ```c SHZ_INLINE shz_complex_t shz_cacscf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex arccosecant of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cacscf`](https://sh4zam.com/api/cpp/#shzcacscf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:182`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L182) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_cacschf Source: https://sh4zam.com/api/complex/shz_cacschf/ > Calculates and returns the complex hyperbolic arccosecant of c ```c SHZ_INLINE shz_complex_t shz_cacschf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic arccosecant of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cacschf`](https://sh4zam.com/api/cpp/#shzcacschf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:225`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L225) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_caddf Source: https://sh4zam.com/api/complex/shz_caddf/ ```c SHZ_INLINE shz_complex_t shz_caddf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT; ``` Adds two complex numbers together and returns the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `lhs` | `shz_complex_t` | | | `rhs` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::caddf`](https://sh4zam.com/api/cpp/#shzcaddf), [`shz::complex::operator+=`](https://sh4zam.com/api/cpp/complex/), [`shz::operator+`](https://sh4zam.com/api/cpp/#shzoperator+) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:83`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L83) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Arithmetic" --- # shz_cargf Source: https://sh4zam.com/api/complex/shz_cargf/ > Returns the phase angle of the complex number, c ```c SHZ_INLINE float shz_cargf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the phase angle of the complex number, `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cargf`](https://sh4zam.com/api/cpp/#shzcargf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:117`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L117) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Manipulation" --- # shz_casecf Source: https://sh4zam.com/api/complex/shz_casecf/ > Calculates and returns the complex arcsecant of c ```c SHZ_INLINE shz_complex_t shz_casecf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex arcsecant of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::casecf`](https://sh4zam.com/api/cpp/#shzcasecf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:185`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L185) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_casechf Source: https://sh4zam.com/api/complex/shz_casechf/ > Calculates and returns the complex hyperbolic arcsecant of c ```c SHZ_INLINE shz_complex_t shz_casechf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic arcsecant of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::casechf`](https://sh4zam.com/api/cpp/#shzcasechf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:228`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L228) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_casinf Source: https://sh4zam.com/api/complex/shz_casinf/ > Calculates and returns the complex arcsine of c ```c SHZ_INLINE shz_complex_t shz_casinf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex arcsine of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::casinf`](https://sh4zam.com/api/cpp/#shzcasinf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:173`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L173) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_casinhf Source: https://sh4zam.com/api/complex/shz_casinhf/ > Calculates and returns the complex hyperbolic arcsine of c ```c SHZ_INLINE shz_complex_t shz_casinhf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic arcsine of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::casinhf`](https://sh4zam.com/api/cpp/#shzcasinhf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:216`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L216) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_catanf Source: https://sh4zam.com/api/complex/shz_catanf/ > Calculates and returns the complex arctangent of c ```c SHZ_INLINE shz_complex_t shz_catanf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex arctangent of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::catanf`](https://sh4zam.com/api/cpp/#shzcatanf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:179`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L179) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_catanhf Source: https://sh4zam.com/api/complex/shz_catanhf/ > Calculates and returns the complex hyperbolic arctangent of c ```c SHZ_INLINE shz_complex_t shz_catanhf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic arctangent of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::catanhf`](https://sh4zam.com/api/cpp/#shzcatanhf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:222`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L222) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_ccosf Source: https://sh4zam.com/api/complex/shz_ccosf/ > Calculates and returns the complex cosine of c ```c SHZ_INLINE shz_complex_t shz_ccosf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex cosine of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::ccosf`](https://sh4zam.com/api/cpp/#shzccosf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:158`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L158) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_ccoshf Source: https://sh4zam.com/api/complex/shz_ccoshf/ > Calculates and returns the complex hyperbolic cosine of c ```c SHZ_INLINE shz_complex_t shz_ccoshf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic cosine of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::ccoshf`](https://sh4zam.com/api/cpp/#shzccoshf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:201`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L201) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_ccotf Source: https://sh4zam.com/api/complex/shz_ccotf/ > Calculates and returns the complex cotangent of c ```c SHZ_INLINE shz_complex_t shz_ccotf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex cotangent of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::ccotf`](https://sh4zam.com/api/cpp/#shzccotf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:170`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L170) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_ccothf Source: https://sh4zam.com/api/complex/shz_ccothf/ > Calculates and returns the complex hyperbolic cotangent of c ```c SHZ_INLINE shz_complex_t shz_ccothf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic cotangent of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::ccothf`](https://sh4zam.com/api/cpp/#shzccothf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:213`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L213) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_ccscf Source: https://sh4zam.com/api/complex/shz_ccscf/ > Calculates and returns the complex cosecant of c ```c SHZ_INLINE shz_complex_t shz_ccscf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex cosecant of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::ccscf`](https://sh4zam.com/api/cpp/#shzccscf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:164`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L164) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_ccschf Source: https://sh4zam.com/api/complex/shz_ccschf/ > Calculates and returns the complex hyperbolic cosecant of c ```c SHZ_INLINE shz_complex_t shz_ccschf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic cosecant of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::ccschf`](https://sh4zam.com/api/cpp/#shzccschf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:207`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L207) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_cdivf Source: https://sh4zam.com/api/complex/shz_cdivf/ > Divides lhs by rhs, returning the complex result ```c SHZ_INLINE shz_complex_t shz_cdivf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT; ``` Divides `lhs` by `rhs`, returning the complex result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `lhs` | `shz_complex_t` | | | `rhs` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cdivf`](https://sh4zam.com/api/cpp/#shzcdivf), [`shz::complex::operator/=`](https://sh4zam.com/api/cpp/complex/), [`shz::operator/`](https://sh4zam.com/api/cpp/#shzoperator/) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:92`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L92) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Arithmetic" --- # shz_cequalf Source: https://sh4zam.com/api/complex/shz_cequalf/ ```c SHZ_INLINE bool shz_cequalf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT; ``` Checks for equality between two complex numbers with either an absolute or relative tolerance. ## Parameters | Name | Type | Description | | --- | --- | --- | | `lhs` | `shz_complex_t` | | | `rhs` | `shz_complex_t` | | ## Returns `bool` ## Availability - **C++ equivalent:** [`shz::cequalf`](https://sh4zam.com/api/cpp/#shzcequalf), [`shz::operator==`](https://sh4zam.com/api/cpp/#shzoperator==) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:67`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L67) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Basic" --- # shz_cexpf Source: https://sh4zam.com/api/complex/shz_cexpf/ > Returns the complex base e exponential of c ```c SHZ_INLINE shz_complex_t shz_cexpf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the complex base `e` exponential of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cexpf`](https://sh4zam.com/api/cpp/#shzcexpf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:139`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L139) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Transcendental" --- # shz_cimagf Source: https://sh4zam.com/api/complex/shz_cimagf/ ```c SHZ_INLINE float shz_cimagf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the imaginary component of a complex number. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cimagf`](https://sh4zam.com/api/cpp/#shzcimagf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:73`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L73) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Basic" --- # shz_cinitf Source: https://sh4zam.com/api/complex/shz_cinitf/ ```c SHZ_INLINE shz_complex_t shz_cinitf(float real, float imag) SHZ_NOEXCEPT; ``` Returns a complex number which has been initialized to contain the given component values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `real` | `float` | | | `imag` | `float` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cinitf`](https://sh4zam.com/api/cpp/#shzcinitf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:61`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L61) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Basic" --- # shz_clog10f Source: https://sh4zam.com/api/complex/shz_clog10f/ > Computes and returns the complex base 10 logarithm of c ```c SHZ_INLINE shz_complex_t shz_clog10f(shz_complex_t c) SHZ_NOEXCEPT; ``` Computes and returns the complex base 10 logarithm of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::clog10f`](https://sh4zam.com/api/cpp/#shzclog10f) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:145`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L145) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Transcendental" --- # shz_clogf Source: https://sh4zam.com/api/complex/shz_clogf/ > Computes and returns the complex natural logarithm of c ```c SHZ_INLINE shz_complex_t shz_clogf(shz_complex_t c) SHZ_NOEXCEPT; ``` Computes and returns the complex natural logarithm of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::clogf`](https://sh4zam.com/api/cpp/#shzclogf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:142`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L142) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Transcendental" --- # SHZ_CMPLXF Source: https://sh4zam.com/api/complex/SHZ_CMPLXF/ ```c #define SHZ_CMPLXF(x, y) shz_cinitf(x, y) ``` Initializes a complex number. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | | | | `y` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_complex.h:38`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L38) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Preprocessor" --- # SHZ_CMPLXF32 Source: https://sh4zam.com/api/complex/SHZ_CMPLXF32/ ```c #define SHZ_CMPLXF32(x, y) SHZ_CMPLXF(x, y) ``` Initializes a complex number. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | | | | `y` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_complex.h:39`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L39) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Preprocessor" --- # shz_cmulf Source: https://sh4zam.com/api/complex/shz_cmulf/ ```c SHZ_INLINE shz_complex_t shz_cmulf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT; ``` Multiplies two complex numbers together, returning the complex result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `lhs` | `shz_complex_t` | | | `rhs` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cmulf`](https://sh4zam.com/api/cpp/#shzcmulf), [`shz::operator*`](https://sh4zam.com/api/cpp/#shzoperator*) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:89`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L89) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Arithmetic" --- # shz_cnormf Source: https://sh4zam.com/api/complex/shz_cnormf/ > Returns the squared magnitude of the complex number, c ```c SHZ_INLINE float shz_cnormf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the squared magnitude of the complex number, `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cnormf`](https://sh4zam.com/api/cpp/#shzcnormf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:114`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L114) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Manipulation" --- # shz_complex_t Source: https://sh4zam.com/api/complex/shz_complex_t/ ```c typedef struct shz_complex { float real; //!< The real portion of the complex number. float imag; //!< The imaginary portion of the complex number. } shz_complex_t; ``` Represents a floating-point complex number real/imaginary pair. ## Fields | Field | Type | Description | | --- | --- | --- | | `real` | `float` | The real portion of the complex number. | | `imag` | `float` | The imaginary portion of the complex number. | ## Availability - **C++ equivalent:** [`shz::complex`](https://sh4zam.com/api/cpp/complex/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_complex.h:47`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L47) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Types" --- # shz_complex Source: https://sh4zam.com/api/complex/shz_complex/ > shz_complex_t alias for those who don't like POSIX-style ```c typedef shz_complex_t shz_complex; ``` [`shz_complex_t`](https://sh4zam.com/api/complex/shz_complex_t/) alias for those who don't like POSIX-style. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_complex.h:53`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L53) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Types" --- # shz_conjf Source: https://sh4zam.com/api/complex/shz_conjf/ > Returns the complex conjugate of c ```c SHZ_INLINE shz_complex_t shz_conjf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the complex conjugate of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::conjf`](https://sh4zam.com/api/cpp/#shzconjf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:120`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L120) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Manipulation" --- # shz_cpolarf Source: https://sh4zam.com/api/complex/shz_cpolarf/ > Returns a complex number with a magnitude of r, and a phase angle of theta (in radians) ```c SHZ_INLINE shz_complex_t shz_cpolarf(float r, float theta) SHZ_NOEXCEPT; ``` Returns a complex number with a magnitude of `r`, and a phase angle of `theta` (in radians). ## Parameters | Name | Type | Description | | --- | --- | --- | | `r` | `float` | | | `theta` | `float` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cpolarf`](https://sh4zam.com/api/cpp/#shzcpolarf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:64`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L64) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Basic" --- # shz_cpowf Source: https://sh4zam.com/api/complex/shz_cpowf/ > Raises the complex base to the complex exp power, returning a complex result ```c SHZ_INLINE shz_complex_t shz_cpowf(shz_complex_t base, shz_complex_t exp) SHZ_NOEXCEPT; ``` Raises the complex `base` to the complex `exp` power, returning a complex result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `base` | `shz_complex_t` | | | `exp` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cpowf`](https://sh4zam.com/api/cpp/#shzcpowf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:136`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L136) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Transcendental" --- # shz_cprojf Source: https://sh4zam.com/api/complex/shz_cprojf/ > Calculates the projection of the complex number, c, onto the Riemann sphere ```c SHZ_INLINE shz_complex_t shz_cprojf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates the projection of the complex number, `c`, onto the Riemann sphere. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cprojf`](https://sh4zam.com/api/cpp/#shzcprojf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:123`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L123) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Manipulation" --- # shz_crealf Source: https://sh4zam.com/api/complex/shz_crealf/ ```c SHZ_INLINE float shz_crealf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the real component of a complex number. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::crealf`](https://sh4zam.com/api/cpp/#shzcrealf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:70`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L70) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Basic" --- # shz_crecipf Source: https://sh4zam.com/api/complex/shz_crecipf/ > Returns the multiplicative inverse or reciprocal of the complex number, c ```c SHZ_INLINE shz_complex_t shz_crecipf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the multiplicative inverse or reciprocal of the complex number, `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::crecipf`](https://sh4zam.com/api/cpp/#shzcrecipf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:98`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L98) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Arithmetic" --- # shz_cscalef Source: https://sh4zam.com/api/complex/shz_cscalef/ > Scales both componets of the complex number, c, by the value, v, returning the result ```c SHZ_INLINE shz_complex_t shz_cscalef(shz_complex_t c, float v) SHZ_NOEXCEPT; ``` Scales both componets of the complex number, `c`, by the value, `v`, returning the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | | `v` | `float` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::cscalef`](https://sh4zam.com/api/cpp/#shzcscalef), [`shz::operator*`](https://sh4zam.com/api/cpp/#shzoperator*), [`shz::operator/`](https://sh4zam.com/api/cpp/#shzoperator/) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:95`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L95) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Arithmetic" --- # shz_csecf Source: https://sh4zam.com/api/complex/shz_csecf/ > Calculates and returns the complex secant of c ```c SHZ_INLINE shz_complex_t shz_csecf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex secant of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::csecf`](https://sh4zam.com/api/cpp/#shzcsecf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:167`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L167) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_csechf Source: https://sh4zam.com/api/complex/shz_csechf/ > Calculates and returns the complex hyperbolic secant of c ```c SHZ_INLINE shz_complex_t shz_csechf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic secant of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::csechf`](https://sh4zam.com/api/cpp/#shzcsechf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:210`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L210) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_csinf Source: https://sh4zam.com/api/complex/shz_csinf/ > Calculates and returns the complex sine of c ```c SHZ_INLINE shz_complex_t shz_csinf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex sine of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::csinf`](https://sh4zam.com/api/cpp/#shzcsinf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:155`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L155) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_csinhf Source: https://sh4zam.com/api/complex/shz_csinhf/ > Calculates and returns the complex hyperbolic sine of c ```c SHZ_INLINE shz_complex_t shz_csinhf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic sine of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::csinhf`](https://sh4zam.com/api/cpp/#shzcsinhf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:198`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L198) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_csqrtf Source: https://sh4zam.com/api/complex/shz_csqrtf/ > Computes and returns the complex square root of c ```c SHZ_INLINE shz_complex_t shz_csqrtf(shz_complex_t c) SHZ_NOEXCEPT; ``` Computes and returns the complex square root of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::csqrtf`](https://sh4zam.com/api/cpp/#shzcsqrtf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:133`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L133) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Transcendental" --- # shz_csubf Source: https://sh4zam.com/api/complex/shz_csubf/ > Subtracts rhs from lhs and returns the complex result ```c SHZ_INLINE shz_complex_t shz_csubf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT; ``` Subtracts `rhs` from `lhs` and returns the complex result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `lhs` | `shz_complex_t` | | | `rhs` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::complex::operator-=`](https://sh4zam.com/api/cpp/complex/), [`shz::csubf`](https://sh4zam.com/api/cpp/#shzcsubf), [`shz::operator-`](https://sh4zam.com/api/cpp/#shzoperator-) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:86`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L86) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Arithmetic" --- # shz_ctanf Source: https://sh4zam.com/api/complex/shz_ctanf/ > Calculates and returns the complex tangent of c ```c SHZ_INLINE shz_complex_t shz_ctanf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex tangent of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::ctanf`](https://sh4zam.com/api/cpp/#shzctanf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:161`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L161) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Spherical Trigonometry" --- # shz_ctanhf Source: https://sh4zam.com/api/complex/shz_ctanhf/ > Calculates and returns the complex hyperbolic tangent of c ```c SHZ_INLINE shz_complex_t shz_ctanhf(shz_complex_t c) SHZ_NOEXCEPT; ``` Calculates and returns the complex hyperbolic tangent of `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `shz_complex_t` ## Availability - **C++ equivalent:** [`shz::ctanhf`](https://sh4zam.com/api/cpp/#shzctanhf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:204`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L204) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Hyperbolic Trigonometry" --- # shz_fft Source: https://sh4zam.com/api/complex/shz_fft/ ```c SHZ_INLINE void shz_fft(shz_complex_t* s, size_t size) SHZ_NOEXCEPT; ``` Fast Fourier Transform. ## Parameters | Name | Type | Description | | --- | --- | --- | | `s` | `shz_complex_t *` | | | `size` | `size_t` | | ## Returns Nothing (`void`). ## Details Applies a fast fourier transform to convert the complex array of samples, `s`, of the given `size`, from the time to the frequency domain. The conversion is done in-place. ## Notes - The underlying implementation uses the Radix2 variant of the Cooley-Tukey FFT algorithm, using an XMTRX-accelerated 2 point butterfly DIF. ## Warnings - `size` must be a power-of-two! - `s` must be aligned to 8-byte boundaries! - This routine clobbers `XMTRX`! ## Availability - **C++ equivalent:** [`shz::fft`](https://sh4zam.com/api/cpp/#shzfft) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:255`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L255) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Signal Processing" --- # SHZ_I Source: https://sh4zam.com/api/complex/SHZ_I/ ```c #define SHZ_I SHZ_CMPLXF32(0.0f, 1.0f) ``` Unit imaginary constant, 'I'. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_complex.h:40`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L40) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Preprocessor" --- # shz_inv_cabsf Source: https://sh4zam.com/api/complex/shz_inv_cabsf/ > Returns the inverse of the absolute value (or inverse of the magnitude) of the complex number, c ```c SHZ_INLINE float shz_inv_cabsf(shz_complex_t c) SHZ_NOEXCEPT; ``` Returns the inverse of the absolute value (or inverse of the magnitude) of the complex number, `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c` | `shz_complex_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::inv_cabsf`](https://sh4zam.com/api/cpp/#shzinv_cabsf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_complex.h:111`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.h#L111) - **Module:** [Complex](https://sh4zam.com/api/complex/), section "Manipulation" --- # C++ API Source: https://sh4zam.com/api/cpp/ > The SH4ZAM C++ API in namespace shz: classes, operators and aliases, mapped to the C functions they call C++ code can still use the C API by design, and every C++ type is also compatible with its corresponding C types and C API, so you can mix and match. Include `` (or a per-module `.hpp`). Vector, quaternion and matrix types derive from the C structs and add methods and operators; `shz::xmtrx` exposes the active matrix as static member functions; scalar and trig routines are `constexpr` aliases of the C functions with the `shz_` prefix dropped. ## Classes | Class | C type | Header | Description | | --- | --- | --- | --- | | [`shz::vecN`](https://sh4zam.com/api/cpp/vecn/) | n/a | `sh4zam/shz_vector.hpp` | Common C++ base structure inherited by all vector types. | | [`shz::vec2`](https://sh4zam.com/api/cpp/vec2/) | [`shz_vec2_t`](https://sh4zam.com/api/vector/shz_vec2_t/) | `sh4zam/shz_vector.hpp` | 2D Vector type | | [`shz::vec3`](https://sh4zam.com/api/cpp/vec3/) | [`shz_vec3_t`](https://sh4zam.com/api/vector/shz_vec3_t/) | `sh4zam/shz_vector.hpp` | 3D Vector type | | [`shz::vec4`](https://sh4zam.com/api/cpp/vec4/) | [`shz_vec4_t`](https://sh4zam.com/api/vector/shz_vec4_t/) | `sh4zam/shz_vector.hpp` | 4D Vector type | | [`shz::quat`](https://sh4zam.com/api/cpp/quat/) | [`shz_quat_t`](https://sh4zam.com/api/quat/shz_quat_t/) | `sh4zam/shz_quat.hpp` | C++ structure representing a quaternion. | | [`shz::mat4x4`](https://sh4zam.com/api/cpp/mat4x4/) | [`shz_mat4x4_t`](https://sh4zam.com/api/matrix/shz_mat4x4_t/) | `sh4zam/shz_matrix.hpp` | | | [`shz::xmtrx`](https://sh4zam.com/api/cpp/xmtrx/) | n/a | `sh4zam/shz_xmtrx.hpp` | Static structure around the 4x4 XMTRX FP register back-bank. | | [`shz::sincos`](https://sh4zam.com/api/cpp/sincos/) | [`shz_sincos_t`](https://sh4zam.com/api/trig/shz_sincos_t/) | `sh4zam/shz_trig.hpp` | C++ sine/cosine approximation pairs. | | [`shz::complex`](https://sh4zam.com/api/cpp/complex/) | [`shz_complex_t`](https://sh4zam.com/api/complex/shz_complex_t/) | `sh4zam/shz_complex.hpp` | C++ wrapper around a floating-point complex number, real/imaginary pair. | | [`shz::version`](https://sh4zam.com/api/cpp/version/) | n/a | `sh4zam/shz_version.hpp` | Class representing a full SH4ZAM API version. | ## Scalar aliases | C++ | C function | Description | | --- | --- | --- | | `shz::fminf` | [`shz_fminf`](https://sh4zam.com/api/scalar/shz_fminf/) | Returns the minimum value of two given floats. | | `shz::fmaxf` | [`shz_fmaxf`](https://sh4zam.com/api/scalar/shz_fmaxf/) | Returns the maximum value of two given floats. | | `shz::equalf` | [`shz_equalf`](https://sh4zam.com/api/scalar/shz_equalf/) | Checks for equality based on EITHER the absolute tolerance or relative tolerance, using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). | | `shz::equalf_abs` | [`shz_equalf_abs`](https://sh4zam.com/api/scalar/shz_equalf_abs/) | Checks for equality based on the absolute tolerance using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). | | `shz::equalf_rel` | [`shz_equalf_rel`](https://sh4zam.com/api/scalar/shz_equalf_rel/) | Checks for equality based on the relative tolerance using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). | | `shz::floorf` | [`shz_floorf`](https://sh4zam.com/api/scalar/shz_floorf/) | Replacement for the \ routine, floorf(). | | `shz::ceilf` | [`shz_ceilf`](https://sh4zam.com/api/scalar/shz_ceilf/) | Replacement for the \ routine, ceilf(). | | `shz::roundf` | [`shz_roundf`](https://sh4zam.com/api/scalar/shz_roundf/) | Replacement for the \ routine, roundf(). | | `shz::truncf` | [`shz_truncf`](https://sh4zam.com/api/scalar/shz_truncf/) | Replacement for the \ routine, truncf(). | | `shz::remainderf` | [`shz_remainderf`](https://sh4zam.com/api/scalar/shz_remainderf/) | Replacement for the \ routine, remainderf(). | | `shz::fmodf` | [`shz_fmodf`](https://sh4zam.com/api/scalar/shz_fmodf/) | Replacement for the \ routine, fmodf(). | | `shz::remquof` | [`shz_remquof`](https://sh4zam.com/api/scalar/shz_remquof/) | (Sorta) Replacement for the \ routine, remquof(). | | `shz::clampf` | [`shz_clampf`](https://sh4zam.com/api/scalar/shz_clampf/) | Clamps a floating-point value by the given `min` and `max` values. | | `shz::normalizef` | [`shz_normalizef`](https://sh4zam.com/api/scalar/shz_normalizef/) | Maps a value within the given range `from` to `to`, to be within the range of `0.0f += 1.0f`. | | `shz::normalizef_fsrra` | [`shz_normalizef_fsrra`](https://sh4zam.com/api/scalar/shz_normalizef_fsrra/) | Maps a value within the given range `from` to `to`, to be within the range of `0.0f + 1.0f` more quickly, provided `to` - `from` is a positive difference. | | `shz::remapf` | [`shz_remapf`](https://sh4zam.com/api/scalar/shz_remapf/) | Maps a value within the given range `inputStart` to `inputEnd`, to be within the range of `outputStart` to `outputEnd`. | | `shz::remapf_fsrra` | [`shz_remapf_fsrra`](https://sh4zam.com/api/scalar/shz_remapf_fsrra/) | Maps a value within the given range `inputStart` to `inputEnd`, to be within the range of `outputStart` to `outputEnd` more quickly, provided the `outputEnd` - `outputStart` is a positive difference. | | `shz::wrapf` | [`shz_wrapf`](https://sh4zam.com/api/scalar/shz_wrapf/) | Wraps the given `value` back to be within the range of `min` to `max`. | | `shz::wrapf_fsrra` | [`shz_wrapf_fsrra`](https://sh4zam.com/api/scalar/shz_wrapf_fsrra/) | Wraps the given `value` back to be within the range of `min` to `max` more quickly, provided `max` - `min` is a positive difference. | | `shz::fractf` | [`shz_fractf`](https://sh4zam.com/api/scalar/shz_fractf/) | Returns the fractional part of `x`, equivalent to GLSL `fract()`. | | `shz::signf` | [`shz_signf`](https://sh4zam.com/api/scalar/shz_signf/) | Returns -1.0f if `x` \< 0, 0.0f if `x` == 0, or 1.0f if `x` > 0. | | `shz::saturatef` | [`shz_saturatef`](https://sh4zam.com/api/scalar/shz_saturatef/) | Clamps `x` to the range \[0.0f, 1.0f\]. | | `shz::fabsf` | [`shz_fabsf`](https://sh4zam.com/api/scalar/shz_fabsf/) | Replacement for the \ routine, fabsf(). | | `shz::copysignf` | [`shz_copysignf`](https://sh4zam.com/api/scalar/shz_copysignf/) | Replacement for the \ routine, copysignf(). | | `shz::fmaf` | [`shz_fmaf`](https://sh4zam.com/api/scalar/shz_fmaf/) | Replacement for the \ routine, fmaf(). | | `shz::fdimf` | [`shz_fdimf`](https://sh4zam.com/api/scalar/shz_fdimf/) | Replacement for the \ routine, fdimf(),. | | `shz::hypotf` | [`shz_hypotf`](https://sh4zam.com/api/scalar/shz_hypotf/) | Replacement for the \ routine, hypotf(). | | `shz::lerpf` | [`shz_lerpf`](https://sh4zam.com/api/scalar/shz_lerpf/) | Returns a value that is linearly interpolated between `a` and `b` by the given ratio, `t`. | | `shz::barycentric_lerpf` | [`shz_barycentric_lerpf`](https://sh4zam.com/api/scalar/shz_barycentric_lerpf/) | Returns a value that is barycentrically interpolated between `a`, `b`, and `c` using the given barycentric coordinates, `u` and `v`. | | `shz::quadratic_roots` | [`shz_quadratic_roots`](https://sh4zam.com/api/scalar/shz_quadratic_roots/) | Uses the quadratic formula with the given coefficients to solve for the two roots, returning `true` if any real roots exist, and `false` if the roots are only imaginary. | | `shz::randf` | [`shz_randf`](https://sh4zam.com/api/scalar/shz_randf/) | Returns a random floating-point number between `0.0f` and `1.0f`, using and updating the given seed. | | `shz::randf_range` | [`shz_randf_range`](https://sh4zam.com/api/scalar/shz_randf_range/) | Returns a random floating-point number between `min` and `max`, using and updating the given seed. | | `shz::stepf` | [`shz_stepf`](https://sh4zam.com/api/scalar/shz_stepf/) | returns 0.0f if x \< edge, otherwise 1.0f | | `shz::smoothstepf` | [`shz_smoothstepf`](https://sh4zam.com/api/scalar/shz_smoothstepf/) | Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. edge0 must be less than edge1 or result is undefined. | | `shz::smoothstepf_safe` | [`shz_smoothstepf_safe`](https://sh4zam.com/api/scalar/shz_smoothstepf_safe/) | Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. | | `shz::cbrtf` | [`shz_cbrtf`](https://sh4zam.com/api/scalar/shz_cbrtf/) | Replacement for the \ routine, cbrtf(). | | `shz::inv_sqrtf_fsrra` | [`shz_inv_sqrtf_fsrra`](https://sh4zam.com/api/scalar/shz_inv_sqrtf_fsrra/) | Calculates 1.0f/sqrtf( `x`), using a fast approximation. | | `shz::inv_sqrtf` | [`shz_inv_sqrtf`](https://sh4zam.com/api/scalar/shz_inv_sqrtf/) | Calculates 1.0f/sqrtf( `x` ), using a fast approximation, while safely protecting against division-by-zero. | | `shz::sqrtf_fsrra` | [`shz_sqrtf_fsrra`](https://sh4zam.com/api/scalar/shz_sqrtf_fsrra/) | Returns the fast approximate square root of the given value, `x`. | | `shz::sqrtf` | [`shz_sqrtf`](https://sh4zam.com/api/scalar/shz_sqrtf/) | Returns the fast approximate square root of the given value, `x`, safely returning `0.0f` is `x` == `0.0f`. | | `shz::invf_fsrra` | [`shz_invf_fsrra`](https://sh4zam.com/api/scalar/shz_invf_fsrra/) | Takes the inverse of `x` using a very fast approximation, returning a positive result. | | `shz::invf` | [`shz_invf`](https://sh4zam.com/api/scalar/shz_invf/) | Takes the inverse of `x` using a slighty faster approximation than doing a full division, safely handling negative values. | | `shz::divf_fsrra` | [`shz_divf_fsrra`](https://sh4zam.com/api/scalar/shz_divf_fsrra/) | Divides `num` by `denom` using a very fast approximation, which requires `denom` be a positive value. | | `shz::divf` | [`shz_divf`](https://sh4zam.com/api/scalar/shz_divf/) | Divides `num` by `denom` using a slightly faster approximation, allowing `denom` to be negative. | | `shz::dot6f` | [`shz_dot6f`](https://sh4zam.com/api/scalar/shz_dot6f/) | Takes two sets of 3D vectors as 3 floats and calculates their dot product using an approximation. | | `shz::dot8f` | [`shz_dot8f`](https://sh4zam.com/api/scalar/shz_dot8f/) | Takes two sets of 4D vectors as 4 floats and calculates their dot product using an approximation. | | `shz::mag_sqr3f` | [`shz_mag_sqr3f`](https://sh4zam.com/api/scalar/shz_mag_sqr3f/) | Takes a 3D vector as 3 floats and calculates its squared magnitude using a fast approximation. | | `shz::mag_sqr4f` | [`shz_mag_sqr4f`](https://sh4zam.com/api/scalar/shz_mag_sqr4f/) | Takes a 4D vector as 4 floats and calculates its squared magnitude using a fast approximation. | | `shz::pow2f` | [`shz_pow2f`](https://sh4zam.com/api/scalar/shz_pow2f/) | Fast approximation for raising 2 to a floating-point power. | | `shz::powf` | [`shz_powf`](https://sh4zam.com/api/scalar/shz_powf/) | Fast approximation for C's powf(). | | `shz::pow10f` | [`shz_pow10f`](https://sh4zam.com/api/scalar/shz_pow10f/) | Fast approximation of POSIX's pow10f(). | | `shz::log2f` | [`shz_log2f`](https://sh4zam.com/api/scalar/shz_log2f/) | Fast approximation for C's log2f(). | | `shz::logf` | [`shz_logf`](https://sh4zam.com/api/scalar/shz_logf/) | Fast approximation for C's logf(). | | `shz::log10f` | [`shz_log10f`](https://sh4zam.com/api/scalar/shz_log10f/) | Fast approximation for C's log10f(). | | `shz::expf` | [`shz_expf`](https://sh4zam.com/api/scalar/shz_expf/) | Fast approximation for C's expf(). | | `shz::operator/` | [`shz_invf`](https://sh4zam.com/api/scalar/shz_invf/) | Takes the inverse of `x` using a slighty faster approximation than doing a full division, safely handling negative values. | | `shz::operator/` | [`shz_invf`](https://sh4zam.com/api/scalar/shz_invf/) | Takes the inverse of `x` using a slighty faster approximation than doing a full division, safely handling negative values. | ## Trigonometry aliases | C++ | C function | Description | | --- | --- | --- | | `shz::sincosu16` | [`shz_sincosu16`](https://sh4zam.com/api/trig/shz_sincosu16/) | Returns sinf()/cosf() pairs for the given unsigned 16-bit angle in radians. | | `shz::sincosf` | [`shz_sincosf`](https://sh4zam.com/api/trig/shz_sincosf/) | Returns sinf()/cosf() pairs for the given floating-point angle in radians. | | `shz::sincosf_deg` | [`shz_sincosf_deg`](https://sh4zam.com/api/trig/shz_sincosf_deg/) | Returns sinf/cosf() pairs for the given floating-point angle in degrees. | | `shz::sincos_tanf` | [`shz_sincos_tanf`](https://sh4zam.com/api/trig/shz_sincos_tanf/) | Returns tanf() from the given pre-computed `sincos` pair. | | `shz::sincos_secf` | [`shz_sincos_secf`](https://sh4zam.com/api/trig/shz_sincos_secf/) | Returns the floating-point secant (1.0f / cosf(x)) from the given pre-computed `sincos` pair. | | `shz::sincos_cscf` | [`shz_sincos_cscf`](https://sh4zam.com/api/trig/shz_sincos_cscf/) | Returns the floating-point cosecant (1.0f / sinf(x)) from the given pre-computed `sincos` pair. | | `shz::sincos_cotf` | [`shz_sincos_cotf`](https://sh4zam.com/api/trig/shz_sincos_cotf/) | Returns the floating-point cotangent (1.0f / tanf(x)) from the given pre-computed `sincos` pair. | | `shz::sinf` | [`shz_sinf`](https://sh4zam.com/api/trig/shz_sinf/) | One-off routine for returning only sinf() from an angle in radians. | | `shz::sinf_deg` | [`shz_sinf_deg`](https://sh4zam.com/api/trig/shz_sinf_deg/) | One-off routine for returning only sinf() from an angle in degrees. | | `shz::cosf` | [`shz_cosf`](https://sh4zam.com/api/trig/shz_cosf/) | One-off routine for returning only cosf() from an angle in radians. | | `shz::cosf_deg` | [`shz_cosf_deg`](https://sh4zam.com/api/trig/shz_cosf_deg/) | One-off routine for returning only cosf() from an angle in degrees. | | `shz::tanf` | [`shz_tanf`](https://sh4zam.com/api/trig/shz_tanf/) | One-off routine for returning only tanf() from an angle in radians. | | `shz::tanf_deg` | [`shz_tanf_deg`](https://sh4zam.com/api/trig/shz_tanf_deg/) | One-off routine for returning only tanf() from an angle in degrees. | | `shz::secf` | [`shz_secf`](https://sh4zam.com/api/trig/shz_secf/) | One-off routine for returning only secant (1 / cos(x)) from an angle in radians. | | `shz::secf_deg` | [`shz_secf_deg`](https://sh4zam.com/api/trig/shz_secf_deg/) | One-off routine for returning only secant (1 / cos(x)) from an angle in degrees. | | `shz::cscf` | [`shz_cscf`](https://sh4zam.com/api/trig/shz_cscf/) | One-off routine for returning only cosecant (1 / sin(x)) from an angle in radians. | | `shz::cscf_deg` | [`shz_cscf_deg`](https://sh4zam.com/api/trig/shz_cscf_deg/) | One-off routine for returning only cosecant (1 / sin(x)) from an angle in degrees. | | `shz::cotf` | [`shz_cotf`](https://sh4zam.com/api/trig/shz_cotf/) | One-off routine for returning only cotangent (1 / tan(x)) from an angle in radians. | | `shz::cotf_deg` | [`shz_cotf_deg`](https://sh4zam.com/api/trig/shz_cotf_deg/) | One-off routine for returning only cotangent (1 / cot(x)) from an angle in degrees. | | `shz::atanf_unit` | [`shz_atanf_unit`](https://sh4zam.com/api/trig/shz_atanf_unit/) | Fast arctangent approximation for unit values between `0.0f` and `1.0f`. | | `shz::atanf_q1` | [`shz_atanf_q1`](https://sh4zam.com/api/trig/shz_atanf_q1/) | Fast arctangent approximation for values lying within the first quadrant (`>= 0.0f`). | | `shz::atanf` | [`shz_atanf`](https://sh4zam.com/api/trig/shz_atanf/) | Fast arctangent approximation; equvalent to C's atanf(). | | `shz::atan2f` | [`shz_atan2f`](https://sh4zam.com/api/trig/shz_atan2f/) | Computes arctangent of `y / x`, using the signs of arguments to determine correct quadtrant. Equivalent to C's atan2f(). | | `shz::asinf` | [`shz_asinf`](https://sh4zam.com/api/trig/shz_asinf/) | Fast arcsine approximation; equivalent to C's asinf(). | | `shz::acosf` | [`shz_acosf`](https://sh4zam.com/api/trig/shz_acosf/) | Fast arccosine approximation; equivalent to C's acosf(). | | `shz::asecf` | [`shz_asecf`](https://sh4zam.com/api/trig/shz_asecf/) | Fast arcsecant/inverse secant approximation, taking units in radians. | | `shz::acscf` | [`shz_acscf`](https://sh4zam.com/api/trig/shz_acscf/) | Fast arccosecant/inverse cosecant approximation; taking units in radians. | | `shz::acotf` | [`shz_acotf`](https://sh4zam.com/api/trig/shz_acotf/) | Fast arccotangent/inverse cotangent approximation; taking units in radians. | | `shz::sinhf` | [`shz_sinhf`](https://sh4zam.com/api/trig/shz_sinhf/) | Fast hyperbolic sine function. | | `shz::coshf` | [`shz_coshf`](https://sh4zam.com/api/trig/shz_coshf/) | Fast hyperbolic cosine function. | | `shz::tanhf` | [`shz_tanhf`](https://sh4zam.com/api/trig/shz_tanhf/) | Fast hyperbolic tangent function. | | `shz::cschf` | [`shz_cschf`](https://sh4zam.com/api/trig/shz_cschf/) | Fast hyperbolic cosecant function. | | `shz::sechf` | [`shz_sechf`](https://sh4zam.com/api/trig/shz_sechf/) | Fast hyperbolic secant function. | | `shz::cothf` | [`shz_cothf`](https://sh4zam.com/api/trig/shz_cothf/) | Fast hyperbolic cotangent function. | | `shz::asinhf` | [`shz_asinhf`](https://sh4zam.com/api/trig/shz_asinhf/) | Fast hyperbolic arcsine function. | | `shz::acoshf` | [`shz_acoshf`](https://sh4zam.com/api/trig/shz_acoshf/) | Fast hyperbolic arccosine function. | | `shz::atanhf` | [`shz_atanhf`](https://sh4zam.com/api/trig/shz_atanhf/) | Fast hyperbolic arctangent function. | | `shz::acschf` | [`shz_acschf`](https://sh4zam.com/api/trig/shz_acschf/) | Fast hyperbolic arccosecant function. | | `shz::asechf` | [`shz_asechf`](https://sh4zam.com/api/trig/shz_asechf/) | Fast hyperbolic arcsecant function. | | `shz::acothf` | [`shz_acothf`](https://sh4zam.com/api/trig/shz_acothf/) | Fast hyperbolic arccotangent function. | ## Vector aliases | C++ | C function | Description | | --- | --- | --- | | `shz::operator+` | [`shz_vec_add`](https://sh4zam.com/api/vector/shz_vec_add/) | C type-generic vector addition. | | `shz::operator-` | [`shz_vec_sub`](https://sh4zam.com/api/vector/shz_vec_sub/) | C type-generic vector subtraction. | | `shz::operator*` | [`shz_vec_mul`](https://sh4zam.com/api/vector/shz_vec_mul/) | C type-generic vector multiplication. | | `shz::operator/` | [`shz_vec_div`](https://sh4zam.com/api/vector/shz_vec_div/) | C type-generic vector division. | | `shz::operator*` | [`shz_vec_scale`](https://sh4zam.com/api/vector/shz_vec_scale/) | C type-generic vector scaling. | | `shz::operator*` | [`shz_vec_scale`](https://sh4zam.com/api/vector/shz_vec_scale/) | C type-generic vector scaling. | | `shz::operator/` | [`shz_vec_scale`](https://sh4zam.com/api/vector/shz_vec_scale/) | C type-generic vector scaling. | | `shz::operator/` | [`shz_vec_div`](https://sh4zam.com/api/vector/shz_vec_div/) | C type-generic vector division. | ## Complex aliases | C++ | C function | Description | | --- | --- | --- | | `shz::csqrtf` | [`shz_csqrtf`](https://sh4zam.com/api/complex/shz_csqrtf/) | Computes and returns the complex square root of `c`. | | `shz::cpowf` | [`shz_cpowf`](https://sh4zam.com/api/complex/shz_cpowf/) | Raises the complex `base` to the complex `exp` power, returning a complex result. | | `shz::cexpf` | [`shz_cexpf`](https://sh4zam.com/api/complex/shz_cexpf/) | Returns the complex base `e` exponential of `c`. | | `shz::clogf` | [`shz_clogf`](https://sh4zam.com/api/complex/shz_clogf/) | Computes and returns the complex natural logarithm of `c`. | | `shz::clog10f` | [`shz_clog10f`](https://sh4zam.com/api/complex/shz_clog10f/) | Computes and returns the complex base 10 logarithm of `c`. | | `shz::operator+` | [`shz_caddf`](https://sh4zam.com/api/complex/shz_caddf/) | Adds two complex numbers together and returns the result. | | `shz::operator-` | [`shz_csubf`](https://sh4zam.com/api/complex/shz_csubf/) | Subtracts `rhs` from `lhs` and returns the complex result. | | `shz::operator*` | [`shz_cmulf`](https://sh4zam.com/api/complex/shz_cmulf/) | Multiplies two complex numbers together, returning the complex result. | | `shz::operator*` | [`shz_cscalef`](https://sh4zam.com/api/complex/shz_cscalef/) | Scales both componets of the complex number, `c`, by the value, `v`, returning the result. | | `shz::operator/` | [`shz_cdivf`](https://sh4zam.com/api/complex/shz_cdivf/) | Divides `lhs` by `rhs`, returning the complex result. | | `shz::operator/` | [`shz_cscalef`](https://sh4zam.com/api/complex/shz_cscalef/) | Scales both componets of the complex number, `c`, by the value, `v`, returning the result. | | `shz::operator==` | [`shz_cequalf`](https://sh4zam.com/api/complex/shz_cequalf/) | Checks for equality between two complex numbers with either an absolute or relative tolerance. | | `shz::cinitf` | [`shz_cinitf`](https://sh4zam.com/api/complex/shz_cinitf/) | Returns a complex number which has been initialized to contain the given component values. | | `shz::cpolarf` | [`shz_cpolarf`](https://sh4zam.com/api/complex/shz_cpolarf/) | Returns a complex number with a magnitude of `r`, and a phase angle of `theta` (in radians). | | `shz::cequalf` | [`shz_cequalf`](https://sh4zam.com/api/complex/shz_cequalf/) | Checks for equality between two complex numbers with either an absolute or relative tolerance. | | `shz::crealf` | [`shz_crealf`](https://sh4zam.com/api/complex/shz_crealf/) | Returns the real component of a complex number. | | `shz::cimagf` | [`shz_cimagf`](https://sh4zam.com/api/complex/shz_cimagf/) | Returns the imaginary component of a complex number. | | `shz::caddf` | [`shz_caddf`](https://sh4zam.com/api/complex/shz_caddf/) | Adds two complex numbers together and returns the result. | | `shz::csubf` | [`shz_csubf`](https://sh4zam.com/api/complex/shz_csubf/) | Subtracts `rhs` from `lhs` and returns the complex result. | | `shz::cmulf` | [`shz_cmulf`](https://sh4zam.com/api/complex/shz_cmulf/) | Multiplies two complex numbers together, returning the complex result. | | `shz::cdivf` | [`shz_cdivf`](https://sh4zam.com/api/complex/shz_cdivf/) | Divides `lhs` by `rhs`, returning the complex result. | | `shz::cscalef` | [`shz_cscalef`](https://sh4zam.com/api/complex/shz_cscalef/) | Scales both componets of the complex number, `c`, by the value, `v`, returning the result. | | `shz::crecipf` | [`shz_crecipf`](https://sh4zam.com/api/complex/shz_crecipf/) | Returns the multiplicative inverse or reciprocal of the complex number, `c`. | | `shz::cabsf` | [`shz_cabsf`](https://sh4zam.com/api/complex/shz_cabsf/) | Returns the absolute value (or magnitude) of the complex number, `c`. | | `shz::inv_cabsf` | [`shz_inv_cabsf`](https://sh4zam.com/api/complex/shz_inv_cabsf/) | Returns the inverse of the absolute value (or inverse of the magnitude) of the complex number, `c`. | | `shz::cnormf` | [`shz_cnormf`](https://sh4zam.com/api/complex/shz_cnormf/) | Returns the squared magnitude of the complex number, `c`. | | `shz::cargf` | [`shz_cargf`](https://sh4zam.com/api/complex/shz_cargf/) | Returns the phase angle of the complex number, `c`. | | `shz::conjf` | [`shz_conjf`](https://sh4zam.com/api/complex/shz_conjf/) | Returns the complex conjugate of `c`. | | `shz::cprojf` | [`shz_cprojf`](https://sh4zam.com/api/complex/shz_cprojf/) | Calculates the projection of the complex number, `c`, onto the Riemann sphere. | | `shz::csinf` | [`shz_csinf`](https://sh4zam.com/api/complex/shz_csinf/) | Calculates and returns the complex sine of `c`. | | `shz::ccosf` | [`shz_ccosf`](https://sh4zam.com/api/complex/shz_ccosf/) | Calculates and returns the complex cosine of `c`. | | `shz::ctanf` | [`shz_ctanf`](https://sh4zam.com/api/complex/shz_ctanf/) | Calculates and returns the complex tangent of `c`. | | `shz::ccscf` | [`shz_ccscf`](https://sh4zam.com/api/complex/shz_ccscf/) | Calculates and returns the complex cosecant of `c`. | | `shz::csecf` | [`shz_csecf`](https://sh4zam.com/api/complex/shz_csecf/) | Calculates and returns the complex secant of `c`. | | `shz::ccotf` | [`shz_ccotf`](https://sh4zam.com/api/complex/shz_ccotf/) | Calculates and returns the complex cotangent of `c`. | | `shz::casinf` | [`shz_casinf`](https://sh4zam.com/api/complex/shz_casinf/) | Calculates and returns the complex arcsine of `c`. | | `shz::cacosf` | [`shz_cacosf`](https://sh4zam.com/api/complex/shz_cacosf/) | Calculates and returns the complex arccosine of `c`. | | `shz::catanf` | [`shz_catanf`](https://sh4zam.com/api/complex/shz_catanf/) | Calculates and returns the complex arctangent of `c`. | | `shz::cacscf` | [`shz_cacscf`](https://sh4zam.com/api/complex/shz_cacscf/) | Calculates and returns the complex arccosecant of `c`. | | `shz::casecf` | [`shz_casecf`](https://sh4zam.com/api/complex/shz_casecf/) | Calculates and returns the complex arcsecant of `c`. | | `shz::cacotf` | [`shz_cacotf`](https://sh4zam.com/api/complex/shz_cacotf/) | Calculates and returns the complex arccotangent of `c`. | | `shz::csinhf` | [`shz_csinhf`](https://sh4zam.com/api/complex/shz_csinhf/) | Calculates and returns the complex hyperbolic sine of `c`. | | `shz::ccoshf` | [`shz_ccoshf`](https://sh4zam.com/api/complex/shz_ccoshf/) | Calculates and returns the complex hyperbolic cosine of `c`. | | `shz::ctanhf` | [`shz_ctanhf`](https://sh4zam.com/api/complex/shz_ctanhf/) | Calculates and returns the complex hyperbolic tangent of `c`. | | `shz::ccschf` | [`shz_ccschf`](https://sh4zam.com/api/complex/shz_ccschf/) | Calculates and returns the complex hyperbolic cosecant of `c`. | | `shz::csechf` | [`shz_csechf`](https://sh4zam.com/api/complex/shz_csechf/) | Calculates and returns the complex hyperbolic secant of `c`. | | `shz::ccothf` | [`shz_ccothf`](https://sh4zam.com/api/complex/shz_ccothf/) | Calculates and returns the complex hyperbolic cotangent of `c`. | | `shz::casinhf` | [`shz_casinhf`](https://sh4zam.com/api/complex/shz_casinhf/) | Calculates and returns the complex hyperbolic arcsine of `c`. | | `shz::cacoshf` | [`shz_cacoshf`](https://sh4zam.com/api/complex/shz_cacoshf/) | Calculates and returns the complex hyperbolic arccosine of `c`. | | `shz::catanhf` | [`shz_catanhf`](https://sh4zam.com/api/complex/shz_catanhf/) | Calculates and returns the complex hyperbolic arctangent of `c`. | | `shz::cacschf` | [`shz_cacschf`](https://sh4zam.com/api/complex/shz_cacschf/) | Calculates and returns the complex hyperbolic arccosecant of `c`. | | `shz::casechf` | [`shz_casechf`](https://sh4zam.com/api/complex/shz_casechf/) | Calculates and returns the complex hyperbolic arcsecant of `c`. | | `shz::cacothf` | [`shz_cacothf`](https://sh4zam.com/api/complex/shz_cacothf/) | Calculates and returns the complex hyperbolic arccotangent of `c`. | | `shz::fft` | [`shz_fft`](https://sh4zam.com/api/complex/shz_fft/) | Fast Fourier Transform. | ## Memory aliases | C++ | C function | Description | | --- | --- | --- | | `shz::dcache_alloc_line` | [`shz_dcache_alloc_line`](https://sh4zam.com/api/memory/shz_dcache_alloc_line/) | Intrinsic around the SH4 `MOVCA.L` instruction. | | `shz::memcpy` | [`shz_memcpy`](https://sh4zam.com/api/memory/shz_memcpy/) | Generic drop-in fast memcpy() replacement. | | `shz::memcpy1` | [`shz_memcpy1`](https://sh4zam.com/api/memory/shz_memcpy1/) | Copies an unaligned buffer to another one byte at a time. | | `shz::memcpy2` | [`shz_memcpy2`](https://sh4zam.com/api/memory/shz_memcpy2/) | Copies from one 2-byte aligned buffer to another two bytes at a time. | | `shz::memcpy4` | [`shz_memcpy4`](https://sh4zam.com/api/memory/shz_memcpy4/) | Copies a from one 4-byte aligned buffer to another 4 bytes at a time. | | `shz::memcpy8` | [`shz_memcpy8`](https://sh4zam.com/api/memory/shz_memcpy8/) | Copies a from one 8-byte aligned buffer to another 8 bytes at a time. | | `shz::memset8` | [`shz_memset8`](https://sh4zam.com/api/memory/shz_memset8/) | Assigns the given 8-byte `value` to the `bytes` in `dst`. | | `shz::memcpy32` | [`shz_memcpy32`](https://sh4zam.com/api/memory/shz_memcpy32/) | Copies `bytes` from the `src` to the `dst` buffer in 32-byte chunks. | | `shz::memcpy64` | [`shz_memcpy64`](https://sh4zam.com/api/memory/shz_memcpy64/) | Specialized memcpy() variant for copying multiples of 64-bytes. | | `shz::memcpy2_8` | [`shz_memcpy2_8`](https://sh4zam.com/api/memory/shz_memcpy2_8/) | Copies 8 shorts from `src` to `dst`. | | `shz::memcpy2_16` | [`shz_memcpy2_16`](https://sh4zam.com/api/memory/shz_memcpy2_16/) | Copies 16 shorts from `src` to `dst`. | | `shz::memset2_16` | [`shz_memset2_16`](https://sh4zam.com/api/memory/shz_memset2_16/) | Sets the values of the 16 shorts pointed to by `dst` to the given `value`. | | `shz::memcpy4_16` | [`shz_memcpy4_16`](https://sh4zam.com/api/memory/shz_memcpy4_16/) | Copies 16 4-byte, long values from `src` to `dst`. | | `shz::memswap32_1` | [`shz_memswap32_1`](https://sh4zam.com/api/memory/shz_memswap32_1/) | Swaps the values within the given 32-byte buffers. | | `shz::memswap32_1_xmtrx` | [`shz_memswap32_1_xmtrx`](https://sh4zam.com/api/memory/shz_memswap32_1_xmtrx/) | Swaps the values within the given 32-byte buffers, using XMTRX. | | `shz::sq_memcpy32` | [`shz_sq_memcpy32`](https://sh4zam.com/api/memory/shz_sq_memcpy32/) | Copies `bytes` from `src` to `dst` in 32-byte chunks, using the Store Queues. | | `shz::sq_memcpy32_xmtrx` | [`shz_sq_memcpy32_xmtrx`](https://sh4zam.com/api/memory/shz_sq_memcpy32_xmtrx/) | Copies `bytes` from `src` to `dst` in 32-byte chunks, using the Store Queues and XMTRX. | | `shz::sq_memcpy32_1` | [`shz_sq_memcpy32_1`](https://sh4zam.com/api/memory/shz_sq_memcpy32_1/) | Copies `src` to `dst` in a single 32-byte transaction using the Store Queues. | | `shz::sq_memcpy32_1_xmtrx` | [`shz_sq_memcpy32_1_xmtrx`](https://sh4zam.com/api/memory/shz_sq_memcpy32_1_xmtrx/) | Copies `src` to `dst` in a single 32-byte transaction using the Store Queues and XMTRX. | | `shz::memmove` | [`shz_memmove`](https://sh4zam.com/api/memory/shz_memmove/) | Generic drop-in fast memmove() replacement. | | `shz::memcpy128` | [`shz_memcpy128`](https://sh4zam.com/api/memory/shz_memcpy128/) | Specialized memcpy() variant for copying multiples of 128 bytes. | ## Constants | C++ | Definition | Description | | --- | --- | --- | | `shz::fipr_max_error` | `constexpr float fipr_max_error = 0.1f;` | | | `shz::pi_f` | `constexpr float pi_f = SHZ_F_PI;` | Floating-point constant approximation for Pi. | | `shz::tau_f` | `constexpr float tau_f = SHZ_F_TAU;` | Floating-point constant approximation for Pi\*2. | | `shz::pi_f_2` | `constexpr float pi_f_2 = SHZ_F_PI_2;` | Floating-point constant approximation for Pi/2. | | `shz::pi_f_4` | `constexpr float pi_f_4 = SHZ_F_PI_4;` | Floating-point constant approximation for Pi/4. | | `shz::fsca_rad_factor` | `constexpr float fsca_rad_factor = SHZ_FSCA_RAD_FACTOR;` | Scaling factor used to scale the input to FSCA from radians. | | `shz::fsca_deg_factor` | `constexpr float fsca_deg_factor = SHZ_FSCA_DEG_FACTOR;` | Scaling factor used to scale the input to FSCA from degrees. | --- # shz::complex Source: https://sh4zam.com/api/cpp/complex/ C++ wrapper around a floating-point complex number, real/imaginary pair. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_complex.hpp#L30)) - **C type:** [`shz_complex_t`](https://sh4zam.com/api/complex/shz_complex_t/) (layout-compatible; the C API accepts it directly) - **Bases:** `shz_complex_t` ## Members ### complex ```cpp complex() noexcept=default complex(const complex &rhs) noexcept=default complex(float re, float im=0.0f) noexcept complex(const shz_complex_t &cplx) noexcept complex(const volatile shz_complex_t &cplx) noexcept ``` Default constructor. ### operator+= ```cpp complex & operator+=(const complex &rhs) noexcept ``` Adds and accumulates `rhs` onto the given complex number. Calls: [`shz_caddf()`](https://sh4zam.com/api/complex/shz_caddf/) ### operator-= ```cpp complex & operator-=(const complex &rhs) noexcept ``` Subtracts `rhs` from the given complex number, assigning it to the result. Calls: [`shz_csubf()`](https://sh4zam.com/api/complex/shz_csubf/) ### operator*= ```cpp complex & operator*=(const complex &rhs) noexcept complex & operator*=(float scale) noexcept ``` Multiplies and accumulates `rhs` by the given complex number. Calls: [`shz_cmulf()`](https://sh4zam.com/api/complex/shz_cmulf/), [`shz_cscalef()`](https://sh4zam.com/api/complex/shz_cscalef/) ### operator/= ```cpp complex & operator/=(const complex &rhs) noexcept ``` Divides the given complex number by `rhs`, assigning it to the result. Calls: [`shz_cdivf()`](https://sh4zam.com/api/complex/shz_cdivf/) ### imag ```cpp float shz_complex_t::imag ``` The imaginary portion of the complex number. Inherited from `shz::vecN`. ### real ```cpp float shz_complex_t::real ``` The real portion of the complex number. Inherited from `shz::vecN`. --- # shz::mat4x4 Source: https://sh4zam.com/api/cpp/mat4x4/ > C++ class shz::mat4x4 C++ type `shz::mat4x4`. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.hpp#L27)) - **C type:** [`shz_mat4x4_t`](https://sh4zam.com/api/matrix/shz_mat4x4_t/) (layout-compatible; the C API accepts it directly) - **Bases:** `shz_mat4x4_t` ## Static functions ### copy ```cpp static void copy(shz_mat4x4_t *lhs, const shz_mat4x4_t &rhs) noexcept static void copy(shz_mat4x4_t *lhs, const float rhs[16]) noexcept ``` Calls: [`shz_mat4x4_copy()`](https://sh4zam.com/api/matrix/shz_mat4x4_copy/), [`shz_mat4x4_copy_unaligned()`](https://sh4zam.com/api/matrix/shz_mat4x4_copy_unaligned/) ### mult ```cpp static void mult(shz_mat4x4_t *dst, const shz_mat4x4_t &lhs, const shz_mat4x4_t &rhs) noexcept static void mult(shz_mat4x4_t *dst, const shz_mat4x4_t &lhs, const float rhs[16]) noexcept ``` Calls: [`shz_mat4x4_mult()`](https://sh4zam.com/api/matrix/shz_mat4x4_mult/), [`shz_mat4x4_mult_unaligned()`](https://sh4zam.com/api/matrix/shz_mat4x4_mult_unaligned/) ### mult_transpose ```cpp static void mult_transpose(shz_mat4x4_t *dst, const shz_mat4x4_t &lhs, const shz_mat4x4_t &rhs) noexcept static void mult_transpose(shz_mat4x4_t *dst, const shz_mat4x4_t &lhs, const float rhs[16]) noexcept ``` Calls: [`shz_mat4x4_mult_transpose()`](https://sh4zam.com/api/matrix/shz_mat4x4_mult_transpose/), [`shz_mat4x4_mult_transpose_unaligned()`](https://sh4zam.com/api/matrix/shz_mat4x4_mult_transpose_unaligned/) ## Members ### init_identity ```cpp void init_identity() noexcept ``` Calls: [`shz_mat4x4_init_identity()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_identity/) ### init_identity_safe ```cpp void init_identity_safe() noexcept ``` Calls: [`shz_mat4x4_init_identity()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_identity/) ### init_zero ```cpp void init_zero() noexcept ``` Calls: [`shz_mat4x4_init_zero()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_zero/) ### init_one ```cpp void init_one() noexcept ``` Calls: [`shz_mat4x4_init_one()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_one/) ### init_fill ```cpp void init_fill(float value) noexcept ``` Calls: [`shz_mat4x4_init_fill()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_fill/) ### init_translation ```cpp void init_translation(float x, float y, float z) noexcept void init_translation(const vec3 &v) noexcept ``` Calls: [`shz_mat4x4_init_translation()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_translation/) ### init_scale ```cpp void init_scale(float x, float y, float z) noexcept void init_scale(const vec3 &v) noexcept ``` Calls: [`shz_mat4x4_init_scale()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_scale/) ### init_rotation_x ```cpp void init_rotation_x(float angle) noexcept ``` Calls: [`shz_mat4x4_init_rotation_x()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_x/) ### init_rotation_y ```cpp void init_rotation_y(float angle) noexcept ``` Calls: [`shz_mat4x4_init_rotation_y()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_y/) ### init_rotation_z ```cpp void init_rotation_z(float angle) noexcept ``` Calls: [`shz_mat4x4_init_rotation_z()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_z/) ### init_rotation_xyz ```cpp void init_rotation_xyz(float xAngle, float yAngle, float zAngle) noexcept ``` Calls: [`shz_mat4x4_init_rotation_xyz()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_xyz/) ### init_rotation_zyx ```cpp void init_rotation_zyx(float zAngle, float yAngle, float xAngle) noexcept ``` Calls: [`shz_mat4x4_init_rotation_zyx()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_zyx/) ### init_rotation_zxy ```cpp void init_rotation_zxy(float zAngle, float xAngle, float yAngle) noexcept ``` Calls: [`shz_mat4x4_init_rotation_zxy()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_zxy/) ### init_rotation_yxz ```cpp void init_rotation_yxz(float yAngle, float xAngle, float zAngle) noexcept ``` Calls: [`shz_mat4x4_init_rotation_yxz()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_yxz/) ### init_rotation ```cpp void init_rotation(float angle, float x, float y, float z) noexcept void init_rotation(float angle, const vec3 &axis) noexcept void init_rotation(const quat &q) noexcept ``` Calls: [`shz_mat4x4_init_rotation()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation/), [`shz_mat4x4_init_rotation_quat()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_quat/) ### init_rotation_dir ```cpp void init_rotation_dir(float angle, float x, float y, float z) noexcept void init_rotation_dir(float angle, const vec3 &dir) noexcept ``` Calls: [`shz_mat4x4_init_rotation_dir()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_dir/) ### init_diagonal ```cpp void init_diagonal(float x, float y, float z, float w) noexcept void init_diagonal(const vec4 &v) noexcept ``` Calls: [`shz_mat4x4_init_diagonal()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_diagonal/) ### init_upper_triangular ```cpp void init_upper_triangular(float col1, const vec2 &col2, const vec3 &col3, const vec4 &col4) noexcept ``` Calls: [`shz_mat4x4_init_upper_triangular()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_upper_triangular/) ### init_lower_triangular ```cpp void init_lower_triangular(const vec4 &col1, const vec3 &col2, const vec2 &col3, float col4) noexcept ``` Calls: [`shz_mat4x4_init_lower_triangular()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_lower_triangular/) ### init_symmetric_skew ```cpp void init_symmetric_skew(float x, float y, float z) noexcept void init_symmetric_skew(const vec3 &v) noexcept ``` Calls: [`shz_mat4x4_init_symmetric_skew()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_symmetric_skew/) ### init_outer_product ```cpp void init_outer_product(const vec4 &v1, const vec4 &v2) noexcept ``` Calls: [`shz_mat4x4_init_outer_product()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_outer_product/) ### init_permutation_wxyz ```cpp void init_permutation_wxyz() noexcept ``` Calls: [`shz_mat4x4_init_permutation_wxyz()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_permutation_wxyz/) ### init_permutation_yzwx ```cpp void init_permutation_yzwx() noexcept ``` Calls: [`shz_mat4x4_init_permutation_yzwx()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_permutation_yzwx/) ### init_screen ```cpp void init_screen(float width, float height) noexcept ``` Calls: [`shz_mat4x4_init_screen()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_screen/) ### init_lookat ```cpp void init_lookat(const vec3 &eye, const vec3 ¢er, const vec3 &up) noexcept ``` Calls: [`shz_mat4x4_init_lookat()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_lookat/) ### init_ortho ```cpp void init_ortho(float left, float right, float bottom, float top, float znear, float zfar) noexcept ``` Calls: [`shz_mat4x4_init_ortho()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_ortho/) ### init_frustum ```cpp void init_frustum(float left, float right, float bottom, float top, float znear, float zfar) noexcept ``` Calls: [`shz_mat4x4_init_frustum()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_frustum/) ### init_perspective ```cpp void init_perspective(float fov, float aspect, float znear) noexcept ``` Calls: [`shz_mat4x4_init_perspective()`](https://sh4zam.com/api/matrix/shz_mat4x4_init_perspective/) ### row ```cpp vec4 row(size_t index) const noexcept ``` C++ wrapper for `shz_mat4x4_row()`. Calls: [`shz_mat4x4_row()`](https://sh4zam.com/api/matrix/shz_mat4x4_row/) ### col ```cpp vec4 col(size_t index) const noexcept ``` C++ wrapper for `shz_mat4x4_col()`. Calls: [`shz_mat4x4_col()`](https://sh4zam.com/api/matrix/shz_mat4x4_col/) ### get_translation ```cpp vec3 get_translation() const noexcept ``` Calls: [`shz_mat4x4_get_translation()`](https://sh4zam.com/api/matrix/shz_mat4x4_get_translation/) ### get_scale ```cpp vec3 get_scale() const noexcept ``` Returns the scaling components from the inner 3x3 matrix of XMTRX, as a 3D vector. Calls: [`shz_mat4x4_get_scale()`](https://sh4zam.com/api/matrix/shz_mat4x4_get_scale/) ### set_row ```cpp void set_row(size_t index, vec4 values) noexcept ``` Calls: [`shz_mat4x4_set_row()`](https://sh4zam.com/api/matrix/shz_mat4x4_set_row/) ### set_col ```cpp void set_col(size_t index, vec4 values) noexcept ``` Calls: [`shz_mat4x4_set_col()`](https://sh4zam.com/api/matrix/shz_mat4x4_set_col/) ### swap_rows ```cpp void swap_rows(size_t row1, size_t row2) noexcept ``` Calls: [`shz_mat4x4_swap_rows()`](https://sh4zam.com/api/matrix/shz_mat4x4_swap_rows/) ### swap_cols ```cpp void swap_cols(size_t col1, size_t col2) noexcept ``` Calls: [`shz_mat4x4_swap_cols()`](https://sh4zam.com/api/matrix/shz_mat4x4_swap_cols/) ### set_translation ```cpp void set_translation(float x, float y, float z) noexcept void set_translation(const vec3 &v) noexcept ``` Calls: [`shz_mat4x4_set_translation()`](https://sh4zam.com/api/matrix/shz_mat4x4_set_translation/) ### set_scale ```cpp void set_scale(float x, float y, float z) noexcept void set_scale(const vec3 &v) noexcept ``` Calls: [`shz_mat4x4_set_scale()`](https://sh4zam.com/api/matrix/shz_mat4x4_set_scale/) ### set_rotation ```cpp void set_rotation(const quat &rot) noexcept ``` Calls: [`shz_mat4x4_set_rotation_quat()`](https://sh4zam.com/api/matrix/shz_mat4x4_set_rotation_quat/) ### set_diagonal ```cpp void set_diagonal(float x, float y, float z, float w) noexcept void set_diagonal(const vec4 &v) noexcept ``` Calls: [`shz_mat4x4_set_diagonal()`](https://sh4zam.com/api/matrix/shz_mat4x4_set_diagonal/) ### apply ```cpp void apply(const shz_mat4x4_t &mat) noexcept void apply(const float mat[16]) noexcept ``` Calls: [`shz_mat4x4_apply()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply/), [`shz_mat4x4_apply_unaligned()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_unaligned/) ### apply_transpose ```cpp void apply_transpose(const shz_mat4x4_t &mat) noexcept void apply_transpose(const float mat[16]) noexcept ``` Calls: [`shz_mat4x4_apply_transpose()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_transpose/), [`shz_mat4x4_apply_transpose_unaligned()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_transpose_unaligned/) ### apply_scale ```cpp void apply_scale(float x, float y, float z) noexcept void apply_scale(const vec3 &v) noexcept ``` Calls: [`shz_mat4x4_apply_scale()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_scale/) ### apply_translation ```cpp void apply_translation(float x, float y, float z) noexcept void apply_translation(const vec3 &v) noexcept ``` Calls: [`shz_mat4x4_apply_translation()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_translation/) ### apply_rotation_x ```cpp void apply_rotation_x(float angle) noexcept ``` Calls: [`shz_mat4x4_apply_rotation_x()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_x/) ### apply_rotation_y ```cpp void apply_rotation_y(float angle) noexcept ``` Calls: [`shz_mat4x4_apply_rotation_y()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_y/) ### apply_rotation_z ```cpp void apply_rotation_z(float angle) noexcept ``` Calls: [`shz_mat4x4_apply_rotation_z()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_z/) ### apply_rotation_xyz ```cpp void apply_rotation_xyz(float xAngle, float yAngle, float zAngle) noexcept ``` Calls: [`shz_mat4x4_apply_rotation_xyz()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_xyz/) ### apply_rotation_zyx ```cpp void apply_rotation_zyx(float zAngle, float yAngle, float xAngle) noexcept ``` Calls: [`shz_mat4x4_apply_rotation_zyx()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_zyx/) ### apply_rotation_zxy ```cpp void apply_rotation_zxy(float zAngle, float xAngle, float yAngle) noexcept ``` Calls: [`shz_mat4x4_apply_rotation_zxy()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_zxy/) ### apply_rotation_yxz ```cpp void apply_rotation_yxz(float yAngle, float xAngle, float zAngle) noexcept ``` Calls: [`shz_mat4x4_apply_rotation_yxz()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_yxz/) ### apply_rotation ```cpp void apply_rotation(float angle, float x, float y, float z) noexcept void apply_rotation(float angle, vec3 axis) noexcept void apply_rotation(const quat &q) noexcept ``` Calls: [`shz_mat4x4_apply_rotation()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation/), [`shz_mat4x4_apply_rotation_quat()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_quat/) ### apply_lookat ```cpp void apply_lookat(vec3 pos, vec3 target, vec3 up) noexcept ``` Calls: [`shz_mat4x4_apply_lookat()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_lookat/) ### apply_ortho ```cpp void apply_ortho(float left, float right, float bottom, float top, float znear, float zfar) noexcept ``` Calls: [`shz_mat4x4_apply_ortho()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_ortho/) ### apply_frustum ```cpp void apply_frustum(float left, float right, float bottom, float top, float znear, float zfar) noexcept ``` Calls: [`shz_mat4x4_apply_frustum()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_frustum/) ### apply_perspective ```cpp void apply_perspective(float fov, float aspect, float znear) noexcept ``` Calls: [`shz_mat4x4_apply_perspective()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_perspective/) ### apply_screen ```cpp void apply_screen(float width, float height) noexcept ``` Calls: [`shz_mat4x4_apply_screen()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_screen/) ### apply_symmetric_skew ```cpp void apply_symmetric_skew(float x, float y, float z) noexcept ``` Calls: [`shz_mat4x4_apply_symmetric_skew()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_symmetric_skew/) ### apply_permutation_wxyz ```cpp void apply_permutation_wxyz() noexcept ``` Calls: [`shz_mat4x4_apply_permutation_wxyz()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_permutation_wxyz/) ### apply_permutation_yzwx ```cpp void apply_permutation_yzwx() noexcept ``` Calls: [`shz_mat4x4_apply_permutation_yzwx()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_permutation_yzwx/) ### apply_self ```cpp void apply_self() noexcept ``` Calls: [`shz_mat4x4_apply_self()`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_self/) ### translate ```cpp void translate(float x, float y, float z) noexcept void translate(vec3 v) noexcept ``` Calls: [`shz_mat4x4_translate()`](https://sh4zam.com/api/matrix/shz_mat4x4_translate/) ### scale ```cpp void scale(float x, float y, float z) noexcept void scale(vec3 v) noexcept ``` Calls: [`shz_mat4x4_scale()`](https://sh4zam.com/api/matrix/shz_mat4x4_scale/) ### rotate_x ```cpp void rotate_x(float radians) noexcept ``` Calls: [`shz_mat4x4_rotate_x()`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_x/) ### rotate_y ```cpp void rotate_y(float radians) noexcept ``` Calls: [`shz_mat4x4_rotate_y()`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_y/) ### rotate_z ```cpp void rotate_z(float radians) noexcept ``` Calls: [`shz_mat4x4_rotate_z()`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_z/) ### rotate_xyz ```cpp void rotate_xyz(float xRadians, float yRadians, float zRadians) noexcept ``` Calls: [`shz_mat4x4_rotate_xyz()`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_xyz/) ### rotate_zyx ```cpp void rotate_zyx(float zRadians, float yRadians, float xRadians) noexcept ``` Calls: [`shz_mat4x4_rotate_zyx()`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_zyx/) ### rotate_zxy ```cpp void rotate_zxy(float zRadians, float xRadians, float yRadians) noexcept ``` Calls: [`shz_mat4x4_rotate_zxy()`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_zxy/) ### rotate_yxz ```cpp void rotate_yxz(float yRadians, float xRadians, float zRadians) noexcept ``` Calls: [`shz_mat4x4_rotate_yxz()`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_yxz/) ### rotate ```cpp void rotate(float radians, float xAxis, float yAxis, float zAxis) noexcept void rotate(float radians, vec3 axis) noexcept ``` Calls: [`shz_mat4x4_rotate()`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate/) ### translate_reverse ```cpp void translate_reverse(float x, float y, float z) noexcept void translate_reverse(const shz::vec3 &pos) noexcept ``` Pre-multiplies and accumulates the given matrix onto the 3D translation matrix with the given components. Calls: [`shz_mat4x4_translate_reverse()`](https://sh4zam.com/api/matrix/shz_mat4x4_translate_reverse/) ### scale_reverse ```cpp void scale_reverse(float x, float y, float z) noexcept void scale_reverse(const shz::vec3 &size) noexcept ``` Pre-multiplies and accumulates the given matrix onto the 3D scaling matrix with the given components. Calls: [`shz_mat4x4_scale_reverse()`](https://sh4zam.com/api/matrix/shz_mat4x4_scale_reverse/) ### transform ```cpp vec2 transform(const vec2 &in) const noexcept vec3 transform(const vec3 &in) const noexcept vec4 transform(const vec4 &in) const noexcept ``` Calls: [`shz_mat4x4_transform_vec2()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec2/), [`shz_mat4x4_transform_vec3()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec3/), [`shz_mat4x4_transform_vec4()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec4/) ### transform_point ```cpp vec2 transform_point(const vec2 &pt) const noexcept vec3 transform_point(const vec3 &pt) const noexcept ``` Calls: [`shz_mat4x4_transform_point2()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_point2/), [`shz_mat4x4_transform_point3()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_point3/) ### transform_transpose ```cpp vec2 transform_transpose(const vec2 &in) const noexcept vec3 transform_transpose(const vec3 &in) const noexcept vec4 transform_transpose(const vec4 &in) const noexcept ``` Calls: [`shz_mat4x4_transform_vec2_transpose()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec2_transpose/), [`shz_mat4x4_transform_vec3_transpose()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec3_transpose/), [`shz_mat4x4_transform_vec4_transpose()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec4_transpose/) ### transform_point_transpose ```cpp vec2 transform_point_transpose(const vec2 &pt) const noexcept vec3 transform_point_transpose(const vec3 &pt) const noexcept ``` Calls: [`shz_mat4x4_transform_point2_transpose()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_point2_transpose/), [`shz_mat4x4_transform_point3_transpose()`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_point3_transpose/) ### to_quat ```cpp quat to_quat() const noexcept ``` Calls: [`shz_mat4x4_to_quat()`](https://sh4zam.com/api/matrix/shz_mat4x4_to_quat/) ### determinant ```cpp float determinant() const noexcept ``` Calls: [`shz_mat4x4_determinant()`](https://sh4zam.com/api/matrix/shz_mat4x4_determinant/) ### trace ```cpp float trace() const noexcept ``` Calls: [`shz_mat4x4_trace()`](https://sh4zam.com/api/matrix/shz_mat4x4_trace/) ### inverse ```cpp void inverse(mat4x4 *out) const noexcept ``` Calls: [`shz_mat4x4_inverse()`](https://sh4zam.com/api/matrix/shz_mat4x4_inverse/) ### inverse_block_triangular ```cpp void inverse_block_triangular(mat4x4 *out) const noexcept ``` Calls: [`shz_mat4x4_inverse_block_triangular()`](https://sh4zam.com/api/matrix/shz_mat4x4_inverse_block_triangular/) ### decompose ```cpp void decompose(vec3 *translation, quat *rotation, vec3 *scale) const noexcept ``` Calls: [`shz_mat4x4_decompose()`](https://sh4zam.com/api/matrix/shz_mat4x4_decompose/) ### blend ```cpp void blend(const shz_mat4x4_t &matrix, float weight) noexcept ``` Adds and accumulates a scaled 4x4 matrix into the given matrix. Calls: [`shz_mat4x4_blend()`](https://sh4zam.com/api/matrix/shz_mat4x4_blend/) ### swap ```cpp void swap(shz_mat4x4_t &matA, shz_mat4x4_t &matB) noexcept ``` ### mat4x4 ```cpp mat4x4() noexcept=default mat4x4(const mat4x4 &other) noexcept mat4x4(const shz_mat4x4_t &other) noexcept ``` Calls: [`shz_mat4x4_copy()`](https://sh4zam.com/api/matrix/shz_mat4x4_copy/) ### operator= ```cpp mat4x4 & operator=(const shz_mat4x4_t &other) noexcept ``` Calls: [`shz_mat4x4_copy()`](https://sh4zam.com/api/matrix/shz_mat4x4_copy/) ### operator== ```cpp bool operator==(const mat4x4 &lhs, const mat4x4 &rhs) noexcept ``` Overloaded equality operator, for comparing vectors. --- # shz::quat Source: https://sh4zam.com/api/cpp/quat/ C++ structure representing a quaternion. A quaternion represents a rotation about an arbitrary axis in 3D space. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.hpp#L38)) - **C type:** [`shz_quat_t`](https://sh4zam.com/api/quat/shz_quat_t/) (layout-compatible; the C API accepts it directly) - **Bases:** `shz_quat_t` ## Static functions ### identity ```cpp static quat identity() noexcept ``` Returns an identity quaternion. Calls: [`shz_quat_identity()`](https://sh4zam.com/api/quat/shz_quat_identity/) ### from_angles_xyz ```cpp static quat from_angles_xyz(float x, float y, float z) noexcept ``` C++ convenience wrapper for `shz_quat_from_angles_xyz()`. Calls: [`shz_quat_from_angles_xyz()`](https://sh4zam.com/api/quat/shz_quat_from_angles_xyz/) ### from_rotation_xyz ```cpp static quat from_rotation_xyz(float x, float y, float z) noexcept ``` C++ convenience wrapper for `shz_quat_from_rotation_xyz()`. Calls: [`shz_quat_from_rotation_xyz()`](https://sh4zam.com/api/quat/shz_quat_from_rotation_xyz/) ### from_rotation_zyx ```cpp static quat from_rotation_zyx(float z, float y, float x) noexcept ``` C++ convenience wrapper for `shz_quat_from_rotation_zyx()`. Calls: [`shz_quat_from_rotation_zyx()`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zyx/) ### from_rotation_zxy ```cpp static quat from_rotation_zxy(float z, float x, float y) noexcept ``` C++ convenience wrapper for `shz_quat_from_rotation_zxy()`. Calls: [`shz_quat_from_rotation_zxy()`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zxy/) ### from_rotation_yxz ```cpp static quat from_rotation_yxz(float y, float x, float z) noexcept ``` C++ convenience wrapper for `shz_quat_from_rotation_yxz()`. Calls: [`shz_quat_from_rotation_yxz()`](https://sh4zam.com/api/quat/shz_quat_from_rotation_yxz/) ### from_rotation_xyz_u16 ```cpp static quat from_rotation_xyz_u16(uint16_t x, uint16_t y, uint16_t z) noexcept ``` C++ convenience wrapper for `shz_quat_from_rotation_xyz_u16()`. Calls: [`shz_quat_from_rotation_xyz_u16()`](https://sh4zam.com/api/quat/shz_quat_from_rotation_xyz_u16/) ### from_rotation_zyx_u16 ```cpp static quat from_rotation_zyx_u16(uint16_t z, uint16_t y, uint16_t x) noexcept ``` C++ convenience wrapper for `shz_quat_from_rotation_zyx_u16()`. Calls: [`shz_quat_from_rotation_zyx_u16()`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zyx_u16/) ### from_rotation_zxy_u16 ```cpp static quat from_rotation_zxy_u16(uint16_t z, uint16_t x, uint16_t y) noexcept ``` C++ convenience wrapper for `shz_quat_from_rotation_zxy_u16()`. Calls: [`shz_quat_from_rotation_zxy_u16()`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zxy_u16/) ### from_rotation_yxz_u16 ```cpp static quat from_rotation_yxz_u16(uint16_t y, uint16_t x, uint16_t z) noexcept ``` C++ convenience wrapper for `shz_quat_from_rotation_yxz_u16()`. Calls: [`shz_quat_from_rotation_yxz_u16()`](https://sh4zam.com/api/quat/shz_quat_from_rotation_yxz_u16/) ### from_axis_angle ```cpp static quat from_axis_angle(const vec3 &axis, float angle) noexcept ``` Initializes a quaternion which is a rotation in `angle` radians about the given `axis`. Calls: [`shz_quat_from_axis_angle()`](https://sh4zam.com/api/quat/shz_quat_from_axis_angle/) ### from_look_axis ```cpp static quat from_look_axis(const vec3 &forward, const vec3 &up) noexcept ``` Creates a quaternion looking in the given direction with the given reference direction. Calls: [`shz_quat_from_look_axis()`](https://sh4zam.com/api/quat/shz_quat_from_look_axis/) ### from_rotated_axis ```cpp static quat from_rotated_axis(const vec3 &start, const vec3 &end) noexcept ``` Returns the quaternion representing the rotation from the `start` to the `end` axes. Calls: [`shz_quat_from_rotated_axis()`](https://sh4zam.com/api/quat/shz_quat_from_rotated_axis/) ### lerp ```cpp static quat lerp(const quat &q, const quat &p, float t) noexcept ``` Returns the quaternion that is linearly interpolating `q` to `p`, by a t factor of `0.0f-1.0f`. Calls: [`shz_quat_lerp()`](https://sh4zam.com/api/quat/shz_quat_lerp/) ### nlerp ```cpp static quat nlerp(const quat &q, const quat &p, float t) noexcept ``` Equivalent to `lerp()`, except that the resulting quaternion is normalized. Calls: [`shz_quat_nlerp()`](https://sh4zam.com/api/quat/shz_quat_nlerp/) ### slerp ```cpp static quat slerp(const quat &q, const quat &p, float t) noexcept ``` Returns the quaternion that is spherically linearly interpolating `q` to `p`, by a `t` factor of `0.0f-1.0f`. Calls: [`shz_quat_slerp()`](https://sh4zam.com/api/quat/shz_quat_slerp/) ### squad ```cpp static quat squad(const quat &q1, const quat &q2, const quat &s1, const quat &s2, float t) noexcept ``` Evaluates the smooth cubic spherical interpolation (SQUAD) at parameter `t`. Calls: [`shz_quat_squad()`](https://sh4zam.com/api/quat/shz_quat_squad/) ## Members ### quat ```cpp quat() noexcept=default quat(const quat &other) noexcept=default quat(float w, float x, float y, float z) noexcept quat(const shz_quat_t &q) noexcept quat(const volatile shz_quat_t &other) noexcept ``` Default constructor: does nothing. ### angle ```cpp float angle() const noexcept ``` Returns the angle of rotation represented by the given quaternion. Calls: [`shz_quat_angle()`](https://sh4zam.com/api/quat/shz_quat_angle/) ### axis ```cpp vec3 axis() const noexcept ``` Returns the axis of rotation represented by the given quaternion. Calls: [`shz_quat_axis()`](https://sh4zam.com/api/quat/shz_quat_axis/) ### angle_x ```cpp float angle_x() const noexcept ``` Returns the angle of rotation about the X axis represented by the given quaternion. Calls: [`shz_quat_angle_x()`](https://sh4zam.com/api/quat/shz_quat_angle_x/) ### angle_y ```cpp float angle_y() const noexcept ``` Returns the angle of rotation about the Y axis represented by the given quaternion. Calls: [`shz_quat_angle_y()`](https://sh4zam.com/api/quat/shz_quat_angle_y/) ### angle_z ```cpp float angle_z() const noexcept ``` Returns the angle of rotation about the Z axis represented by the given quaternion. Calls: [`shz_quat_angle_z()`](https://sh4zam.com/api/quat/shz_quat_angle_z/) ### magnitude_sqr ```cpp float magnitude_sqr() const noexcept ``` Returns the magnitude of the quaternion squared. Calls: [`shz_quat_magnitude_sqr()`](https://sh4zam.com/api/quat/shz_quat_magnitude_sqr/) ### magnitude ```cpp float magnitude() const noexcept ``` Returns the magnitude of the quaternion. Calls: [`shz_quat_magnitude()`](https://sh4zam.com/api/quat/shz_quat_magnitude/) ### magnitude_inv ```cpp float magnitude_inv() const noexcept ``` Returns the inverse of the magnitude of the quaternion. Calls: [`shz_quat_magnitude_inv()`](https://sh4zam.com/api/quat/shz_quat_magnitude_inv/) ### to_angles_xyz ```cpp vec3 to_angles_xyz() const noexcept ``` Returns the tait-bryan rotation angles about the X, Y, then Z axes which are represented by the given quaternion. Calls: [`shz_quat_to_angles_xyz()`](https://sh4zam.com/api/quat/shz_quat_to_angles_xyz/) ### to_axis_angle ```cpp void to_axis_angle(shz_vec3_t *axis, float *angle) const noexcept std::pair< vec3, float > to_axis_angle() const noexcept ``` Returns both the axis and angle of rotation through the pointer arguments. Calls: [`shz_quat_to_axis_angle()`](https://sh4zam.com/api/quat/shz_quat_to_axis_angle/) ### normalized ```cpp quat normalized() const noexcept ``` Returns the given quaternion as a unit quaternion. Calls: [`shz_quat_normalize()`](https://sh4zam.com/api/quat/shz_quat_normalize/) ### normalize ```cpp void normalize() noexcept ``` Normalizes the given quaternion. ### normalized_safe ```cpp quat normalized_safe() const noexcept ``` Returns a safely normalized quaternion from the given quaternion, protecting against division-by-zero. Calls: [`shz_quat_normalize_safe()`](https://sh4zam.com/api/quat/shz_quat_normalize_safe/) ### normalize_safe ```cpp void normalize_safe() noexcept ``` Safely normalizes the given quaternion by protecting against division-by-zero. ### conjugated ```cpp quat conjugated() const noexcept ``` Returns a quaternion that is the conjugate of the given quaternion. Calls: [`shz_quat_conjugate()`](https://sh4zam.com/api/quat/shz_quat_conjugate/) ### conjugate ```cpp void conjugate() noexcept ``` Conjugates the given quaternion. ### inverse ```cpp quat inverse() const noexcept ``` Returns the inverse of the given quaternion. Calls: [`shz_quat_inv()`](https://sh4zam.com/api/quat/shz_quat_inv/) ### invert ```cpp void invert() noexcept ``` Inverts the given quaternion. ### negated ```cpp quat negated() const noexcept ``` Returns a new quaternion whose components are the negated values of the given quaternion. Calls: [`shz_quat_neg()`](https://sh4zam.com/api/quat/shz_quat_neg/) ### negate ```cpp void negate() noexcept ``` Negates the components of the given quaternion. ### add ```cpp quat add(const quat &rhs) const noexcept ``` Returns a new quaternion from adding the given quaterion to `rhs`. Calls: [`shz_quat_add()`](https://sh4zam.com/api/quat/shz_quat_add/) ### sub ```cpp quat sub(const quat &rhs) const noexcept ``` Returns a new quaternion from adding `rhs` from the given quaternion. Calls: [`shz_quat_sub()`](https://sh4zam.com/api/quat/shz_quat_sub/) ### scaled ```cpp quat scaled(float s) const noexcept ``` Returns a new quaternion from scaling the given quaterion by `s`. Calls: [`shz_quat_scale()`](https://sh4zam.com/api/quat/shz_quat_scale/) ### scale ```cpp void scale(float s) noexcept ``` Multiplies each component of the given quaternion by `s`. ### dot ```cpp float dot(const quat &other) const noexcept vec2 dot(const quat &q1, const quat &q2) const noexcept vec3 dot(const quat &q1, const quat &q2, const quat &q3) const noexcept ``` Returns the dot product between the given quaternion and another. Calls: [`shz_quat_dot()`](https://sh4zam.com/api/quat/shz_quat_dot/), [`shz_quat_dot2()`](https://sh4zam.com/api/quat/shz_quat_dot2/), [`shz_quat_dot3()`](https://sh4zam.com/api/quat/shz_quat_dot3/) ### mult ```cpp quat mult(const quat &rhs) const noexcept ``` Returns a new quaterion from multiplying the given quaternion by another. Calls: [`shz_quat_mult()`](https://sh4zam.com/api/quat/shz_quat_mult/) ### div ```cpp quat div(const quat &rhs) const noexcept ``` Returns a new quaterion from dividing the given quaternion by another (or multiplying the given quaternion by the inverse of another). Calls: [`shz_quat_div()`](https://sh4zam.com/api/quat/shz_quat_div/) ### angle_between ```cpp float angle_between(const quat &p) const noexcept ``` Returns the angle in radians between the rotations represented by quaternions `q` and `p`. Calls: [`shz_quat_angle_between()`](https://sh4zam.com/api/quat/shz_quat_angle_between/) ### rotate_towards ```cpp quat rotate_towards(const quat &to, float max_angle) const noexcept ``` Rotates quaternion `from` towards quaternion `to` by at most `max_angle` radians. Calls: [`shz_quat_rotate_towards()`](https://sh4zam.com/api/quat/shz_quat_rotate_towards/) ### transform ```cpp vec3 transform(const vec3 &in) const noexcept ``` Returns a new `shz::vec3` from transforming `in` by the given quaternion. Calls: [`shz_quat_transform_vec3()`](https://sh4zam.com/api/quat/shz_quat_transform_vec3/) ### operator- ```cpp quat operator-() const noexcept ``` Overloaded unary negation operator, returns the negation of the given quaternion. ### operator+= ```cpp quat operator+=(const quat &rhs) noexcept ``` Adds and accumulates `rhs` onto the given quaternion. ### operator-= ```cpp quat operator-=(const quat &rhs) noexcept ``` Subtracts `rhs` from the given quaternion. ### operator*= ```cpp quat operator*=(const quat &rhs) noexcept quat operator*=(float rhs) noexcept ``` Multiplies and accumulates `rhs` into the given quaternion. ### operator/= ```cpp quat operator/=(const quat &rhs) noexcept quat operator/=(float rhs) noexcept ``` Divides the given quaternion by `rhs`. Calls: [`shz_invf()`](https://sh4zam.com/api/scalar/shz_invf/) ### operator== ```cpp bool operator==(const quat &lhs, const quat &rhs) noexcept ``` Overloaded comparison operator, checks for quaternion equality. --- # shz::sincos Source: https://sh4zam.com/api/cpp/sincos/ C++ sine/cosine approximation pairs. This structure contains the precomputed values for both sine and cosine of an angle. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.hpp#L44)) - **C type:** [`shz_sincos_t`](https://sh4zam.com/api/trig/shz_sincos_t/) (layout-compatible; the C API accepts it directly) - **Bases:** `shz_sincos_t` ## Static functions ### from_radians ```cpp static sincos from_radians(float rad) noexcept static sincos from_radians(uint16_t rad) noexcept ``` Returns a new sin/cos pair from the given angle in radians. Calls: [`shz_sincosf()`](https://sh4zam.com/api/trig/shz_sincosf/), [`shz_sincosu16()`](https://sh4zam.com/api/trig/shz_sincosu16/) ### from_degrees ```cpp static sincos from_degrees(float deg) noexcept ``` Returns a new sin/cos pair from the given angle in degrees. Calls: [`shz_sincosf_deg()`](https://sh4zam.com/api/trig/shz_sincosf_deg/) ## Members ### sincos ```cpp sincos(const shz_sincos_t &val) noexcept ``` Converting constructor from C struct. ### sinf ```cpp float sinf() const noexcept ``` Returns the sine component from the pair. ### cosf ```cpp float cosf() const noexcept ``` Returns the cosine component from the pair. ### tanf ```cpp float tanf() const noexcept ``` Calculates the tangent from the given pair. Calls: [`shz_sincos_tanf()`](https://sh4zam.com/api/trig/shz_sincos_tanf/) ### secf ```cpp float secf() const noexcept ``` Calculates the secant from the given pair. Calls: [`shz_sincos_secf()`](https://sh4zam.com/api/trig/shz_sincos_secf/) ### cscf ```cpp float cscf() const noexcept ``` Calculates the cosecant from the given pair. Calls: [`shz_sincos_cscf()`](https://sh4zam.com/api/trig/shz_sincos_cscf/) ### cotf ```cpp float cotf() const noexcept ``` Calculates the cotangent from the given pair. Calls: [`shz_sincos_cotf()`](https://sh4zam.com/api/trig/shz_sincos_cotf/) ### operator std::pair< float, float > ```cpp operator std::pair< float, float >() const noexcept ``` ### cos ```cpp float shz_sincos_t::cos ``` cosf() approximation for the angle Inherited from `shz::vecN`. ### sin ```cpp float shz_sincos_t::sin ``` sinf() approximation for the angle Inherited from `shz::vecN`. --- # shz::vec2 Source: https://sh4zam.com/api/cpp/vec2/ 2D Vector type C++ structure for representing a 2-dimensional vector. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.hpp#L420)) - **C type:** [`shz_vec2_t`](https://sh4zam.com/api/vector/shz_vec2_t/) (layout-compatible; the C API accepts it directly) - **Bases:** `shz::vecN< vec2, shz_vec2_t, 2 >` ## Static functions ### from_angle ```cpp static vec2 from_angle(float rads) noexcept ``` Constructs a `vec2` from the given angle of rotation from the +X axis, in radians. Calls: [`shz_vec2_from_angle()`](https://sh4zam.com/api/vector/shz_vec2_from_angle/) ### from_angle_deg ```cpp static vec2 from_angle_deg(float deg) noexcept ``` Constructs a `vec2` from the given angle of rotation from the +X axis, in degrees. Calls: [`shz_vec2_from_angle_deg()`](https://sh4zam.com/api/vector/shz_vec2_from_angle_deg/) ### from ```cpp static CppType shz::vecN< CRTP, C, R >::from(const auto &raw) noexcept ``` Conversion operator for going from a layout-compatible vector type to a SH4ZAM vector type. Inherited from `shz::vecN`. ### lerp ```cpp static CppType shz::vecN< CRTP, C, R >::lerp(const CppType &start, const CppType &end, float t) noexcept ``` Returns the vector that is linearly interpolated between the two given vectors by the `0.0f-1.0f` factor, `t`. Calls: [`shz_vec2_lerp()`](https://sh4zam.com/api/vector/shz_vec2_lerp/) (inherited from `shz::vecN`) ### smoothstep ```cpp static CppType shz::vecN< CRTP, C, R >::smoothstep(const CppType &vec, T &&edge0, T &&edge1) noexcept ``` Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1. Calls: [`shz_vec2_smoothstep()`](https://sh4zam.com/api/vector/shz_vec2_smoothstep/) (inherited from `shz::vecN`) ### smoothstep_safe ```cpp static CppType shz::vecN< CRTP, C, R >::smoothstep_safe(const CppType &vec, T &&edge0, T &&edge1) noexcept ``` Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1. Calls: [`shz_vec2_smoothstep_safe()`](https://sh4zam.com/api/vector/shz_vec2_smoothstep_safe/) (inherited from `shz::vecN`) ### step ```cpp static CppType shz::vecN< CRTP, C, R >::step(const CppType &vec, T &&edge) noexcept ``` Compares each component of the vector to the edge. 0 returned in that component if x\[i\] \< edge. Otherwise the component is 1. Calls: [`shz_vec2_step()`](https://sh4zam.com/api/vector/shz_vec2_step/) (inherited from `shz::vecN`) ## Members ### vec2 ```cpp vec2()=default vec2(float v) noexcept vec2(float x, float y) noexcept vec2(const sincos &pair) noexcept ``` Default constructor: does nothing. ### cross ```cpp float cross(const vec2 &other) const noexcept ``` C++ wrapper for `shz_vec2_cross()`. Calls: [`shz_vec2_cross()`](https://sh4zam.com/api/vector/shz_vec2_cross/) ### rotate ```cpp vec2 rotate(float radians) const noexcept ``` C++ wrapper for `shz_vec2_rotate()`. Calls: [`shz_vec2_rotate()`](https://sh4zam.com/api/vector/shz_vec2_rotate/) ### vecN ```cpp shz::vecN< CRTP, C, R >::vecN() noexcept=default shz::vecN< CRTP, C, R >::vecN(const vecN &other) noexcept=default shz::vecN< CRTP, C, R >::vecN(const CType &other) noexcept shz::vecN< CRTP, C, R >::vecN(const volatile CType &other) noexcept ``` Default constructor, does nothing. ### dot ```cpp float shz::vecN< CRTP, C, R >::dot(const CppType &other) const noexcept vec2 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2) const noexcept vec3 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2, const CppType &v3) const noexcept ``` Returns the dot product of the given vector and another. ### abs ```cpp CppType shz::vecN< CRTP, C, R >::abs() const noexcept ``` Returns a new vector whose components are the absolute value of the given vector. Calls: [`shz_vec2_abs()`](https://sh4zam.com/api/vector/shz_vec2_abs/) (inherited from `shz::vecN`) ### angle_between ```cpp float shz::vecN< CRTP, C, R >::angle_between(const CppType &other) const noexcept ``` Returns the angle between the given vector and another, in radians. Calls: [`shz_vec2_angle_between()`](https://sh4zam.com/api/vector/shz_vec2_angle_between/) (inherited from `shz::vecN`) ### angles ```cpp auto shz::vecN< CRTP, C, R >::angles() const noexcept ``` Returns the angle(s) created between the given vector axis and the +X axis, in radians. Calls: [`shz_vec2_angle()`](https://sh4zam.com/api/vector/shz_vec2_angle/) (inherited from `shz::vecN`) ### ceil ```cpp CppType shz::vecN< CRTP, C, R >::ceil() const noexcept ``` Returns a new vector with the component-wise ceil of the given vector. Calls: [`shz_vec2_ceil()`](https://sh4zam.com/api/vector/shz_vec2_ceil/) (inherited from `shz::vecN`) ### clamp ```cpp CppType shz::vecN< CRTP, C, R >::clamp(float min, float max) const noexcept ``` Returns a new vector whose values are the clamped components of the given vector. Calls: [`shz_vec2_clamp()`](https://sh4zam.com/api/vector/shz_vec2_clamp/) (inherited from `shz::vecN`) ### deref ```cpp CppType & shz::vecN< CRTP, C, R >::deref(const auto *raw) noexcept ``` Conversion operator for accessing an existing pointer type as though it were a refrence to a SH4ZAM type. Inherited from `shz::vecN`. ### direction ```cpp CppType shz::vecN< CRTP, C, R >::direction() const noexcept ``` Returns the direction vector resulting from normalizing the given vector. Calls: [`shz_vec2_normalize()`](https://sh4zam.com/api/vector/shz_vec2_normalize/) (inherited from `shz::vecN`) ### direction_safe ```cpp CppType shz::vecN< CRTP, C, R >::direction_safe() const noexcept ``` Returns the direction vector of a given vector, safely protecting against division-by-zero. Calls: [`shz_vec2_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec2_normalize_safe/) (inherited from `shz::vecN`) ### distance ```cpp float shz::vecN< CRTP, C, R >::distance(const CppType &other) const noexcept ``` Returns the magnitude of the difference between two vectors as their distance. Calls: [`shz_vec2_distance()`](https://sh4zam.com/api/vector/shz_vec2_distance/) (inherited from `shz::vecN`) ### distance_sqr ```cpp float shz::vecN< CRTP, C, R >::distance_sqr(const CppType &other) const noexcept ``` Returns the value of the distance between two vectors squared (faster than actual distance). Calls: [`shz_vec2_distance_sqr()`](https://sh4zam.com/api/vector/shz_vec2_distance_sqr/) (inherited from `shz::vecN`) ### floor ```cpp CppType shz::vecN< CRTP, C, R >::floor() const noexcept ``` Returns a new vector with the component-wise floor of the given vector. Calls: [`shz_vec2_floor()`](https://sh4zam.com/api/vector/shz_vec2_floor/) (inherited from `shz::vecN`) ### fract ```cpp CppType shz::vecN< CRTP, C, R >::fract() const noexcept ``` Returns a new vector with the fractional part of each component. Calls: [`shz_vec2_fract()`](https://sh4zam.com/api/vector/shz_vec2_fract/) (inherited from `shz::vecN`) ### inv ```cpp CppType shz::vecN< CRTP, C, R >::inv() const noexcept ``` Returns a new vector whose components are the reciprocal values of the given vector. Calls: [`shz_vec2_inv()`](https://sh4zam.com/api/vector/shz_vec2_inv/) (inherited from `shz::vecN`) ### inv_sqrtf ```cpp CppType shz::vecN< CRTP, C, R >::inv_sqrtf() const noexcept ``` Returns a new vector whose components are the inverse square root of the given vector. Calls: [`shz_vec2_inv_sqrtf()`](https://sh4zam.com/api/vector/shz_vec2_inv_sqrtf/) (inherited from `shz::vecN`) ### magnitude ```cpp float shz::vecN< CRTP, C, R >::magnitude() const noexcept ``` Returns the magnitude of the given vector. Calls: [`shz_vec2_magnitude()`](https://sh4zam.com/api/vector/shz_vec2_magnitude/) (inherited from `shz::vecN`) ### magnitude_inv ```cpp float shz::vecN< CRTP, C, R >::magnitude_inv() const noexcept ``` Returns the inverse magnitude of the given vector. Calls: [`shz_vec2_magnitude_inv()`](https://sh4zam.com/api/vector/shz_vec2_magnitude_inv/) (inherited from `shz::vecN`) ### magnitude_sqr ```cpp float shz::vecN< CRTP, C, R >::magnitude_sqr() const noexcept ``` Returns the squared magnitude of the given vector. Calls: [`shz_vec2_magnitude_sqr()`](https://sh4zam.com/api/vector/shz_vec2_magnitude_sqr/) (inherited from `shz::vecN`) ### max ```cpp float shz::vecN< CRTP, C, R >::max() const noexcept ``` Returns the maximum value of every element within the vector. Calls: [`shz_vec2_max()`](https://sh4zam.com/api/vector/shz_vec2_max/) (inherited from `shz::vecN`) ### maxv ```cpp CppType shz::vecN< CRTP, C, R >::maxv(const CppType &other) const noexcept ``` Returns a new vector with the component-wise maximum of two vectors. Calls: [`shz_vec2_maxv()`](https://sh4zam.com/api/vector/shz_vec2_maxv/) (inherited from `shz::vecN`) ### min ```cpp float shz::vecN< CRTP, C, R >::min() const noexcept ``` Returns the minimum value of every element within the vector. Calls: [`shz_vec2_min()`](https://sh4zam.com/api/vector/shz_vec2_min/) (inherited from `shz::vecN`) ### minv ```cpp CppType shz::vecN< CRTP, C, R >::minv(const CppType &other) const noexcept ``` Returns a new vector with the component-wise minimum of two vectors. Calls: [`shz_vec2_minv()`](https://sh4zam.com/api/vector/shz_vec2_minv/) (inherited from `shz::vecN`) ### move ```cpp CppType shz::vecN< CRTP, C, R >::move(const CppType &target, float maxdist) const noexcept ``` Moves the given vector towards the target by the given `maxdist`. Calls: [`shz_vec2_move()`](https://sh4zam.com/api/vector/shz_vec2_move/) (inherited from `shz::vecN`) ### neg ```cpp CppType shz::vecN< CRTP, C, R >::neg() const noexcept ``` Returns a new vector whose components are the negative values of the given vector. Calls: [`shz_vec2_neg()`](https://sh4zam.com/api/vector/shz_vec2_neg/) (inherited from `shz::vecN`) ### normalize ```cpp void shz::vecN< CRTP, C, R >::normalize() noexcept ``` Normalizes the given vector. Calls: [`shz_vec2_normalize()`](https://sh4zam.com/api/vector/shz_vec2_normalize/) (inherited from `shz::vecN`) ### normalize_safe ```cpp void shz::vecN< CRTP, C, R >::normalize_safe() noexcept ``` Normalizes the given vector, safely protecting against division-by-zero. Calls: [`shz_vec2_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec2_normalize_safe/) (inherited from `shz::vecN`) ### normalized ```cpp CppType shz::vecN< CRTP, C, R >::normalized() const noexcept ``` Return the normalized vector. Calls: [`shz_vec2_normalize()`](https://sh4zam.com/api/vector/shz_vec2_normalize/) (inherited from `shz::vecN`) ### normalized_safe ```cpp CppType shz::vecN< CRTP, C, R >::normalized_safe() const noexcept ``` Return the normalized vector, safely protecting against division-by-zero. Calls: [`shz_vec2_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec2_normalize_safe/) (inherited from `shz::vecN`) ### operator*= ```cpp CppType & shz::vecN< CRTP, C, R >::operator*=(const CppType &other) noexcept ``` Overloaded multiplication assignment operator, multiplies and accumulates a vector onto the left-hand vector. Inherited from `shz::vecN`. ### operator+= ```cpp CppType & shz::vecN< CRTP, C, R >::operator+=(const CppType &other) noexcept ``` Overloaded operator for adding and accumulating a vector onto another. Inherited from `shz::vecN`. ### operator-= ```cpp CppType & shz::vecN< CRTP, C, R >::operator-=(const CppType &other) noexcept ``` Overloaded subtraction assignment operator, subtracts a vector from the left-hand vector. Inherited from `shz::vecN`. ### operator/= ```cpp CppType & shz::vecN< CRTP, C, R >::operator/=(const CppType &other) noexcept ``` Overloaded division assignment operator, divides the left vector by the right, assigning the left to the result. Inherited from `shz::vecN`. ### project ```cpp CppType shz::vecN< CRTP, C, R >::project(const CppType &onto) const noexcept ``` Returns the vector created from projecting the given vector onto another. Calls: [`shz_vec2_project()`](https://sh4zam.com/api/vector/shz_vec2_project/) (inherited from `shz::vecN`) ### project_safe ```cpp CppType shz::vecN< CRTP, C, R >::project_safe(const CppType &onto) const noexcept ``` Returns the vector created from projecting the given vector onto another, safely protecting against division-by-zero. Calls: [`shz_vec2_project_safe()`](https://sh4zam.com/api/vector/shz_vec2_project_safe/) (inherited from `shz::vecN`) ### reflect ```cpp CppType shz::vecN< CRTP, C, R >::reflect(const CppType &normal) const noexcept ``` Returns the vector created from reflecting the given vector over the normal of a surface. Calls: [`shz_vec2_reflect()`](https://sh4zam.com/api/vector/shz_vec2_reflect/) (inherited from `shz::vecN`) ### refract ```cpp CppType shz::vecN< CRTP, C, R >::refract(const CppType &normal, float eta) const noexcept ``` Returns the vector create from refracting the given incidence vector over the normal of a surface, using the given refraction ratio index. Calls: [`shz_vec2_refract()`](https://sh4zam.com/api/vector/shz_vec2_refract/) (inherited from `shz::vecN`) ### round ```cpp CppType shz::vecN< CRTP, C, R >::round() const noexcept ``` Returns a new vector with the component-wise rounding of the given vector. Calls: [`shz_vec2_round()`](https://sh4zam.com/api/vector/shz_vec2_round/) (inherited from `shz::vecN`) ### saturate ```cpp CppType shz::vecN< CRTP, C, R >::saturate() const noexcept ``` Returns a new vector with each component clamped to \[0, 1\]. Calls: [`shz_vec2_saturate()`](https://sh4zam.com/api/vector/shz_vec2_saturate/) (inherited from `shz::vecN`) ### sign ```cpp CppType shz::vecN< CRTP, C, R >::sign() const noexcept ``` Returns a new vector with the sign of each component (-1, 0, or 1). Calls: [`shz_vec2_sign()`](https://sh4zam.com/api/vector/shz_vec2_sign/) (inherited from `shz::vecN`) ### sqrtf ```cpp CppType shz::vecN< CRTP, C, R >::sqrtf() const noexcept ``` Returns a new vector whose components are the square root of the given vector. Calls: [`shz_vec2_sqrtf()`](https://sh4zam.com/api/vector/shz_vec2_sqrtf/) (inherited from `shz::vecN`) ### swizzle ```cpp CppType shz::vecN< CRTP, C, R >::swizzle() const noexcept ``` Swizzle oeprator which takes a compile-time list of indices as non-type template arguments for the index each element should use as its new value. Calls: [`shz_vec2_swizzle()`](https://sh4zam.com/api/vector/shz_vec2_swizzle/) (inherited from `shz::vecN`) ### to ```cpp T shz::vecN< CRTP, C, R >::to() const noexcept ``` Conversion operator for going from a SH4ZAM vector type to another layout-compatible type. Inherited from `shz::vecN`. --- # shz::vec3 Source: https://sh4zam.com/api/cpp/vec3/ 3D Vector type C++ structure for representing a 3-dimensional vector. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.hpp#L475)) - **C type:** [`shz_vec3_t`](https://sh4zam.com/api/vector/shz_vec3_t/) (layout-compatible; the C API accepts it directly) - **Bases:** `shz::vecN< vec3, shz_vec3_t, 3 >` ## Static functions ### orthonormalize ```cpp static auto orthonormalize(const vec3 &in1, const vec3 &in2) noexcept static void orthonormalize(const vec3 &in1, const vec3 &in2, vec3 *out1, vec3 *out2) noexcept ``` Returns 2 3D vectors which are normalized and orthogonal to the two input vectors as a std::pair\<>. Calls: [`shz_vec3_orthonormalize()`](https://sh4zam.com/api/vector/shz_vec3_orthonormalize/) ### cubic_hermite ```cpp static vec3 cubic_hermite(const vec3 &v1, const vec3 &tangent1, const vec3 &v2, const vec3 &tangent2, float amount) noexcept ``` Calculates the cubic hermite interpolation between two vectors and their tangents. Calls: [`shz_vec3_cubic_hermite()`](https://sh4zam.com/api/vector/shz_vec3_cubic_hermite/) ### from_angles ```cpp static vec3 from_angles(float azimuth_rads, float elevation_rads) noexcept ``` Returns a 3D vector which forms the given angles with the +X axis, in radians. Calls: [`shz_vec3_from_angles()`](https://sh4zam.com/api/vector/shz_vec3_from_angles/) ### from_angles_deg ```cpp static vec3 from_angles_deg(float azimuth_deg, float elevation_deg) noexcept ``` Returns a 3D vector which forms the given angles with the +X axis, in degrees. Calls: [`shz_vec3_from_angles_deg()`](https://sh4zam.com/api/vector/shz_vec3_from_angles_deg/) ### from ```cpp static CppType shz::vecN< CRTP, C, R >::from(const auto &raw) noexcept ``` Conversion operator for going from a layout-compatible vector type to a SH4ZAM vector type. Inherited from `shz::vecN`. ### lerp ```cpp static CppType shz::vecN< CRTP, C, R >::lerp(const CppType &start, const CppType &end, float t) noexcept ``` Returns the vector that is linearly interpolated between the two given vectors by the `0.0f-1.0f` factor, `t`. Calls: [`shz_vec3_lerp()`](https://sh4zam.com/api/vector/shz_vec3_lerp/) (inherited from `shz::vecN`) ### smoothstep ```cpp static CppType shz::vecN< CRTP, C, R >::smoothstep(const CppType &vec, T &&edge0, T &&edge1) noexcept ``` Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1. Calls: [`shz_vec3_smoothstep()`](https://sh4zam.com/api/vector/shz_vec3_smoothstep/) (inherited from `shz::vecN`) ### smoothstep_safe ```cpp static CppType shz::vecN< CRTP, C, R >::smoothstep_safe(const CppType &vec, T &&edge0, T &&edge1) noexcept ``` Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1. Calls: [`shz_vec3_smoothstep_safe()`](https://sh4zam.com/api/vector/shz_vec3_smoothstep_safe/) (inherited from `shz::vecN`) ### step ```cpp static CppType shz::vecN< CRTP, C, R >::step(const CppType &vec, T &&edge) noexcept ``` Compares each component of the vector to the edge. 0 returned in that component if x\[i\] \< edge. Otherwise the component is 1. Calls: [`shz_vec3_step()`](https://sh4zam.com/api/vector/shz_vec3_step/) (inherited from `shz::vecN`) ## Members ### rotate_x ```cpp vec3 rotate_x(float angle) const noexcept ``` Rotates a 3D vector about the X axis by the given number of radians. Calls: [`shz_vec3_rotate_x()`](https://sh4zam.com/api/vector/shz_vec3_rotate_x/) ### rotate_y ```cpp vec3 rotate_y(float angle) const noexcept ``` Rotates a 3D vector about the Y axis by the given number of radians. Calls: [`shz_vec3_rotate_y()`](https://sh4zam.com/api/vector/shz_vec3_rotate_y/) ### rotate_z ```cpp vec3 rotate_z(float angle) const noexcept ``` Rotates a 3D vector about the Z axis by the given number of radians. Calls: [`shz_vec3_rotate_z()`](https://sh4zam.com/api/vector/shz_vec3_rotate_z/) ### vec3 ```cpp vec3()=default vec3(const shz_vec3_t &other) noexcept vec3(float v) noexcept vec3(float x, float y, float z) noexcept vec3(const shz::vec2 &xy, float z) noexcept vec3(float x, const shz::vec2 &yz) noexcept vec3(const sincos &azimuth, const sincos &elevation) noexcept ``` Default constructor: does nothing. ### xy ```cpp vec2 xy() const noexcept ``` ### cross ```cpp vec3 cross(const vec3 &other) const noexcept ``` Returns a 3D vector which forms the given angles with the +X axis. Calls: [`shz_vec3_cross()`](https://sh4zam.com/api/vector/shz_vec3_cross/) ### triple ```cpp float triple(const vec3 &b, const vec3 &c) const noexcept ``` Returns the 3D vector "triple product" between the given vector and vectors `a` and `b`. Calls: [`shz_vec3_triple()`](https://sh4zam.com/api/vector/shz_vec3_triple/) ### perp ```cpp vec3 perp() const noexcept ``` Returns a 3D vector which is perpendicular to this vector. Calls: [`shz_vec3_perp()`](https://sh4zam.com/api/vector/shz_vec3_perp/) ### reject ```cpp vec3 reject(const vec3 &onto) const noexcept ``` Returns the 3D reject vector of the given vector and another. Calls: [`shz_vec3_reject()`](https://sh4zam.com/api/vector/shz_vec3_reject/) ### barycenter ```cpp vec3 barycenter(const vec3 &a, const vec3 &b, const vec3 &c) const noexcept ``` Computes the barycentric coordinates `` for the given 3D vector, within the plane of the triangle formed by the given vertices, `a`, `b`, and `c`. Calls: [`shz_vec3_barycenter()`](https://sh4zam.com/api/vector/shz_vec3_barycenter/) ### vecN ```cpp shz::vecN< CRTP, C, R >::vecN() noexcept=default shz::vecN< CRTP, C, R >::vecN(const vecN &other) noexcept=default shz::vecN< CRTP, C, R >::vecN(const CType &other) noexcept shz::vecN< CRTP, C, R >::vecN(const volatile CType &other) noexcept ``` Default constructor, does nothing. ### dot ```cpp float shz::vecN< CRTP, C, R >::dot(const CppType &other) const noexcept vec2 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2) const noexcept vec3 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2, const CppType &v3) const noexcept ``` Returns the dot product of the given vector and another. ### abs ```cpp CppType shz::vecN< CRTP, C, R >::abs() const noexcept ``` Returns a new vector whose components are the absolute value of the given vector. Calls: [`shz_vec3_abs()`](https://sh4zam.com/api/vector/shz_vec3_abs/) (inherited from `shz::vecN`) ### angle_between ```cpp float shz::vecN< CRTP, C, R >::angle_between(const CppType &other) const noexcept ``` Returns the angle between the given vector and another, in radians. Calls: [`shz_vec3_angle_between()`](https://sh4zam.com/api/vector/shz_vec3_angle_between/) (inherited from `shz::vecN`) ### angles ```cpp auto shz::vecN< CRTP, C, R >::angles() const noexcept ``` Returns the angle(s) created between the given vector axis and the +X axis, in radians. Calls: [`shz_vec3_angles()`](https://sh4zam.com/api/vector/shz_vec3_angles/) (inherited from `shz::vecN`) ### ceil ```cpp CppType shz::vecN< CRTP, C, R >::ceil() const noexcept ``` Returns a new vector with the component-wise ceil of the given vector. Calls: [`shz_vec3_ceil()`](https://sh4zam.com/api/vector/shz_vec3_ceil/) (inherited from `shz::vecN`) ### clamp ```cpp CppType shz::vecN< CRTP, C, R >::clamp(float min, float max) const noexcept ``` Returns a new vector whose values are the clamped components of the given vector. Calls: [`shz_vec3_clamp()`](https://sh4zam.com/api/vector/shz_vec3_clamp/) (inherited from `shz::vecN`) ### deref ```cpp CppType & shz::vecN< CRTP, C, R >::deref(const auto *raw) noexcept ``` Conversion operator for accessing an existing pointer type as though it were a refrence to a SH4ZAM type. Inherited from `shz::vecN`. ### direction ```cpp CppType shz::vecN< CRTP, C, R >::direction() const noexcept ``` Returns the direction vector resulting from normalizing the given vector. Calls: [`shz_vec3_normalize()`](https://sh4zam.com/api/vector/shz_vec3_normalize/) (inherited from `shz::vecN`) ### direction_safe ```cpp CppType shz::vecN< CRTP, C, R >::direction_safe() const noexcept ``` Returns the direction vector of a given vector, safely protecting against division-by-zero. Calls: [`shz_vec3_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec3_normalize_safe/) (inherited from `shz::vecN`) ### distance ```cpp float shz::vecN< CRTP, C, R >::distance(const CppType &other) const noexcept ``` Returns the magnitude of the difference between two vectors as their distance. Calls: [`shz_vec3_distance()`](https://sh4zam.com/api/vector/shz_vec3_distance/) (inherited from `shz::vecN`) ### distance_sqr ```cpp float shz::vecN< CRTP, C, R >::distance_sqr(const CppType &other) const noexcept ``` Returns the value of the distance between two vectors squared (faster than actual distance). Calls: [`shz_vec3_distance_sqr()`](https://sh4zam.com/api/vector/shz_vec3_distance_sqr/) (inherited from `shz::vecN`) ### floor ```cpp CppType shz::vecN< CRTP, C, R >::floor() const noexcept ``` Returns a new vector with the component-wise floor of the given vector. Calls: [`shz_vec3_floor()`](https://sh4zam.com/api/vector/shz_vec3_floor/) (inherited from `shz::vecN`) ### fract ```cpp CppType shz::vecN< CRTP, C, R >::fract() const noexcept ``` Returns a new vector with the fractional part of each component. Calls: [`shz_vec3_fract()`](https://sh4zam.com/api/vector/shz_vec3_fract/) (inherited from `shz::vecN`) ### inv ```cpp CppType shz::vecN< CRTP, C, R >::inv() const noexcept ``` Returns a new vector whose components are the reciprocal values of the given vector. Calls: [`shz_vec3_inv()`](https://sh4zam.com/api/vector/shz_vec3_inv/) (inherited from `shz::vecN`) ### inv_sqrtf ```cpp CppType shz::vecN< CRTP, C, R >::inv_sqrtf() const noexcept ``` Returns a new vector whose components are the inverse square root of the given vector. Calls: [`shz_vec3_inv_sqrtf()`](https://sh4zam.com/api/vector/shz_vec3_inv_sqrtf/) (inherited from `shz::vecN`) ### magnitude ```cpp float shz::vecN< CRTP, C, R >::magnitude() const noexcept ``` Returns the magnitude of the given vector. Calls: [`shz_vec3_magnitude()`](https://sh4zam.com/api/vector/shz_vec3_magnitude/) (inherited from `shz::vecN`) ### magnitude_inv ```cpp float shz::vecN< CRTP, C, R >::magnitude_inv() const noexcept ``` Returns the inverse magnitude of the given vector. Calls: [`shz_vec3_magnitude_inv()`](https://sh4zam.com/api/vector/shz_vec3_magnitude_inv/) (inherited from `shz::vecN`) ### magnitude_sqr ```cpp float shz::vecN< CRTP, C, R >::magnitude_sqr() const noexcept ``` Returns the squared magnitude of the given vector. Calls: [`shz_vec3_magnitude_sqr()`](https://sh4zam.com/api/vector/shz_vec3_magnitude_sqr/) (inherited from `shz::vecN`) ### max ```cpp float shz::vecN< CRTP, C, R >::max() const noexcept ``` Returns the maximum value of every element within the vector. Calls: [`shz_vec3_max()`](https://sh4zam.com/api/vector/shz_vec3_max/) (inherited from `shz::vecN`) ### maxv ```cpp CppType shz::vecN< CRTP, C, R >::maxv(const CppType &other) const noexcept ``` Returns a new vector with the component-wise maximum of two vectors. Calls: [`shz_vec3_maxv()`](https://sh4zam.com/api/vector/shz_vec3_maxv/) (inherited from `shz::vecN`) ### min ```cpp float shz::vecN< CRTP, C, R >::min() const noexcept ``` Returns the minimum value of every element within the vector. Calls: [`shz_vec3_min()`](https://sh4zam.com/api/vector/shz_vec3_min/) (inherited from `shz::vecN`) ### minv ```cpp CppType shz::vecN< CRTP, C, R >::minv(const CppType &other) const noexcept ``` Returns a new vector with the component-wise minimum of two vectors. Calls: [`shz_vec3_minv()`](https://sh4zam.com/api/vector/shz_vec3_minv/) (inherited from `shz::vecN`) ### move ```cpp CppType shz::vecN< CRTP, C, R >::move(const CppType &target, float maxdist) const noexcept ``` Moves the given vector towards the target by the given `maxdist`. Calls: [`shz_vec3_move()`](https://sh4zam.com/api/vector/shz_vec3_move/) (inherited from `shz::vecN`) ### neg ```cpp CppType shz::vecN< CRTP, C, R >::neg() const noexcept ``` Returns a new vector whose components are the negative values of the given vector. Calls: [`shz_vec3_neg()`](https://sh4zam.com/api/vector/shz_vec3_neg/) (inherited from `shz::vecN`) ### normalize ```cpp void shz::vecN< CRTP, C, R >::normalize() noexcept ``` Normalizes the given vector. Calls: [`shz_vec3_normalize()`](https://sh4zam.com/api/vector/shz_vec3_normalize/) (inherited from `shz::vecN`) ### normalize_safe ```cpp void shz::vecN< CRTP, C, R >::normalize_safe() noexcept ``` Normalizes the given vector, safely protecting against division-by-zero. Calls: [`shz_vec3_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec3_normalize_safe/) (inherited from `shz::vecN`) ### normalized ```cpp CppType shz::vecN< CRTP, C, R >::normalized() const noexcept ``` Return the normalized vector. Calls: [`shz_vec3_normalize()`](https://sh4zam.com/api/vector/shz_vec3_normalize/) (inherited from `shz::vecN`) ### normalized_safe ```cpp CppType shz::vecN< CRTP, C, R >::normalized_safe() const noexcept ``` Return the normalized vector, safely protecting against division-by-zero. Calls: [`shz_vec3_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec3_normalize_safe/) (inherited from `shz::vecN`) ### operator*= ```cpp CppType & shz::vecN< CRTP, C, R >::operator*=(const CppType &other) noexcept ``` Overloaded multiplication assignment operator, multiplies and accumulates a vector onto the left-hand vector. Inherited from `shz::vecN`. ### operator+= ```cpp CppType & shz::vecN< CRTP, C, R >::operator+=(const CppType &other) noexcept ``` Overloaded operator for adding and accumulating a vector onto another. Inherited from `shz::vecN`. ### operator-= ```cpp CppType & shz::vecN< CRTP, C, R >::operator-=(const CppType &other) noexcept ``` Overloaded subtraction assignment operator, subtracts a vector from the left-hand vector. Inherited from `shz::vecN`. ### operator/= ```cpp CppType & shz::vecN< CRTP, C, R >::operator/=(const CppType &other) noexcept ``` Overloaded division assignment operator, divides the left vector by the right, assigning the left to the result. Inherited from `shz::vecN`. ### project ```cpp CppType shz::vecN< CRTP, C, R >::project(const CppType &onto) const noexcept ``` Returns the vector created from projecting the given vector onto another. Calls: [`shz_vec3_project()`](https://sh4zam.com/api/vector/shz_vec3_project/) (inherited from `shz::vecN`) ### project_safe ```cpp CppType shz::vecN< CRTP, C, R >::project_safe(const CppType &onto) const noexcept ``` Returns the vector created from projecting the given vector onto another, safely protecting against division-by-zero. Calls: [`shz_vec3_project_safe()`](https://sh4zam.com/api/vector/shz_vec3_project_safe/) (inherited from `shz::vecN`) ### reflect ```cpp CppType shz::vecN< CRTP, C, R >::reflect(const CppType &normal) const noexcept ``` Returns the vector created from reflecting the given vector over the normal of a surface. Calls: [`shz_vec3_reflect()`](https://sh4zam.com/api/vector/shz_vec3_reflect/) (inherited from `shz::vecN`) ### refract ```cpp CppType shz::vecN< CRTP, C, R >::refract(const CppType &normal, float eta) const noexcept ``` Returns the vector create from refracting the given incidence vector over the normal of a surface, using the given refraction ratio index. Calls: [`shz_vec3_refract()`](https://sh4zam.com/api/vector/shz_vec3_refract/) (inherited from `shz::vecN`) ### round ```cpp CppType shz::vecN< CRTP, C, R >::round() const noexcept ``` Returns a new vector with the component-wise rounding of the given vector. Calls: [`shz_vec3_round()`](https://sh4zam.com/api/vector/shz_vec3_round/) (inherited from `shz::vecN`) ### saturate ```cpp CppType shz::vecN< CRTP, C, R >::saturate() const noexcept ``` Returns a new vector with each component clamped to \[0, 1\]. Calls: [`shz_vec3_saturate()`](https://sh4zam.com/api/vector/shz_vec3_saturate/) (inherited from `shz::vecN`) ### sign ```cpp CppType shz::vecN< CRTP, C, R >::sign() const noexcept ``` Returns a new vector with the sign of each component (-1, 0, or 1). Calls: [`shz_vec3_sign()`](https://sh4zam.com/api/vector/shz_vec3_sign/) (inherited from `shz::vecN`) ### sqrtf ```cpp CppType shz::vecN< CRTP, C, R >::sqrtf() const noexcept ``` Returns a new vector whose components are the square root of the given vector. Calls: [`shz_vec3_sqrtf()`](https://sh4zam.com/api/vector/shz_vec3_sqrtf/) (inherited from `shz::vecN`) ### swizzle ```cpp CppType shz::vecN< CRTP, C, R >::swizzle() const noexcept ``` Swizzle oeprator which takes a compile-time list of indices as non-type template arguments for the index each element should use as its new value. Calls: [`shz_vec3_swizzle()`](https://sh4zam.com/api/vector/shz_vec3_swizzle/) (inherited from `shz::vecN`) ### to ```cpp T shz::vecN< CRTP, C, R >::to() const noexcept ``` Conversion operator for going from a SH4ZAM vector type to another layout-compatible type. Inherited from `shz::vecN`. --- # shz::vec4 Source: https://sh4zam.com/api/cpp/vec4/ 4D Vector type C++ structure for representing a 4-dimensional vector. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.hpp#L613)) - **C type:** [`shz_vec4_t`](https://sh4zam.com/api/vector/shz_vec4_t/) (layout-compatible; the C API accepts it directly) - **Bases:** `shz::vecN< vec4, shz_vec4_t, 4 >` ## Static functions ### from ```cpp static CppType shz::vecN< CRTP, C, R >::from(const auto &raw) noexcept ``` Conversion operator for going from a layout-compatible vector type to a SH4ZAM vector type. Inherited from `shz::vecN`. ### lerp ```cpp static CppType shz::vecN< CRTP, C, R >::lerp(const CppType &start, const CppType &end, float t) noexcept ``` Returns the vector that is linearly interpolated between the two given vectors by the `0.0f-1.0f` factor, `t`. Calls: [`shz_vec4_lerp()`](https://sh4zam.com/api/vector/shz_vec4_lerp/) (inherited from `shz::vecN`) ### smoothstep ```cpp static CppType shz::vecN< CRTP, C, R >::smoothstep(const CppType &vec, T &&edge0, T &&edge1) noexcept ``` Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1. Calls: [`shz_vec4_smoothstep()`](https://sh4zam.com/api/vector/shz_vec4_smoothstep/) (inherited from `shz::vecN`) ### smoothstep_safe ```cpp static CppType shz::vecN< CRTP, C, R >::smoothstep_safe(const CppType &vec, T &&edge0, T &&edge1) noexcept ``` Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1. Calls: [`shz_vec4_smoothstep_safe()`](https://sh4zam.com/api/vector/shz_vec4_smoothstep_safe/) (inherited from `shz::vecN`) ### step ```cpp static CppType shz::vecN< CRTP, C, R >::step(const CppType &vec, T &&edge) noexcept ``` Compares each component of the vector to the edge. 0 returned in that component if x\[i\] \< edge. Otherwise the component is 1. Calls: [`shz_vec4_step()`](https://sh4zam.com/api/vector/shz_vec4_step/) (inherited from `shz::vecN`) ## Members ### vec4 ```cpp vec4()=default vec4(const shz_vec4_t &other) noexcept vec4(float v) noexcept vec4(float x, float y, float z, float w) noexcept vec4(const shz::vec2 &xy, float z, float w) noexcept vec4(float x, const shz::vec2 &yz, float w) noexcept vec4(float x, float y, const shz::vec2 &zw) noexcept vec4(const shz::vec2 &xy, const shz::vec2 &zw) noexcept vec4(const shz::vec3 &xyz, float w) noexcept vec4(float x, const shz::vec3 &yzw) noexcept ``` Default constructor: does nothing. ### xy ```cpp vec2 xy() const noexcept ``` ### zw ```cpp vec2 zw() const noexcept ``` ### xyz ```cpp vec3 xyz() const noexcept ``` ### vecN ```cpp shz::vecN< CRTP, C, R >::vecN() noexcept=default shz::vecN< CRTP, C, R >::vecN(const vecN &other) noexcept=default shz::vecN< CRTP, C, R >::vecN(const CType &other) noexcept shz::vecN< CRTP, C, R >::vecN(const volatile CType &other) noexcept ``` Default constructor, does nothing. ### dot ```cpp float shz::vecN< CRTP, C, R >::dot(const CppType &other) const noexcept vec2 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2) const noexcept vec3 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2, const CppType &v3) const noexcept ``` Returns the dot product of the given vector and another. ### abs ```cpp CppType shz::vecN< CRTP, C, R >::abs() const noexcept ``` Returns a new vector whose components are the absolute value of the given vector. Calls: [`shz_vec4_abs()`](https://sh4zam.com/api/vector/shz_vec4_abs/) (inherited from `shz::vecN`) ### angle_between ```cpp float shz::vecN< CRTP, C, R >::angle_between(const CppType &other) const noexcept ``` Returns the angle between the given vector and another, in radians. Calls: [`shz_vec_angle_between()`](https://sh4zam.com/api/vector/shz_vec_angle_between/) (inherited from `shz::vecN`) ### angles ```cpp auto shz::vecN< CRTP, C, R >::angles() const noexcept ``` Returns the angle(s) created between the given vector axis and the +X axis, in radians. Calls: [`shz_vec_angles()`](https://sh4zam.com/api/vector/shz_vec_angles/) (inherited from `shz::vecN`) ### ceil ```cpp CppType shz::vecN< CRTP, C, R >::ceil() const noexcept ``` Returns a new vector with the component-wise ceil of the given vector. Calls: [`shz_vec4_ceil()`](https://sh4zam.com/api/vector/shz_vec4_ceil/) (inherited from `shz::vecN`) ### clamp ```cpp CppType shz::vecN< CRTP, C, R >::clamp(float min, float max) const noexcept ``` Returns a new vector whose values are the clamped components of the given vector. Calls: [`shz_vec4_clamp()`](https://sh4zam.com/api/vector/shz_vec4_clamp/) (inherited from `shz::vecN`) ### deref ```cpp CppType & shz::vecN< CRTP, C, R >::deref(const auto *raw) noexcept ``` Conversion operator for accessing an existing pointer type as though it were a refrence to a SH4ZAM type. Inherited from `shz::vecN`. ### direction ```cpp CppType shz::vecN< CRTP, C, R >::direction() const noexcept ``` Returns the direction vector resulting from normalizing the given vector. Calls: [`shz_vec4_normalize()`](https://sh4zam.com/api/vector/shz_vec4_normalize/) (inherited from `shz::vecN`) ### direction_safe ```cpp CppType shz::vecN< CRTP, C, R >::direction_safe() const noexcept ``` Returns the direction vector of a given vector, safely protecting against division-by-zero. Calls: [`shz_vec4_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec4_normalize_safe/) (inherited from `shz::vecN`) ### distance ```cpp float shz::vecN< CRTP, C, R >::distance(const CppType &other) const noexcept ``` Returns the magnitude of the difference between two vectors as their distance. Calls: [`shz_vec4_distance()`](https://sh4zam.com/api/vector/shz_vec4_distance/) (inherited from `shz::vecN`) ### distance_sqr ```cpp float shz::vecN< CRTP, C, R >::distance_sqr(const CppType &other) const noexcept ``` Returns the value of the distance between two vectors squared (faster than actual distance). Calls: [`shz_vec4_distance_sqr()`](https://sh4zam.com/api/vector/shz_vec4_distance_sqr/) (inherited from `shz::vecN`) ### floor ```cpp CppType shz::vecN< CRTP, C, R >::floor() const noexcept ``` Returns a new vector with the component-wise floor of the given vector. Calls: [`shz_vec4_floor()`](https://sh4zam.com/api/vector/shz_vec4_floor/) (inherited from `shz::vecN`) ### fract ```cpp CppType shz::vecN< CRTP, C, R >::fract() const noexcept ``` Returns a new vector with the fractional part of each component. Calls: [`shz_vec4_fract()`](https://sh4zam.com/api/vector/shz_vec4_fract/) (inherited from `shz::vecN`) ### inv ```cpp CppType shz::vecN< CRTP, C, R >::inv() const noexcept ``` Returns a new vector whose components are the reciprocal values of the given vector. Calls: [`shz_vec4_inv()`](https://sh4zam.com/api/vector/shz_vec4_inv/) (inherited from `shz::vecN`) ### inv_sqrtf ```cpp CppType shz::vecN< CRTP, C, R >::inv_sqrtf() const noexcept ``` Returns a new vector whose components are the inverse square root of the given vector. Calls: [`shz_vec4_inv_sqrtf()`](https://sh4zam.com/api/vector/shz_vec4_inv_sqrtf/) (inherited from `shz::vecN`) ### magnitude ```cpp float shz::vecN< CRTP, C, R >::magnitude() const noexcept ``` Returns the magnitude of the given vector. Calls: [`shz_vec4_magnitude()`](https://sh4zam.com/api/vector/shz_vec4_magnitude/) (inherited from `shz::vecN`) ### magnitude_inv ```cpp float shz::vecN< CRTP, C, R >::magnitude_inv() const noexcept ``` Returns the inverse magnitude of the given vector. Calls: [`shz_vec4_magnitude_inv()`](https://sh4zam.com/api/vector/shz_vec4_magnitude_inv/) (inherited from `shz::vecN`) ### magnitude_sqr ```cpp float shz::vecN< CRTP, C, R >::magnitude_sqr() const noexcept ``` Returns the squared magnitude of the given vector. Calls: [`shz_vec4_magnitude_sqr()`](https://sh4zam.com/api/vector/shz_vec4_magnitude_sqr/) (inherited from `shz::vecN`) ### max ```cpp float shz::vecN< CRTP, C, R >::max() const noexcept ``` Returns the maximum value of every element within the vector. Calls: [`shz_vec4_max()`](https://sh4zam.com/api/vector/shz_vec4_max/) (inherited from `shz::vecN`) ### maxv ```cpp CppType shz::vecN< CRTP, C, R >::maxv(const CppType &other) const noexcept ``` Returns a new vector with the component-wise maximum of two vectors. Calls: [`shz_vec4_maxv()`](https://sh4zam.com/api/vector/shz_vec4_maxv/) (inherited from `shz::vecN`) ### min ```cpp float shz::vecN< CRTP, C, R >::min() const noexcept ``` Returns the minimum value of every element within the vector. Calls: [`shz_vec4_min()`](https://sh4zam.com/api/vector/shz_vec4_min/) (inherited from `shz::vecN`) ### minv ```cpp CppType shz::vecN< CRTP, C, R >::minv(const CppType &other) const noexcept ``` Returns a new vector with the component-wise minimum of two vectors. Calls: [`shz_vec4_minv()`](https://sh4zam.com/api/vector/shz_vec4_minv/) (inherited from `shz::vecN`) ### move ```cpp CppType shz::vecN< CRTP, C, R >::move(const CppType &target, float maxdist) const noexcept ``` Moves the given vector towards the target by the given `maxdist`. Calls: [`shz_vec4_move()`](https://sh4zam.com/api/vector/shz_vec4_move/) (inherited from `shz::vecN`) ### neg ```cpp CppType shz::vecN< CRTP, C, R >::neg() const noexcept ``` Returns a new vector whose components are the negative values of the given vector. Calls: [`shz_vec4_neg()`](https://sh4zam.com/api/vector/shz_vec4_neg/) (inherited from `shz::vecN`) ### normalize ```cpp void shz::vecN< CRTP, C, R >::normalize() noexcept ``` Normalizes the given vector. Calls: [`shz_vec4_normalize()`](https://sh4zam.com/api/vector/shz_vec4_normalize/) (inherited from `shz::vecN`) ### normalize_safe ```cpp void shz::vecN< CRTP, C, R >::normalize_safe() noexcept ``` Normalizes the given vector, safely protecting against division-by-zero. Calls: [`shz_vec4_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec4_normalize_safe/) (inherited from `shz::vecN`) ### normalized ```cpp CppType shz::vecN< CRTP, C, R >::normalized() const noexcept ``` Return the normalized vector. Calls: [`shz_vec4_normalize()`](https://sh4zam.com/api/vector/shz_vec4_normalize/) (inherited from `shz::vecN`) ### normalized_safe ```cpp CppType shz::vecN< CRTP, C, R >::normalized_safe() const noexcept ``` Return the normalized vector, safely protecting against division-by-zero. Calls: [`shz_vec4_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec4_normalize_safe/) (inherited from `shz::vecN`) ### operator*= ```cpp CppType & shz::vecN< CRTP, C, R >::operator*=(const CppType &other) noexcept ``` Overloaded multiplication assignment operator, multiplies and accumulates a vector onto the left-hand vector. Inherited from `shz::vecN`. ### operator+= ```cpp CppType & shz::vecN< CRTP, C, R >::operator+=(const CppType &other) noexcept ``` Overloaded operator for adding and accumulating a vector onto another. Inherited from `shz::vecN`. ### operator-= ```cpp CppType & shz::vecN< CRTP, C, R >::operator-=(const CppType &other) noexcept ``` Overloaded subtraction assignment operator, subtracts a vector from the left-hand vector. Inherited from `shz::vecN`. ### operator/= ```cpp CppType & shz::vecN< CRTP, C, R >::operator/=(const CppType &other) noexcept ``` Overloaded division assignment operator, divides the left vector by the right, assigning the left to the result. Inherited from `shz::vecN`. ### project ```cpp CppType shz::vecN< CRTP, C, R >::project(const CppType &onto) const noexcept ``` Returns the vector created from projecting the given vector onto another. Calls: [`shz_vec4_project()`](https://sh4zam.com/api/vector/shz_vec4_project/) (inherited from `shz::vecN`) ### project_safe ```cpp CppType shz::vecN< CRTP, C, R >::project_safe(const CppType &onto) const noexcept ``` Returns the vector created from projecting the given vector onto another, safely protecting against division-by-zero. Calls: [`shz_vec4_project_safe()`](https://sh4zam.com/api/vector/shz_vec4_project_safe/) (inherited from `shz::vecN`) ### reflect ```cpp CppType shz::vecN< CRTP, C, R >::reflect(const CppType &normal) const noexcept ``` Returns the vector created from reflecting the given vector over the normal of a surface. Calls: [`shz_vec4_reflect()`](https://sh4zam.com/api/vector/shz_vec4_reflect/) (inherited from `shz::vecN`) ### refract ```cpp CppType shz::vecN< CRTP, C, R >::refract(const CppType &normal, float eta) const noexcept ``` Returns the vector create from refracting the given incidence vector over the normal of a surface, using the given refraction ratio index. Calls: [`shz_vec4_refract()`](https://sh4zam.com/api/vector/shz_vec4_refract/) (inherited from `shz::vecN`) ### round ```cpp CppType shz::vecN< CRTP, C, R >::round() const noexcept ``` Returns a new vector with the component-wise rounding of the given vector. Calls: [`shz_vec4_round()`](https://sh4zam.com/api/vector/shz_vec4_round/) (inherited from `shz::vecN`) ### saturate ```cpp CppType shz::vecN< CRTP, C, R >::saturate() const noexcept ``` Returns a new vector with each component clamped to \[0, 1\]. Calls: [`shz_vec4_saturate()`](https://sh4zam.com/api/vector/shz_vec4_saturate/) (inherited from `shz::vecN`) ### sign ```cpp CppType shz::vecN< CRTP, C, R >::sign() const noexcept ``` Returns a new vector with the sign of each component (-1, 0, or 1). Calls: [`shz_vec4_sign()`](https://sh4zam.com/api/vector/shz_vec4_sign/) (inherited from `shz::vecN`) ### sqrtf ```cpp CppType shz::vecN< CRTP, C, R >::sqrtf() const noexcept ``` Returns a new vector whose components are the square root of the given vector. Calls: [`shz_vec4_sqrtf()`](https://sh4zam.com/api/vector/shz_vec4_sqrtf/) (inherited from `shz::vecN`) ### swizzle ```cpp CppType shz::vecN< CRTP, C, R >::swizzle() const noexcept ``` Swizzle oeprator which takes a compile-time list of indices as non-type template arguments for the index each element should use as its new value. Calls: [`shz_vec4_swizzle()`](https://sh4zam.com/api/vector/shz_vec4_swizzle/) (inherited from `shz::vecN`) ### to ```cpp T shz::vecN< CRTP, C, R >::to() const noexcept ``` Conversion operator for going from a SH4ZAM vector type to another layout-compatible type. Inherited from `shz::vecN`. --- # shz::vecN Source: https://sh4zam.com/api/cpp/vecn/ Common C++ base structure inherited by all vector types. This struct template serves as the base class for all concrete vector types, providing: - Common API routines - Adaptor between C and C++ types - Convenience overloaded operators and STL iterators. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.hpp#L43)) - **Bases:** `C` ## Static functions ### from ```cpp static CppType shz::vecN< CRTP, C, R >::from(const auto &raw) noexcept ``` Conversion operator for going from a layout-compatible vector type to a SH4ZAM vector type. ### lerp ```cpp static CppType shz::vecN< CRTP, C, R >::lerp(const CppType &start, const CppType &end, float t) noexcept ``` Returns the vector that is linearly interpolated between the two given vectors by the `0.0f-1.0f` factor, `t`. Calls: [`shz_vec_lerp()`](https://sh4zam.com/api/vector/shz_vec_lerp/) ### step ```cpp static CppType shz::vecN< CRTP, C, R >::step(const CppType &vec, T &&edge) noexcept ``` Compares each component of the vector to the edge. 0 returned in that component if x\[i\] \< edge. Otherwise the component is 1. Calls: [`shz_vec_step()`](https://sh4zam.com/api/vector/shz_vec_step/) ### smoothstep ```cpp static CppType shz::vecN< CRTP, C, R >::smoothstep(const CppType &vec, T &&edge0, T &&edge1) noexcept ``` Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1. Calls: [`shz_vec_smoothstep()`](https://sh4zam.com/api/vector/shz_vec_smoothstep/) ### smoothstep_safe ```cpp static CppType shz::vecN< CRTP, C, R >::smoothstep_safe(const CppType &vec, T &&edge0, T &&edge1) noexcept ``` Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1. Calls: [`shz_vec_smoothstep_safe()`](https://sh4zam.com/api/vector/shz_vec_smoothstep_safe/) ## Members ### vecN ```cpp shz::vecN< CRTP, C, R >::vecN() noexcept=default shz::vecN< CRTP, C, R >::vecN(const vecN &other) noexcept=default shz::vecN< CRTP, C, R >::vecN(const CType &other) noexcept shz::vecN< CRTP, C, R >::vecN(const volatile CType &other) noexcept ``` Default constructor, does nothing. ### to ```cpp T shz::vecN< CRTP, C, R >::to() const noexcept ``` Conversion operator for going from a SH4ZAM vector type to another layout-compatible type. ### deref ```cpp CppType & shz::vecN< CRTP, C, R >::deref(const auto *raw) noexcept ``` Conversion operator for accessing an existing pointer type as though it were a refrence to a SH4ZAM type. ### operator+= ```cpp CppType & shz::vecN< CRTP, C, R >::operator+=(const CppType &other) noexcept ``` Overloaded operator for adding and accumulating a vector onto another. ### operator-= ```cpp CppType & shz::vecN< CRTP, C, R >::operator-=(const CppType &other) noexcept ``` Overloaded subtraction assignment operator, subtracts a vector from the left-hand vector. ### operator*= ```cpp CppType & shz::vecN< CRTP, C, R >::operator*=(const CppType &other) noexcept CppType & shz::vecN< CRTP, C, R >::operator*=(float other) noexcept ``` Overloaded multiplication assignment operator, multiplies and accumulates a vector onto the left-hand vector. ### operator/= ```cpp CppType & shz::vecN< CRTP, C, R >::operator/=(const CppType &other) noexcept CppType & shz::vecN< CRTP, C, R >::operator/=(float other) noexcept ``` Overloaded division assignment operator, divides the left vector by the right, assigning the left to the result. ### swizzle ```cpp CppType shz::vecN< CRTP, C, R >::swizzle() const noexcept ``` Swizzle oeprator which takes a compile-time list of indices as non-type template arguments for the index each element should use as its new value. Calls: [`shz_vec_swizzle()`](https://sh4zam.com/api/vector/shz_vec_swizzle/) ### abs ```cpp CppType shz::vecN< CRTP, C, R >::abs() const noexcept ``` Returns a new vector whose components are the absolute value of the given vector. Calls: [`shz_vec_abs()`](https://sh4zam.com/api/vector/shz_vec_abs/) ### neg ```cpp CppType shz::vecN< CRTP, C, R >::neg() const noexcept ``` Returns a new vector whose components are the negative values of the given vector. Calls: [`shz_vec_neg()`](https://sh4zam.com/api/vector/shz_vec_neg/) ### inv ```cpp CppType shz::vecN< CRTP, C, R >::inv() const noexcept ``` Returns a new vector whose components are the reciprocal values of the given vector. Calls: [`shz_vec_inv()`](https://sh4zam.com/api/vector/shz_vec_inv/) ### max ```cpp float shz::vecN< CRTP, C, R >::max() const noexcept ``` Returns the maximum value of every element within the vector. Calls: [`shz_vec_max()`](https://sh4zam.com/api/vector/shz_vec_max/) ### min ```cpp float shz::vecN< CRTP, C, R >::min() const noexcept ``` Returns the minimum value of every element within the vector. Calls: [`shz_vec_min()`](https://sh4zam.com/api/vector/shz_vec_min/) ### clamp ```cpp CppType shz::vecN< CRTP, C, R >::clamp(float min, float max) const noexcept ``` Returns a new vector whose values are the clamped components of the given vector. Calls: [`shz_vec_clamp()`](https://sh4zam.com/api/vector/shz_vec_clamp/) ### floor ```cpp CppType shz::vecN< CRTP, C, R >::floor() const noexcept ``` Returns a new vector with the component-wise floor of the given vector. Calls: [`shz_vec_floor()`](https://sh4zam.com/api/vector/shz_vec_floor/) ### ceil ```cpp CppType shz::vecN< CRTP, C, R >::ceil() const noexcept ``` Returns a new vector with the component-wise ceil of the given vector. Calls: [`shz_vec_ceil()`](https://sh4zam.com/api/vector/shz_vec_ceil/) ### round ```cpp CppType shz::vecN< CRTP, C, R >::round() const noexcept ``` Returns a new vector with the component-wise rounding of the given vector. Calls: [`shz_vec_round()`](https://sh4zam.com/api/vector/shz_vec_round/) ### fract ```cpp CppType shz::vecN< CRTP, C, R >::fract() const noexcept ``` Returns a new vector with the fractional part of each component. Calls: [`shz_vec_fract()`](https://sh4zam.com/api/vector/shz_vec_fract/) ### sign ```cpp CppType shz::vecN< CRTP, C, R >::sign() const noexcept ``` Returns a new vector with the sign of each component (-1, 0, or 1). Calls: [`shz_vec_sign()`](https://sh4zam.com/api/vector/shz_vec_sign/) ### saturate ```cpp CppType shz::vecN< CRTP, C, R >::saturate() const noexcept ``` Returns a new vector with each component clamped to \[0, 1\]. Calls: [`shz_vec_saturate()`](https://sh4zam.com/api/vector/shz_vec_saturate/) ### minv ```cpp CppType shz::vecN< CRTP, C, R >::minv(const CppType &other) const noexcept ``` Returns a new vector with the component-wise minimum of two vectors. Calls: [`shz_vec_minv()`](https://sh4zam.com/api/vector/shz_vec_minv/) ### maxv ```cpp CppType shz::vecN< CRTP, C, R >::maxv(const CppType &other) const noexcept ``` Returns a new vector with the component-wise maximum of two vectors. Calls: [`shz_vec_maxv()`](https://sh4zam.com/api/vector/shz_vec_maxv/) ### inv_sqrtf ```cpp CppType shz::vecN< CRTP, C, R >::inv_sqrtf() const noexcept ``` Returns a new vector whose components are the inverse square root of the given vector. Calls: [`shz_vec_inv_sqrtf()`](https://sh4zam.com/api/vector/shz_vec_inv_sqrtf/) ### sqrtf ```cpp CppType shz::vecN< CRTP, C, R >::sqrtf() const noexcept ``` Returns a new vector whose components are the square root of the given vector. Calls: [`shz_vec_sqrtf()`](https://sh4zam.com/api/vector/shz_vec_sqrtf/) ### dot ```cpp float shz::vecN< CRTP, C, R >::dot(const CppType &other) const noexcept vec2 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2) const noexcept vec3 shz::vecN< CRTP, C, R >::dot(const CppType &v1, const CppType &v2, const CppType &v3) const noexcept ``` Returns the dot product of the given vector and another. Calls: [`shz_vec_dot()`](https://sh4zam.com/api/vector/shz_vec_dot/) ### magnitude ```cpp float shz::vecN< CRTP, C, R >::magnitude() const noexcept ``` Returns the magnitude of the given vector. Calls: [`shz_vec_magnitude()`](https://sh4zam.com/api/vector/shz_vec_magnitude/) ### magnitude_sqr ```cpp float shz::vecN< CRTP, C, R >::magnitude_sqr() const noexcept ``` Returns the squared magnitude of the given vector. Calls: [`shz_vec_magnitude_sqr()`](https://sh4zam.com/api/vector/shz_vec_magnitude_sqr/) ### magnitude_inv ```cpp float shz::vecN< CRTP, C, R >::magnitude_inv() const noexcept ``` Returns the inverse magnitude of the given vector. Calls: [`shz_vec_magnitude_inv()`](https://sh4zam.com/api/vector/shz_vec_magnitude_inv/) ### direction ```cpp CppType shz::vecN< CRTP, C, R >::direction() const noexcept ``` Returns the direction vector resulting from normalizing the given vector. Calls: [`shz_vec_normalize()`](https://sh4zam.com/api/vector/shz_vec_normalize/) ### direction_safe ```cpp CppType shz::vecN< CRTP, C, R >::direction_safe() const noexcept ``` Returns the direction vector of a given vector, safely protecting against division-by-zero. Calls: [`shz_vec_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec_normalize_safe/) ### normalize ```cpp void shz::vecN< CRTP, C, R >::normalize() noexcept ``` Normalizes the given vector. Calls: [`shz_vec_normalize()`](https://sh4zam.com/api/vector/shz_vec_normalize/) ### normalize_safe ```cpp void shz::vecN< CRTP, C, R >::normalize_safe() noexcept ``` Normalizes the given vector, safely protecting against division-by-zero. Calls: [`shz_vec_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec_normalize_safe/) ### normalized ```cpp CppType shz::vecN< CRTP, C, R >::normalized() const noexcept ``` Return the normalized vector. Calls: [`shz_vec_normalize()`](https://sh4zam.com/api/vector/shz_vec_normalize/) ### normalized_safe ```cpp CppType shz::vecN< CRTP, C, R >::normalized_safe() const noexcept ``` Return the normalized vector, safely protecting against division-by-zero. Calls: [`shz_vec_normalize_safe()`](https://sh4zam.com/api/vector/shz_vec_normalize_safe/) ### distance ```cpp float shz::vecN< CRTP, C, R >::distance(const CppType &other) const noexcept ``` Returns the magnitude of the difference between two vectors as their distance. Calls: [`shz_vec_distance()`](https://sh4zam.com/api/vector/shz_vec_distance/) ### distance_sqr ```cpp float shz::vecN< CRTP, C, R >::distance_sqr(const CppType &other) const noexcept ``` Returns the value of the distance between two vectors squared (faster than actual distance). Calls: [`shz_vec_distance_sqr()`](https://sh4zam.com/api/vector/shz_vec_distance_sqr/) ### move ```cpp CppType shz::vecN< CRTP, C, R >::move(const CppType &target, float maxdist) const noexcept ``` Moves the given vector towards the target by the given `maxdist`. Calls: [`shz_vec_move()`](https://sh4zam.com/api/vector/shz_vec_move/) ### reflect ```cpp CppType shz::vecN< CRTP, C, R >::reflect(const CppType &normal) const noexcept ``` Returns the vector created from reflecting the given vector over the normal of a surface. Calls: [`shz_vec_reflect()`](https://sh4zam.com/api/vector/shz_vec_reflect/) ### refract ```cpp CppType shz::vecN< CRTP, C, R >::refract(const CppType &normal, float eta) const noexcept ``` Returns the vector create from refracting the given incidence vector over the normal of a surface, using the given refraction ratio index. Calls: [`shz_vec_refract()`](https://sh4zam.com/api/vector/shz_vec_refract/) ### project ```cpp CppType shz::vecN< CRTP, C, R >::project(const CppType &onto) const noexcept ``` Returns the vector created from projecting the given vector onto another. Calls: [`shz_vec_project()`](https://sh4zam.com/api/vector/shz_vec_project/) ### project_safe ```cpp CppType shz::vecN< CRTP, C, R >::project_safe(const CppType &onto) const noexcept ``` Returns the vector created from projecting the given vector onto another, safely protecting against division-by-zero. Calls: [`shz_vec_project_safe()`](https://sh4zam.com/api/vector/shz_vec_project_safe/) ### angle_between ```cpp float shz::vecN< CRTP, C, R >::angle_between(const CppType &other) const noexcept ``` Returns the angle between the given vector and another, in radians. Calls: [`shz_vec_angle_between()`](https://sh4zam.com/api/vector/shz_vec_angle_between/) ### angles ```cpp auto shz::vecN< CRTP, C, R >::angles() const noexcept ``` Returns the angle(s) created between the given vector axis and the +X axis, in radians. Calls: [`shz_vec_angles()`](https://sh4zam.com/api/vector/shz_vec_angles/) ### operator== ```cpp bool operator==(const CppType &lhs, const CppType &rhs) noexcept ``` Overloaded equality operator, for comparing vectors. ### operator- ```cpp CppType operator-(const CppType &vec) noexcept ``` Overloaded unary negation operator, returns the negated vector. --- # shz::version Source: https://sh4zam.com/api/cpp/version/ Class representing a full SH4ZAM API version. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.hpp#L21)) ## Static functions ### compiled ```cpp static constexpr version compiled() noexcept ``` Compile-time version of SH4ZAM headers which are being included. ### linked ```cpp static version linked() noexcept ``` Link-time version of SH4ZAM library which was linked against. Calls: [`shz_version_linked()`](https://sh4zam.com/api/version/shz_version_linked/) ## Members ### value_ ```cpp shz_version_t value_ ``` Private packed value member. ### version ```cpp version(shz_version_t value) noexcept version(uint8_t major, uint16_t minor, uint8_t patch) noexcept ``` Constructs a version from the given full value. ### operator shz_version_t ```cpp operator shz_version_t() const noexcept ``` Implicit conversion operator to make this class automatically comparable to a `uint32_t`. ### operator= ```cpp version operator=(uint32_t rhs) noexcept ``` Assignment operator for assigning a version to a full version ID value. ### major ```cpp uint8_t major() const noexcept ``` Extracts the major component value from a full version. ### minor ```cpp uint16_t minor() const noexcept ``` Extracts the minor component value from a full version. ### patch ```cpp uint8_t patch() const noexcept ``` Extracts the patch component value from a full version. --- # shz::xmtrx Source: https://sh4zam.com/api/cpp/xmtrx/ Static structure around the 4x4 XMTRX FP register back-bank. This structure provides the C++ bindings to the XMTRX API as a series of static member functions wrapping the C API. - **Header:** `#include ` ([source](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.hpp#L34)) ## Static functions ### read ```cpp static float read(reg xf) noexcept ``` C++ wrapper around `shz_xmtrx_read()`. Calls: [`shz_xmtrx_read()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_read/), [`shz_xmtrx_reg()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_reg/) ### write ```cpp static void write(reg xf, float value) noexcept ``` C++ wrapper around `shz_xmtrx_write()`. Calls: [`shz_xmtrx_write()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_write/), [`shz_xmtrx_reg()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_reg/) ### read_row ```cpp static vec4 read_row(unsigned int index) noexcept ``` C++ wrapper around `shz_xmtrx_read_row()`. Calls: [`shz_xmtrx_read_row()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_read_row/) ### read_col ```cpp static vec4 read_col(unsigned int index) noexcept ``` C++ wrapper around `shz_xmtrx_read_col()`. Calls: [`shz_xmtrx_read_col()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_read_col/) ### write_row ```cpp static void write_row(unsigned int index, const vec4 &vector) noexcept ``` C++ wrapper around `shz_xmtrx_write_row()`. Calls: [`shz_xmtrx_write_row()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_write_row/) ### write_col ```cpp static void write_col(unsigned int index, const vec4 &vector) noexcept ``` C++ wrapper around `shz_xmtrx_write_col()`. Calls: [`shz_xmtrx_write_col()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_write_col/) ### swap_rows ```cpp static void swap_rows(unsigned int index1, unsigned int index2) noexcept ``` C++ wrapper around `shz_xmtrx_swap_rows()`. Calls: [`shz_xmtrx_swap_rows()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_swap_rows/) ### swap_cols ```cpp static void swap_cols(unsigned int index1, unsigned int index2) noexcept ``` C++ wrapper around `shz_xmtrx_swap_cols()`. Calls: [`shz_xmtrx_swap_cols()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_swap_cols/) ### load ```cpp static void load(const shz_mat4x4_t &mat4) noexcept static void load(const float cArray[16]) noexcept static void load(const std::array< float, 16 > &array) noexcept static void load(const shz_mat3x4_t &mat) noexcept static void load(const shz_mat2x2_t &mat) noexcept static void load(const shz_mat3x3_t &mat) noexcept ``` C++ wrapper around `shz_xmtrx_load_4x4()`. Calls: [`shz_xmtrx_load_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_4x4/), [`shz_xmtrx_load_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_unaligned_4x4/), [`shz_xmtrx_load_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x4/), [`shz_xmtrx_load_2x2()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_2x2/), [`shz_xmtrx_load_3x3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x3/) ### load_transpose ```cpp static void load_transpose(const shz_mat4x4_t &mat4) noexcept static void load_transpose(const float cArray[16]) noexcept static void load_transpose(const std::array< float, 16 > &array) noexcept static void load_transpose(const shz_mat3x4_t &mat) noexcept static void load_transpose(const shz_mat3x3_t &mat) noexcept ``` C++ wrapper around `shz_xmtrx_load_transpose_4x4()`. Calls: [`shz_xmtrx_load_transpose_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_4x4/), [`shz_xmtrx_load_transpose_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_unaligned_4x4/), [`shz_xmtrx_load_transpose_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_3x4/), [`shz_xmtrx_load_transpose_3x3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_3x3/) ### load_wxyz ```cpp static void load_wxyz(const shz_mat4x4_t &mat4) noexcept ``` C++ wrapper around `shz_xmtrx_load_wxyz_4x4()`. Calls: [`shz_xmtrx_load_wxyz_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_wxyz_4x4/) ### load_cols ```cpp static void load_cols(const shz_vec4_t &c1, const shz_vec4_t &c2, const shz_vec4_t &c3, const shz_vec4_t &c4) noexcept static void load_cols(const shz_vec3_t &c1, const shz_vec3_t &c2, const shz_vec3_t &c3, const shz_vec3_t &c4) noexcept ``` C++ wrapper around `shz_xmtrx_load_cols_4x4()`. Calls: [`shz_xmtrx_load_cols_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_4x4/), [`shz_xmtrx_load_cols_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_3x4/) ### load_rows ```cpp static void load_rows(const shz_vec4_t &r1, const shz_vec4_t &r2, const shz_vec4_t &r3, const shz_vec4_t &r4) noexcept static void load_rows(const shz_vec4_t &r1, const shz_vec4_t &r2, const shz_vec4_t &r3) noexcept ``` C++ wrapper around `shz_xmtrx_load_rows_4x4()`. Calls: [`shz_xmtrx_load_rows_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_rows_4x4/), [`shz_xmtrx_load_rows_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_rows_3x4/) ### store ```cpp static void store(shz_mat4x4_t *mat) noexcept static void store(float cArray[16]) noexcept static void store(shz_mat3x4_t *mat) noexcept static void store(std::array< float, 16 > *array) noexcept static void store(shz_mat2x2_t *mat) noexcept static void store(shz_mat3x3_t *mat) noexcept ``` C++ wrapper around `shz_xmtrx_store_4x4()`. Calls: [`shz_xmtrx_store_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_4x4/), [`shz_xmtrx_store_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_unaligned_4x4/), [`shz_xmtrx_store_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x4/), [`shz_xmtrx_store_2x2()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_2x2/), [`shz_xmtrx_store_3x3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x3/) ### store_transpose ```cpp static void store_transpose(shz_mat4x4_t *mat) noexcept static void store_transpose(float cArray[16]) noexcept static void store_transpose(std::array< float, 16 > *array) noexcept static void store_transpose(shz_mat3x4_t *mat) noexcept static void store_transpose(shz_mat3x3_t *mat) noexcept ``` C++ wrapper around `shz_xmtrx_store_transpose_4x4()`. Calls: [`shz_xmtrx_store_transpose_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_4x4/), [`shz_xmtrx_store_transpose_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_unaligned_4x4/), [`shz_xmtrx_store_transpose_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_3x4/), [`shz_xmtrx_store_transpose_3x3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_3x3/) ### init_identity ```cpp static void init_identity() noexcept ``` C++ wrapper around `shz_xmtrx_init_identity()`. Calls: [`shz_xmtrx_init_identity()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_identity/) ### init_identity_safe ```cpp static void init_identity_safe() noexcept ``` C++ wrapper around `shz_xmtrx_init_identity_safe()`. Calls: [`shz_xmtrx_init_identity()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_identity/) ### init_zero ```cpp static void init_zero() noexcept ``` C++ wrapper around `shz_xmtrx_init_zero()`. Calls: [`shz_xmtrx_init_zero()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_zero/) ### init_one ```cpp static void init_one() noexcept ``` C++ wrapper around `shz_xmtrx_init_one()`. Calls: [`shz_xmtrx_init_one()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_one/) ### init_fill ```cpp static void init_fill(float value) noexcept ``` C++ wrapper around `shz_xmtrx_init_fill()`. Calls: [`shz_xmtrx_init_fill()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_fill/) ### init_translation ```cpp static void init_translation(float x, float y, float z) noexcept static void init_translation(const vec3 &v) noexcept ``` C++ wrapper around `shz_xmtrx_init_translation()`. Calls: [`shz_xmtrx_init_translation()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_translation/) ### init_scale ```cpp static void init_scale(float x, float y, float z) noexcept static void init_scale(const vec3 &v) noexcept ``` C++ wrapper around `shz_xmtrx_init_scale()`. Calls: [`shz_xmtrx_init_scale()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_scale/) ### init_rotation_x ```cpp static void init_rotation_x(float x) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_x()`. Calls: [`shz_xmtrx_init_rotation_x()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_x/) ### init_rotation_y ```cpp static void init_rotation_y(float y) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_y()`. Calls: [`shz_xmtrx_init_rotation_y()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_y/) ### init_rotation_z ```cpp static void init_rotation_z(float z) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_z()`. Calls: [`shz_xmtrx_init_rotation_z()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_z/) ### init_rotation_xyz ```cpp static void init_rotation_xyz(float x, float y, float z) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_xyz()`. Calls: [`shz_xmtrx_init_rotation_xyz()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_xyz/) ### init_rotation_zyx ```cpp static void init_rotation_zyx(float z, float y, float x) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_zyx()`. Calls: [`shz_xmtrx_init_rotation_zyx()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_zyx/) ### init_rotation_zxy ```cpp static void init_rotation_zxy(float z, float x, float y) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_zxy()`. Calls: [`shz_xmtrx_init_rotation_zxy()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_zxy/) ### init_rotation_yxz ```cpp static void init_rotation_yxz(float y, float x, float z) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_yxz()`. Calls: [`shz_xmtrx_init_rotation_yxz()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_yxz/) ### init_rotation ```cpp static void init_rotation(float angle, float x, float y, float z) noexcept static void init_rotation(float angle, const vec3 &axis) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation()`. Calls: [`shz_xmtrx_init_rotation()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation/) ### init_rotation_dir ```cpp static void init_rotation_dir(float angle, const vec3 &dir) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_dir()`. Calls: [`shz_xmtrx_init_rotation_dir()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_dir/) ### init_diagonal ```cpp static void init_diagonal(float x, float y, float z, float w) noexcept static void init_diagonal(const vec4 &v) noexcept ``` C++ wrapper around `shz_xmtrx_init_diagonal()`. Calls: [`shz_xmtrx_init_diagonal()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_diagonal/) ### init_upper_triangular ```cpp static void init_upper_triangular(float col1, const vec2 &col2, const vec3 &col3, const vec4 &col4) noexcept ``` C++ wrapper around `shz_xmtrx_init_upper_triangular()`. Calls: [`shz_xmtrx_init_upper_triangular()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_upper_triangular/) ### init_lower_triangular ```cpp static void init_lower_triangular(const vec4 &col1, const vec3 &col2, const vec2 &col3, float col4) noexcept ``` C++ wrapper around `shz_xmtrx_init_lower_triangular()`. Calls: [`shz_xmtrx_init_lower_triangular()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_lower_triangular/) ### init_symmetric_skew ```cpp static void init_symmetric_skew(float x, float y, float z) noexcept ``` C++ wrapper around `shz_xmtrx_init_symmetric_skew()`. Calls: [`shz_xmtrx_init_symmetric_skew()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_symmetric_skew/) ### init_outer_product ```cpp static void init_outer_product(const vec4 &a, const vec4 &b) noexcept ``` C++ wrapper around `shz_xmtrx_init_outer_product()`. Calls: [`shz_xmtrx_init_outer_product()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_outer_product/) ### init_screen ```cpp static void init_screen(float width, float height) noexcept ``` C++ wrapper around `shz_xmtrx_init_screen()`. Calls: [`shz_xmtrx_init_screen()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_screen/) ### init_lookat ```cpp static void init_lookat(const vec3 &eye, const vec3 ¢er, const vec3 &up) noexcept ``` C++ wrapper around `shz_xmtrx_init_lookat()`. Calls: [`shz_xmtrx_init_lookat()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_lookat/) ### init_ortho ```cpp static void init_ortho(float left, float right, float bottom, float top, float znear, float zfar) noexcept ``` C++ wrapper around `shz_xmtrx_init_ortho()`. Calls: [`shz_xmtrx_init_ortho()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_ortho/) ### init_frustum ```cpp static void init_frustum(float left, float right, float bottom, float top, float znear, float zfar) noexcept ``` C++ wrapper around `shz_xmtrx_init_frustum()`. Calls: [`shz_xmtrx_init_frustum()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_frustum/) ### init_perspective ```cpp static void init_perspective(float fov, float aspect, float znear) noexcept ``` C++ wrapper around `shz_xmtrx_init_perspective()`. Calls: [`shz_xmtrx_init_perspective()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_perspective/) ### init_rotation_quat ```cpp static void init_rotation_quat(const quat &q) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_quat()`. Calls: [`shz_xmtrx_init_rotation_quat()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_quat/) ### init_permutation_wxyz ```cpp static void init_permutation_wxyz() noexcept ``` C++ wrapper around `shz_xmtrx_init_permutation_wxyz()`. Calls: [`shz_xmtrx_init_permutation_wxyz()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_wxyz/) ### init_permutation_yzwx ```cpp static void init_permutation_yzwx() noexcept ``` C++ wrapper around `shz_xmtrx_init_permutation_yzwx()`. Calls: [`shz_xmtrx_init_permutation_yzwx()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_yzwx/) ### init_permutation_wzyx ```cpp static void init_permutation_wzyx() noexcept ``` C++ wrapper around `shz_xmtrx_init_permutation_wzyx()`. Calls: [`shz_xmtrx_init_permutation_wzyx()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_wzyx/) ### apply ```cpp static void apply(const shz_mat4x4_t &mat4) noexcept static void apply(const float cArray[16]) noexcept static void apply(const std::array< float, 16 > &array) noexcept static void apply(const shz_mat3x4_t &mat) noexcept static void apply(const shz_mat3x3_t &mat) noexcept ``` C++ wrapper around `shz_xmtrx_apply_4x4()`. Calls: [`shz_xmtrx_apply_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_4x4/), [`shz_xmtrx_apply_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_unaligned_4x4/), [`shz_xmtrx_apply_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x4/), [`shz_xmtrx_apply_3x3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x3/) ### apply_transpose ```cpp static void apply_transpose(const shz_mat4x4_t &mat4) noexcept static void apply_transpose(const float cArray[16]) noexcept static void apply_transpose(const std::array< float, 16 > &array) noexcept static void apply_transpose(const shz_mat3x4_t &mat) noexcept static void apply_transpose(const shz_mat3x3_t &mat) noexcept ``` C++ wrapper around `shz_xmtrx_apply_transpose_4x4()`. Calls: [`shz_xmtrx_apply_transpose_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_4x4/), [`shz_xmtrx_apply_transpose_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_unaligned_4x4/), [`shz_xmtrx_apply_transpose_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_3x4/), [`shz_xmtrx_apply_transpose_3x3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_3x3/) ### apply_reverse ```cpp static void apply_reverse(const shz_mat4x4_t &mat4) noexcept static void apply_reverse(const float cArray[16]) noexcept static void apply_reverse(const std::array< float, 16 > &array) noexcept static void apply_reverse(const shz_mat3x4_t &mat) noexcept ``` C++ wrapper around `shz_xmtrx_apply_reverse_4x4()`. Calls: [`shz_xmtrx_apply_reverse_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_4x4/), [`shz_xmtrx_apply_reverse_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_unaligned_4x4/), [`shz_xmtrx_apply_reverse_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_3x4/) ### apply_reverse_transpose ```cpp static void apply_reverse_transpose(const shz_mat4x4_t &mat4) noexcept static void apply_reverse_transpose(const float cArray[16]) noexcept static void apply_reverse_transpose(const std::array< float, 16 > &array) noexcept static void apply_reverse_transpose(const shz_mat3x4_t &mat) noexcept ``` C++ wrapper around `shz_xmtrx_apply_reverse_transpose_4x4()`. Calls: [`shz_xmtrx_apply_reverse_transpose_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_4x4/), [`shz_xmtrx_apply_reverse_transpose_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_unaligned_4x4/), [`shz_xmtrx_apply_reverse_transpose_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_3x4/) ### apply_translation ```cpp static void apply_translation(float x, float y, float z) noexcept static void apply_translation(const vec3 &v) noexcept ``` C++ wrapper around `shz_xmtrx_apply_translation()`. Calls: [`shz_xmtrx_apply_translation()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_translation/) ### apply_scale ```cpp static void apply_scale(float x, float y, float z) noexcept static void apply_scale(const vec3 &v) noexcept ``` C++ wrapper around `shz_xmtrx_apply_scale()`. Calls: [`shz_xmtrx_apply_scale()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_scale/) ### apply_rotation_x ```cpp static void apply_rotation_x(float x) noexcept ``` C++ wrapper around `shz_xmtrx_apply_rotation_x()`. Calls: [`shz_xmtrx_apply_rotation_x()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_x/) ### apply_rotation_y ```cpp static void apply_rotation_y(float y) noexcept ``` C++ wrapper around `shz_xmtrx_apply_rotation_y()`. Calls: [`shz_xmtrx_apply_rotation_y()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_y/) ### apply_rotation_z ```cpp static void apply_rotation_z(float z) noexcept ``` C++ wrapper around `shz_xmtrx_apply_rotation_z()`. Calls: [`shz_xmtrx_apply_rotation_z()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_z/) ### apply_rotation_xyz ```cpp static void apply_rotation_xyz(float x, float y, float z) noexcept ``` C++ wrapper around `shz_xmtrx_init_rotation_xyz()`. Calls: [`shz_xmtrx_apply_rotation_xyz()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_xyz/) ### apply_rotation_zyx ```cpp static void apply_rotation_zyx(float z, float y, float x) noexcept ``` C++ wrapper around `shz_xmtrx_apply_rotation_zyx()`. Calls: [`shz_xmtrx_apply_rotation_zyx()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zyx/) ### apply_rotation_zxy ```cpp static void apply_rotation_zxy(float z, float x, float y) noexcept ``` C++ wrapper around `shz_xmtrx_apply_rotation_zxy()`. Calls: [`shz_xmtrx_apply_rotation_zxy()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zxy/) ### apply_rotation_yxz ```cpp static void apply_rotation_yxz(float y, float x, float z) noexcept ``` C++ wrapper around `shz_xmtrx_apply_rotation_yxz()`. Calls: [`shz_xmtrx_apply_rotation_yxz()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_yxz/) ### apply_rotation ```cpp static void apply_rotation(float angle, float x, float y, float z) noexcept static void apply_rotation(float angle, const vec3 &axis) noexcept ``` Calls: [`shz_xmtrx_apply_rotation()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation/) ### apply_rotation_quat ```cpp static void apply_rotation_quat(const quat &q) noexcept ``` C++ wrapper around `shz_xmtrx_apply_rotation_quat()`. Calls: [`shz_xmtrx_apply_rotation_quat()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_quat/) ### apply_lookat ```cpp static void apply_lookat(const vec3 &eye, const vec3 ¢er, const vec3 &up) noexcept ``` C++ wrapper around `shz_xmtrx_apply_lookat()`. Calls: [`shz_xmtrx_apply_lookat()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_lookat/) ### apply_ortho ```cpp static void apply_ortho(float left, float right, float bottom, float top, float znear, float zfar) noexcept ``` C++ wrapper around `shz_xmtrx_apply_ortho()`. Calls: [`shz_xmtrx_apply_ortho()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_ortho/) ### apply_frustum ```cpp static void apply_frustum(float left, float right, float bottom, float top, float znear, float zfar) noexcept ``` C++ wrapper around `shz_xmtrx_apply_frustum()`. Calls: [`shz_xmtrx_apply_frustum()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_frustum/) ### apply_perspective ```cpp static void apply_perspective(float fov, float aspect, float znear) noexcept ``` C++ wrapper around `shz_xmtrx_apply_perspective()`. Calls: [`shz_xmtrx_apply_perspective()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_perspective/) ### apply_symmetric_skew ```cpp static void apply_symmetric_skew(float x, float y, float z) noexcept ``` C++ wrapper around `shz_xmtrx_apply_symmetric_skew()`. Calls: [`shz_xmtrx_apply_symmetric_skew()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_symmetric_skew/) ### apply_screen ```cpp static void apply_screen(float width, float height) noexcept ``` C++ wrapper around `shz_xmtrx_apply_screen()`. Calls: [`shz_xmtrx_apply_screen()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_screen/) ### apply_permutation_wxyz ```cpp static void apply_permutation_wxyz() noexcept ``` C++ wrapper around `shz_xmtrx_apply_permutation_wxyz()`. Calls: [`shz_xmtrx_apply_permutation_wxyz()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_wxyz/) ### apply_permutation_yzwx ```cpp static void apply_permutation_yzwx() noexcept ``` C++ wrapper around `shz_xmtrx_apply_permutation_yzwx()`. Calls: [`shz_xmtrx_apply_permutation_yzwx()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_yzwx/) ### apply_permutation_wzyx ```cpp static void apply_permutation_wzyx() noexcept ``` C++ wrapper around `shz_xmtrx_apply_permutation_wzyx()`. Calls: [`shz_xmtrx_apply_permutation_wzyx()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_wzyx/) ### apply_self ```cpp static void apply_self() noexcept ``` C++ wrapper around `shz_xmtrx_apply_self()`. Calls: [`shz_xmtrx_apply_self()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_self/) ### translate ```cpp static void translate(float x, float y, float z) noexcept static void translate(vec3 v) noexcept ``` C++ wrapper around `shz_xmtrx_translate()`. Calls: [`shz_xmtrx_translate()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_translate/) ### scale ```cpp static void scale(float x, float y, float z) noexcept static void scale(vec3 v) noexcept ``` C++ wrapper around `shz_xmtrx_scale()`. Calls: [`shz_xmtrx_scale()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_scale/) ### rotate_x ```cpp static void rotate_x(float radians) noexcept ``` C++ wrapper around `shz_xmtrx_rotate_x()`. Calls: [`shz_xmtrx_rotate_x()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_x/) ### rotate_y ```cpp static void rotate_y(float radians) noexcept ``` C++ wrapper around `shz_xmtrx_rotate_x()`. Calls: [`shz_xmtrx_rotate_y()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_y/) ### rotate_z ```cpp static void rotate_z(float radians) noexcept ``` C++ wrapper around `shz_xmtrx_rotate_x()`. Calls: [`shz_xmtrx_rotate_z()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_z/) ### rotate_xyz ```cpp static void rotate_xyz(float x, float y, float z) noexcept ``` C++ wrapper around `shz_xmtrx_rotate_xyz()`. Calls: [`shz_xmtrx_rotate_xyz()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_xyz/) ### rotate_zyx ```cpp static void rotate_zyx(float z, float y, float x) noexcept ``` C++ wrapper around `shz_xmtrx_rotate_zyx()`. Calls: [`shz_xmtrx_rotate_zyx()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_zyx/) ### rotate_zxy ```cpp static void rotate_zxy(float z, float x, float y) noexcept ``` C++ wrapper around `shz_xmtrx_rotate_zxy()`. Calls: [`shz_xmtrx_rotate_zxy()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_zxy/) ### rotate_yxz ```cpp static void rotate_yxz(float y, float x, float z) noexcept ``` C++ wrapper around `shz_xmtrx_rotate_yxz()`. Calls: [`shz_xmtrx_rotate_yxz()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_yxz/) ### rotate ```cpp static void rotate(float radians, float x, float y, float z) noexcept static void rotate(float radians, const vec3 &axis) noexcept ``` C++ wrapper around `shz_xmtrx_rotate()`. Calls: [`shz_xmtrx_rotate()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate/) ### translate_reverse ```cpp static void translate_reverse(float x, float y, float z) noexcept static void translate_reverse(const shz::vec3 &pos) noexcept ``` Pre-multiplies and accumulates XMTRX onto the 3D translation matrix with the given components. Calls: [`shz_xmtrx_translate_reverse()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_translate_reverse/) ### scale_reverse ```cpp static void scale_reverse(float x, float y, float z) noexcept static void scale_reverse(const shz::vec3 &size) noexcept ``` Pre-multiplies and accumulatse XMTRX onto the 3D scaling matrix with the given components. Calls: [`shz_xmtrx_scale_reverse()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_scale_reverse/) ### load_apply ```cpp static void load_apply(const shz_mat4x4_t &mat1, const shz_mat4x4_t &mat2) noexcept static void load_apply(const float matrix1[16], const float matrix2[16]) noexcept static void load_apply(const shz_mat3x4_t &mat1, const shz_mat3x4_t &mat2) noexcept ``` C++ wrapper around `shz_xmtrx_load_apply_4x4()`. Calls: [`shz_xmtrx_load_apply_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_4x4/), [`shz_xmtrx_load_apply_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_unaligned_4x4/), [`shz_xmtrx_load_apply_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_3x4/) ### apply_store ```cpp static void apply_store(shz_mat4x4_t *out, const shz_mat4x4_t &in) noexcept static void apply_store(float out[16], const float in[16]) noexcept ``` C++ wrapper around `shz_xmtrx_apply_store_4x4()`. Calls: [`shz_xmtrx_apply_store_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_store_4x4/), [`shz_xmtrx_apply_store_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_store_unaligned_4x4/) ### load_apply_store ```cpp static void load_apply_store(shz_mat4x4_t *dst, const shz_mat4x4_t &mat1, const shz_mat4x4_t &mat2) noexcept static void load_apply_store(float out[16], const float matrix1[16], const float matrix2[16]) noexcept static void load_apply_store(shz_mat3x4_t *dst, const shz_mat3x4_t &mat1, const shz_mat3x4_t &mat2) noexcept static void load_apply_store(shz_mat3x3_t *dst, const shz_mat3x3_t &mat1, const shz_mat3x3_t &mat2) noexcept ``` C++ wrapper around `shz_xmtrx_load_apply_store_4x4()`. Calls: [`shz_xmtrx_load_apply_store_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_4x4/), [`shz_xmtrx_load_apply_store_unaligned_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_unaligned_4x4/), [`shz_xmtrx_load_apply_store_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_3x4/), [`shz_xmtrx_load_apply_store_3x3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_3x3/) ### transform ```cpp static vec4 transform(const vec4 &in) noexcept static vec3 transform(const vec3 &in) noexcept static vec2 transform(const vec2 &in) noexcept ``` C++ wrapper around `shz_xmtrx_transform_vec4()`. Calls: [`shz_xmtrx_transform_vec4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec4/), [`shz_xmtrx_transform_vec3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec3/), [`shz_xmtrx_transform_vec2()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec2/) ### transform_point ```cpp static vec3 transform_point(const vec3 &pt) noexcept static vec2 transform_point(const vec2 &pt) noexcept ``` C++ wrapper around `shz_xmtrx_transform_point3()`. Calls: [`shz_xmtrx_transform_point3()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point3/), [`shz_xmtrx_transform_point2()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point2/) ### set_translation ```cpp static void set_translation(float x, float y, float z) noexcept static void set_translation(const vec3 &v) noexcept ``` C++ wrapper around `shz_xmtrx_set_translation()`. Calls: [`shz_xmtrx_set_translation()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_set_translation/) ### set_scale ```cpp static void set_scale(float x, float y, float z) noexcept static void set_scale(const shz::vec3 &size) noexcept ``` Sets only the inner 3x3 submatrix to be a 3D scale matrix with the given components. Calls: [`shz_xmtrx_set_scale()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_set_scale/) ### get_translation ```cpp static vec3 get_translation() noexcept ``` C++ wrapper around `shz_xmtrx_set_translation()`. Calls: [`shz_xmtrx_get_translation()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_get_translation/) ### get_scale ```cpp static vec3 get_scale() noexcept ``` Returns the scaling components from the inner 3x3 matrix of XMTRX, as a 3D vector. Calls: [`shz_xmtrx_get_scale()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_get_scale/) ### add ```cpp static void add(const shz_mat4x4_t &mat) noexcept ``` C++ wrapper around `shz_xmtrx_add_4x4()`. Calls: [`shz_xmtrx_add_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_add_4x4/) ### sub ```cpp static void sub(const shz_mat4x4_t &mat) noexcept ``` C++ wrapper around `shz_xmtrx_sub_4x4()`. Calls: [`shz_xmtrx_sub_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_sub_4x4/) ### transpose ```cpp static void transpose() noexcept ``` C++ wrapper around `shz_xmtrx_transpose()`. Calls: [`shz_xmtrx_transpose()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transpose/) ### negate ```cpp static void negate() noexcept ``` C++ wrapper around `shz_xmtrx_negate()`. Calls: [`shz_xmtrx_negate()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_negate/) ### abs ```cpp static void abs() noexcept ``` C++ wrapper around `shz_xmtrx_abs()`. Calls: [`shz_xmtrx_abs()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_abs/) ### to_quat ```cpp static quat to_quat() noexcept ``` C++ wrapper around `shz_xmtrx_to_quat()`. Calls: [`shz_xmtrx_to_quat()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_to_quat/) ### determinant ```cpp static float determinant() noexcept ``` C++ wrapper around `shz_xmtrx_determinant()`. Calls: [`shz_xmtrx_determinant()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_determinant/) ### invert ```cpp static void invert() noexcept ``` C++ wrapper around `shz_xmtrx_invert()`. Calls: [`shz_xmtrx_invert()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_invert/) ### blend ```cpp static void blend(const shz_mat4x4_t &matrix, float weight) noexcept static void blend(const shz_mat3x4_t &matrix, float weight) noexcept ``` Adds and accumulates a scaled 4x4 matrix onto XMTRX. Calls: [`shz_xmtrx_blend_4x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_4x4/), [`shz_xmtrx_blend_3x4()`](https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_3x4/) ## Members ### reg ```cpp ``` FP back-bank registers comprising XMTRX. ### reg_t ```cpp using reg_t = reg ``` Non-POSIX style `reg_t` alias. --- # Matrix API Source: https://sh4zam.com/api/matrix/ > In-memory matrix manipulation for 4x4 and smaller matrices These types and their corresponding functions are for working with matrices stored within memory, as opposed to being preloaded within the XMTRX back-bank of FP registers. Typically this is desirable for one-off operations where there is no batching of matrix operations, especially when clobbering XMTRX is undesirable. Matrices are column-major, as with GL, and `shz_mat4x4_t` must be aligned on 8-byte boundaries unless you use an `_unaligned` routine. Beware that some of these routines clobber the matrix currently loaded as the active 4x4 matrix, XMTRX. - **C header:** `#include ` - **C++ header:** `#include ` - **C++ types:** [`shz::mat4x4`](https://sh4zam.com/api/cpp/mat4x4/) - **Symbols:** 120 ## Verb model For most transform types this API offers several versions of the same operation. Using translation as the example: | Verb | Meaning | | --- | --- | | `init_*` | **Initializes** the whole matrix to the given transform, setting the other components to identity. | | `set_*` | **Sets** only the values corresponding to the given transform, leaving the others alone. | | `apply_*` | **Applies** the transform, updating only the affected values based on their current values (additively for translation, multiplicatively for scaling and rotation). | | `translate / scale / rotate_*` | **GL-style**: multiplies and accumulates the matrix by a matrix initialized to the given transform. The most general form. | | `load_* / store_*` | Moves a matrix between memory and XMTRX. `load_apply_*` and `load_apply_store_*` are fused combinations. | | `transform_*` | Transforms vectors or points. For `vec3` variants, `transform_point*` implies w = 1 and `transform_vec*` implies w = 0. | ## Suffixes Suffixes used in this module. The full list is in [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. - `_safe`: Guards degenerate input (zero-length vectors, zero denominators) at a small cost. ## Initialization Routines for fully initializing a matrix. | Symbol | Description | | --- | --- | | [`shz_mat4x4_init_identity`](https://sh4zam.com/api/matrix/shz_mat4x4_init_identity/) | Initializes the given matrix to the 4x4 identity matrix. | | [`shz_mat4x4_init_identity_safe`](https://sh4zam.com/api/matrix/shz_mat4x4_init_identity_safe/) | Safely initializes the given matrix to the 4x4 identity matrix. | | [`shz_mat4x4_init_zero`](https://sh4zam.com/api/matrix/shz_mat4x4_init_zero/) | Initializes the given matrix with all 0s for its element values. | | [`shz_mat4x4_init_one`](https://sh4zam.com/api/matrix/shz_mat4x4_init_one/) | Initializes the given matrix with all 1s for its element values. | | [`shz_mat4x4_init_fill`](https://sh4zam.com/api/matrix/shz_mat4x4_init_fill/) | Initializes the given matrix with all elements assigned to the given value. | | [`shz_mat4x4_init_translation`](https://sh4zam.com/api/matrix/shz_mat4x4_init_translation/) | Initializes the given matrix to a 3D translation matrix with the given coordinates. | | [`shz_mat4x4_init_scale`](https://sh4zam.com/api/matrix/shz_mat4x4_init_scale/) | Initializes the given matrix to a 3D scaling matrix with the given dimensions. | | [`shz_mat4x4_init_rotation_x`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_x/) | Initializes the given matrix to a 3D rotation matrix by `xAngle` radians over the X-axis. | | [`shz_mat4x4_init_rotation_y`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_y/) | Initializes the given matrix to a 3D rotation matrix by `yAngle` radians over the Y-axis. | | [`shz_mat4x4_init_rotation_z`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_z/) | Initializes the given matrix to a 3D rotation matrix by `zAngle` radians over the Z-axis. | | [`shz_mat4x4_init_rotation_xyz`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_xyz/) | Initializes the given matrix to a 3D rotation matrix from the intrinsic rotation created by the given Tait-Bryan X-Y-Z angles. | | [`shz_mat4x4_init_rotation_zyx`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_zyx/) | Initializes the given matrix to a 3D rotation matrix from the intrinsic rotation created by the given Tait-Bryan Z-Y-X angles. | | [`shz_mat4x4_init_rotation_zxy`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_zxy/) | Initializes the given matrix to a 3D rotation matrix from the intrinsic rotation created by the given Tait-Bryan Z-X-Y angles. | | [`shz_mat4x4_init_rotation_yxz`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_yxz/) | Initializes the given matrix to a 3D rotation matrix from the intrinsic rotation created by the given Tait-Bryan Y-X-Z angles. | | [`shz_mat4x4_init_rotation`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation/) | Initializes the given 4x4 matrix to a 3D rotation matrix of `angle` radians about the vector with the given components. | | [`shz_mat4x4_init_rotation_dir`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_dir/) | Initializes the given 4x4 matrix to contain a 3D rotation matrix of `angle` radians about the given direction. | | [`shz_mat4x4_init_rotation_quat`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_quat/) | Initializes the given matrix to a 3D rotation matrix with its orientation given by a quaternion. | | [`shz_mat4x4_init_diagonal`](https://sh4zam.com/api/matrix/shz_mat4x4_init_diagonal/) | Initializes the given matrix to a diagonal matrix with the given 4 values. | | [`shz_mat4x4_init_upper_triangular`](https://sh4zam.com/api/matrix/shz_mat4x4_init_upper_triangular/) | Initializes the given matrix to an upper triangular matrix whose nonzero entries have the given value. | | [`shz_mat4x4_init_lower_triangular`](https://sh4zam.com/api/matrix/shz_mat4x4_init_lower_triangular/) | Initializes the given matrix to a lower triangular matrix whose nonzero entries have the given value. | | [`shz_mat4x4_init_symmetric_skew`](https://sh4zam.com/api/matrix/shz_mat4x4_init_symmetric_skew/) | Initializes the given matrix to be the symmetric skew of the given 3D vector components. | | [`shz_mat4x4_init_outer_product`](https://sh4zam.com/api/matrix/shz_mat4x4_init_outer_product/) | Initializes the given matrix to be the result from taking the outer product of the two given 4D vectors. | | [`shz_mat4x4_init_permutation_wxyz`](https://sh4zam.com/api/matrix/shz_mat4x4_init_permutation_wxyz/) | Initializes the matrix to to a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order. | | [`shz_mat4x4_init_permutation_yzwx`](https://sh4zam.com/api/matrix/shz_mat4x4_init_permutation_yzwx/) | Initializes the matrix to to a permutation matrix, which reorders the components of transformed vectors to be in YZWX order. | | [`shz_mat4x4_init_screen`](https://sh4zam.com/api/matrix/shz_mat4x4_init_screen/) | Initializes the given matrix to the viewport matrix with the given dimenions. | | [`shz_mat4x4_init_lookat`](https://sh4zam.com/api/matrix/shz_mat4x4_init_lookat/) | Initializes the given matrix to a "lookAt" view matrix. | | [`shz_mat4x4_init_ortho`](https://sh4zam.com/api/matrix/shz_mat4x4_init_ortho/) | Initializes the given matrix to an orthographic projection matrix. | | [`shz_mat4x4_init_frustum`](https://sh4zam.com/api/matrix/shz_mat4x4_init_frustum/) | Initializes the given matrix to a frustum projection matrix. | | [`shz_mat4x4_init_perspective`](https://sh4zam.com/api/matrix/shz_mat4x4_init_perspective/) | Initializes the given matrix to a perspective projection matrix. | ## Decomposition Routines for decomposing a matrix into its constituent transforms. | Symbol | Description | | --- | --- | | [`shz_mat4x4_decompose`](https://sh4zam.com/api/matrix/shz_mat4x4_decompose/) | Decomposes a 4x4 transform matrix into translation, rotation, and scale. | ## Getting Routines for getting specific values within a matrix. | Symbol | Description | | --- | --- | | [`shz_mat4x4_row`](https://sh4zam.com/api/matrix/shz_mat4x4_row/) | Extracts the `row` index as a 4D row vector from the given matrix. | | [`shz_mat4x4_col`](https://sh4zam.com/api/matrix/shz_mat4x4_col/) | Extracts the `col` index as a 4D column vector from the given matrix. | | [`shz_mat4x4_get_translation`](https://sh4zam.com/api/matrix/shz_mat4x4_get_translation/) | Returns the translational components from the 4th column as a 3D vector. | | [`shz_mat4x4_get_scale`](https://sh4zam.com/api/matrix/shz_mat4x4_get_scale/) | Exracts the 3D scale factors from the given 4x4 matrix. | | [`shz_mat4x4_determinant`](https://sh4zam.com/api/matrix/shz_mat4x4_determinant/) | Returns the determinant of the given 4x4 matrix. | | [`shz_mat4x4_trace`](https://sh4zam.com/api/matrix/shz_mat4x4_trace/) | Returns the trace of the given 4x4 matrix. | | [`shz_mat4x4_3x3`](https://sh4zam.com/api/matrix/shz_mat4x4_3x3/) | Extracts the top-left 3x3 of the given 4D matrix. | | [`shz_mat4x4_3x3_inverse_unscaled`](https://sh4zam.com/api/matrix/shz_mat4x4_3x3_inverse_unscaled/) | Extracts and inverts the top-level, unscaled 3x3 of the given 4x4 matrix. | | [`shz_mat4x4_3x3_inverse`](https://sh4zam.com/api/matrix/shz_mat4x4_3x3_inverse/) | Extracts and inverts the top-level 3x3 (which may be scaled) of the given 4x4 matrix. | | [`shz_mat4x4_3x3_determinant`](https://sh4zam.com/api/matrix/shz_mat4x4_3x3_determinant/) | Returns the determinant of the given 4x4 matrix's internal top-level 3x3 matrix. | ## Setting Routines for setting specific values within a matrix | Symbol | Description | | --- | --- | | [`shz_mat4x4_set_row`](https://sh4zam.com/api/matrix/shz_mat4x4_set_row/) | Sets the values of `mat` at the given `row` to those of the 4D vector, `vec`. | | [`shz_mat4x4_set_col`](https://sh4zam.com/api/matrix/shz_mat4x4_set_col/) | Sets the values of `mat` at the given `col` to those of the 4D vector, `vec`. | | [`shz_mat4x4_swap_rows`](https://sh4zam.com/api/matrix/shz_mat4x4_swap_rows/) | Swaps the 4D row vectors located at `row1` and `row2` within `mat`. | | [`shz_mat4x4_swap_cols`](https://sh4zam.com/api/matrix/shz_mat4x4_swap_cols/) | Swaps the 4D column vectors located at `col1` and `col2` within `mat`. | | [`shz_mat4x4_set_translation`](https://sh4zam.com/api/matrix/shz_mat4x4_set_translation/) | Assigns only the 3D translation-related elements of the given matrix to the given values. | | [`shz_mat4x4_set_scale`](https://sh4zam.com/api/matrix/shz_mat4x4_set_scale/) | Assigns only the 3D scale-related elements of the given matrix to the given values. | | [`shz_mat4x4_set_rotation_quat`](https://sh4zam.com/api/matrix/shz_mat4x4_set_rotation_quat/) | Sets just the rotational component of the matrix to the orientation given by a quaternion, keeping the other elements in-tact. | | [`shz_mat4x4_set_diagonal`](https://sh4zam.com/api/matrix/shz_mat4x4_set_diagonal/) | Assigns only the 4 elements along the diagonal of the given matrix to the given values. | ## Applying Routines for multiplying and accumulating onto the given matrix. | Symbol | Description | | --- | --- | | [`shz_mat4x4_apply`](https://sh4zam.com/api/matrix/shz_mat4x4_apply/) | Multiplies and accumulates the `src` 4x4 matrix onto the `dst` 4x4 matrix. | | [`shz_mat4x4_apply_unaligned`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_unaligned/) | Multiplies and accumulates the unaligned `src` 4x4 matrix onto the `dst` 4x4 matrix. | | [`shz_mat4x4_apply_transpose`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_transpose/) | Multiplies and accumulates the transposed `src` 4x4 matrix onto the `dst` 4x4 matrix. | | [`shz_mat4x4_apply_transpose_unaligned`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_transpose_unaligned/) | Multiplies and accumulates the transposed unaligned `src` 4x4 matrix onto the `dst` 4x4 matrix. | | [`shz_mat4x4_apply_translation`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_translation/) | Adds the given 3D vector components to the translational values of the given matrix. | | [`shz_mat4x4_apply_scale`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_scale/) | Multiplies and accumulates the scale-related elements of the given matrix by the given 3D components. | | [`shz_mat4x4_apply_rotation_x`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_x/) | Multiplies and accumulates a rotation matrix by `xAngle` radians about the X-axis onto the given matrix. | | [`shz_mat4x4_apply_rotation_y`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_y/) | Multiplies and accumulates a rotation matrix by `yAngle` radians about the Y-axis onto the given matrix. | | [`shz_mat4x4_apply_rotation_z`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_z/) | Multiplies and accumulates a rotation matrix by `zAngle` radians about the Z-axis onto the given matrix. | | [`shz_mat4x4_apply_rotation_xyz`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_xyz/) | Rotates the given transform matrix about the X axis, then the Y axis, then the Z axis by the given angles in radians. | | [`shz_mat4x4_apply_rotation_zyx`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_zyx/) | Rotates the given transform matrix about the Z axis, then the Y axis, then the X axis by the given angles in radians. | | [`shz_mat4x4_apply_rotation_zxy`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_zxy/) | Rotates the given transform matrix about the Z axis, then the X axis, then the Y axis by the given angles in radians. | | [`shz_mat4x4_apply_rotation_yxz`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_yxz/) | Rotates the given transform matrix about the Y axis, then the X axis, then the Z axis by the given angles in radians. | | [`shz_mat4x4_apply_rotation`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation/) | Rotates the given transform matrix about the arbitrary axis given by a 3D direction vector and angle of rotation in radians. | | [`shz_mat4x4_apply_rotation_quat`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_quat/) | Multiplies and accumulates the given matrix with a rotation matrix whose orientation is given by a quaternion. | | [`shz_mat4x4_apply_lookat`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_lookat/) | Applies the 3D "lookAt" matrix constructed with the given vector components onto the given matrix. | | [`shz_mat4x4_apply_ortho`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_ortho/) | Multiplies and accumulates the ortho matrix constructed from the given values onto the given matrix. | | [`shz_mat4x4_apply_frustum`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_frustum/) | Multiplies and accumulates the frustum matrix constructed from the given values onto the given matrix. | | [`shz_mat4x4_apply_perspective`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_perspective/) | Multiplies and accumulates the perspective matrix constructed from the given values onto the given matrix. | | [`shz_mat4x4_apply_screen`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_screen/) | Multiplies and accumulates the viewport matrix created with the given components ont othe given matrix. | | [`shz_mat4x4_apply_symmetric_skew`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_symmetric_skew/) | Multiplies and accumulates the given matrix with a symmetric skew matrix formed from the given 3D vector components. | | [`shz_mat4x4_apply_permutation_wxyz`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_permutation_wxyz/) | Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order. | | [`shz_mat4x4_apply_permutation_yzwx`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_permutation_yzwx/) | Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in YZWX order. | | [`shz_mat4x4_apply_self`](https://sh4zam.com/api/matrix/shz_mat4x4_apply_self/) | Multiplies and accumulates the given matrix onto itself. | ## GL Transformations OpenGL-style 4x4 matrix transforms. | Symbol | Description | | --- | --- | | [`shz_mat4x4_translate`](https://sh4zam.com/api/matrix/shz_mat4x4_translate/) | Multiplies and accumulates `mat` by a 3D translation matrix with the given components. | | [`shz_mat4x4_scale`](https://sh4zam.com/api/matrix/shz_mat4x4_scale/) | Multiplies and accumulates `mat` by a 3D scaling matrix with the given components. | | [`shz_mat4x4_rotate_x`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_x/) | Multiplies and accumulates `mat` by a 3D rotation matrix about the X axis. | | [`shz_mat4x4_rotate_y`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_y/) | Multiplies and accumulates `mat` by a 3D rotation matrix about the Y axis. | | [`shz_mat4x4_rotate_z`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_z/) | Multiplies and accumulates `mat` by a 3D rotation matrix about the Z axis. | | [`shz_mat4x4_rotate_xyz`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_xyz/) | Multiplies and accumulates `mat` by 3D rotation matrices about the X then Y then Z axes. | | [`shz_mat4x4_rotate_zyx`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_zyx/) | Multiplies and accumulates `mat` by 3D rotation matrices about the Z then Y then X axes. | | [`shz_mat4x4_rotate_zxy`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_zxy/) | Multiplies and accumulates `mat` by 3D rotation matrices about the Z then X then Y axes. | | [`shz_mat4x4_rotate_yxz`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate_yxz/) | Multiplies and accumulates `mat` by 3D rotation matrices about the Y then X then Z axes. | | [`shz_mat4x4_rotate`](https://sh4zam.com/api/matrix/shz_mat4x4_rotate/) | Multiplies and accumulates `mat` by the 3D rotation matrix formed by the given axis and angle. | ## Reverse GL Transformations Pre-multiplication variants of OpenGL-style 4x4 matrix transforms. | Symbol | Description | | --- | --- | | [`shz_mat4x4_translate_reverse`](https://sh4zam.com/api/matrix/shz_mat4x4_translate_reverse/) | Pre-multiplies and accumulates the given matrix onto the 3D translation matrix with the given components. | | [`shz_mat4x4_scale_reverse`](https://sh4zam.com/api/matrix/shz_mat4x4_scale_reverse/) | Pre-multiplies and accumulates the given matrix onto the 3D scaling matrix with the given components. | ## Transforming Routines for transforming vectors and points by a matrix. | Symbol | Description | | --- | --- | | [`shz_mat4x4_mult`](https://sh4zam.com/api/matrix/shz_mat4x4_mult/) | Multiplies two 4x4 matrices together, storing the result into a third. | | [`shz_mat4x4_mult_unaligned`](https://sh4zam.com/api/matrix/shz_mat4x4_mult_unaligned/) | Multiplies two 4x4 matrices together, with the right handed matrix being unaligned, storing the result into a third. | | [`shz_mat4x4_mult_transpose`](https://sh4zam.com/api/matrix/shz_mat4x4_mult_transpose/) | Multiplies the regular matrix, `lhs`, by the transpose of the matrix, `rhs`, storing the result into `mat`. | | [`shz_mat4x4_mult_transpose_unaligned`](https://sh4zam.com/api/matrix/shz_mat4x4_mult_transpose_unaligned/) | Multiplies the regular matrix, `lhs`, by the transpose of the unaligned matrix, `rhs`, storing the result into `mat`. | | [`shz_mat4x4_transform_vec2`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec2/) | Transforms a 2D vector by a 4x4 matrix. | | [`shz_mat4x4_transform_vec3`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec3/) | Transforms a 3D vector by a 4x4 matrix. | | [`shz_mat4x4_transform_vec4`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec4/) | Transforms a 4D vector by a 4x4 matrix. | | [`shz_mat4x4_transform_vec2_transpose`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec2_transpose/) | Transforms a 2D vector the the transpose of a 4x4 matrix. | | [`shz_mat4x4_transform_vec3_transpose`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec3_transpose/) | Transforms a 3D vector the the transpose of a 4x4 matrix. | | [`shz_mat4x4_transform_vec4_transpose`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec4_transpose/) | Transforms a 4D vector the the transpose of a 4x4 matrix. | | [`shz_mat4x4_transform_point2`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_point2/) | Transforms a 2D point by a 4x4 matrix. | | [`shz_mat4x4_transform_point3`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_point3/) | Transforms a 3D point by a 4x4 matrix. | | [`shz_mat4x4_transform_point2_transpose`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_point2_transpose/) | Transforms a 2D point by the transpose of a 4x4 matrix. | | [`shz_mat4x4_transform_point3_transpose`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_point3_transpose/) | Transforms a 3D point by the transpose of a 4x4 matrix. | ## Miscellaneous Other matrix-related operations and routines | Symbol | Description | | --- | --- | | [`shz_mat4x4_to_quat`](https://sh4zam.com/api/matrix/shz_mat4x4_to_quat/) | Converts the given 4x4 orientation matrix into a quaternion. | | [`shz_mat4x4_transpose`](https://sh4zam.com/api/matrix/shz_mat4x4_transpose/) | Stores the transpose of `mat` within `out`. | | [`shz_mat4x4_inverse`](https://sh4zam.com/api/matrix/shz_mat4x4_inverse/) | Computes the inverse of a 4x4 matrix. | | [`shz_mat4x4_inverse_block_triangular`](https://sh4zam.com/api/matrix/shz_mat4x4_inverse_block_triangular/) | Computes the inverse of a 4x4 matrix in block-triangular form. | | [`shz_mat4x4_equal`](https://sh4zam.com/api/matrix/shz_mat4x4_equal/) | Returns true if the two matrices are equal, based on either absolute or relative tolerance. | | [`shz_mat4x4_is_block_triangular`](https://sh4zam.com/api/matrix/shz_mat4x4_is_block_triangular/) | Returns true if the given matrix is in block-triangular form: having a bottom row in the form of `<0.0f, 0.0f, 0.0f, w>`. | | [`shz_mat4x4_copy`](https://sh4zam.com/api/matrix/shz_mat4x4_copy/) | Copies the given `src` 4x4 matrix into the given `dst` 4x4 matrix. | | [`shz_mat4x4_copy_unaligned`](https://sh4zam.com/api/matrix/shz_mat4x4_copy_unaligned/) | Copies the given unaligned `src` 4x4 matrix into the given `dst` 4x4 matrix. | | [`shz_mat4x4_swap`](https://sh4zam.com/api/matrix/shz_mat4x4_swap/) | Swaps the contents of the two given matrices, `matA` and `matB`. | | [`shz_mat4x4_blend`](https://sh4zam.com/api/matrix/shz_mat4x4_blend/) | Adds and accumulates a scaled 4x4 matrix into the given matrix. | ## Types | Symbol | Description | | --- | --- | | [`shz_mat4x4_t`](https://sh4zam.com/api/matrix/shz_mat4x4_t/) | Structure representing a 4x4 column-major matrix. | | [`shz_mat4x4`](https://sh4zam.com/api/matrix/shz_mat4x4/) | Alternate [`shz_mat4x4_t`](https://sh4zam.com/api/matrix/shz_mat4x4_t/) C typedef for those who hate POSIX style. | | [`shz_mat2x2_t`](https://sh4zam.com/api/matrix/shz_mat2x2_t/) | Structure representing a 2x2 column-major matrix. | | [`shz_mat3x3_t`](https://sh4zam.com/api/matrix/shz_mat3x3_t/) | Structure representing a 3x3 column-major matrix. | | [`shz_mat3x4_t`](https://sh4zam.com/api/matrix/shz_mat3x4_t/) | Structure representing a 3x4 column-major matrix. | | [`shz_mat4x3_t`](https://sh4zam.com/api/matrix/shz_mat4x3_t/) | Structure representing a 4x3 column-major matrix. | ## Functions | Symbol | Description | | --- | --- | | [`shz_mat3x3_transpose`](https://sh4zam.com/api/matrix/shz_mat3x3_transpose/) | Stores the transpose of 3x3 matrix `mat` within `out`. | | [`shz_mat3x3_inverse_unscaled`](https://sh4zam.com/api/matrix/shz_mat3x3_inverse_unscaled/) | Computes the inverse of an orthonormal 3x3 matrix. | | [`shz_mat3x3_inverse`](https://sh4zam.com/api/matrix/shz_mat3x3_inverse/) | Computes the inverse of a 3x3 matrix. | | [`shz_mat3x3_scale`](https://sh4zam.com/api/matrix/shz_mat3x3_scale/) | Uniformly scales each element within a 3x3 matrix by the given value. | | [`shz_mat3x3_transform_vec3`](https://sh4zam.com/api/matrix/shz_mat3x3_transform_vec3/) | Transforms an input vector by a 3x3 matrix, returning the resulting vector. | | [`shz_mat3x3_transform_vec3_transpose`](https://sh4zam.com/api/matrix/shz_mat3x3_transform_vec3_transpose/) | Transforms an input vector by the transpose of a 3x3 matrix, returning the resulting vector. | --- # shz_mat2x2_t Source: https://sh4zam.com/api/matrix/shz_mat2x2_t/ ```c typedef SHZ_ALIGNAS(8) struct shz_mat2x2 { union { float elem[4]; float elem2D[2][2]; shz_vec2_t col[2]; }; } shz_mat2x2_t; ``` Structure representing a 2x2 column-major matrix. ## Fields | Field | Type | Description | | --- | --- | --- | | `elem` | `float[4]` | | | `elem2D` | `float[2][2]` | | | `col` | `shz_vec2_t[2]` | | ## Warnings - This structure MUST be aligned on 8-byte boundaries! ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_matrix.h:889`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L889) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Types" --- # shz_mat3x3_inverse_unscaled Source: https://sh4zam.com/api/matrix/shz_mat3x3_inverse_unscaled/ ```c SHZ_INLINE void shz_mat3x3_inverse_unscaled(const shz_mat3x3_t* mat, shz_mat3x3_t* out) SHZ_NOEXCEPT; ``` Computes the inverse of an orthonormal 3x3 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat3x3_t *` | Pointer to the 3x3 matrix to invert. | | `out` | `shz_mat3x3_t *` | Pointer to the resulting inverted matrix. | ## Returns Nothing (`void`). ## Notes - The routine saves cycles by not scaling by the determinant, which is typically useful for normals and lighting, where the matrix has no scale factor. ## Warnings - This routine clobbers XMTRX. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:959`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L959) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Functions" --- # shz_mat3x3_inverse Source: https://sh4zam.com/api/matrix/shz_mat3x3_inverse/ ```c SHZ_INLINE void shz_mat3x3_inverse(const shz_mat3x3_t* mat, shz_mat3x3_t* out) SHZ_NOEXCEPT; ``` Computes the inverse of a 3x3 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat3x3_t *` | Pointer to the 3x3 matrix to invert. | | `out` | `shz_mat3x3_t *` | Pointer to the resulting inverted matrix. | ## Returns Nothing (`void`). ## Notes - Only valid for non-singular matrices. ## Warnings - This routine clobbers XMTRX. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:970`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L970) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Functions" --- # shz_mat3x3_scale Source: https://sh4zam.com/api/matrix/shz_mat3x3_scale/ ```c SHZ_INLINE void shz_mat3x3_scale(shz_mat3x3_t* dst, const shz_mat3x3_t* src, float value) SHZ_NOEXCEPT; ``` Uniformly scales each element within a 3x3 matrix by the given value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `shz_mat3x3_t *` | | | `src` | `const shz_mat3x3_t *` | | | `value` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:973`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L973) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Functions" --- # shz_mat3x3_t Source: https://sh4zam.com/api/matrix/shz_mat3x3_t/ ```c typedef struct shz_mat3x3 { union { float elem[9]; float elem2D[3][3]; shz_vec3_t col[3]; struct { shz_vec3_t left; shz_vec3_t up; shz_vec3_t forward; }; }; } shz_mat3x3_t; ``` Structure representing a 3x3 column-major matrix. ## Fields | Field | Type | Description | | --- | --- | --- | | `elem` | `float[9]` | | | `elem2D` | `float[3][3]` | | | `col` | `shz_vec3_t[3]` | | | `left` | `shz_vec3_t` | | | `up` | `shz_vec3_t` | | | `forward` | `shz_vec3_t` | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_matrix.h:898`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L898) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Types" --- # shz_mat3x3_transform_vec3_transpose Source: https://sh4zam.com/api/matrix/shz_mat3x3_transform_vec3_transpose/ ```c SHZ_INLINE shz_vec3_t shz_mat3x3_transform_vec3_transpose(const shz_mat3x3_t* m, shz_vec3_t v) SHZ_NOEXCEPT; ``` Transforms an input vector by the transpose of a 3x3 matrix, returning the resulting vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `const shz_mat3x3_t *` | | | `v` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:979`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L979) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Functions" --- # shz_mat3x3_transform_vec3 Source: https://sh4zam.com/api/matrix/shz_mat3x3_transform_vec3/ ```c SHZ_INLINE shz_vec3_t shz_mat3x3_transform_vec3(const shz_mat3x3_t* m, shz_vec3_t v) SHZ_NOEXCEPT; ``` Transforms an input vector by a 3x3 matrix, returning the resulting vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `const shz_mat3x3_t *` | | | `v` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:976`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L976) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Functions" --- # shz_mat3x3_transpose Source: https://sh4zam.com/api/matrix/shz_mat3x3_transpose/ > Stores the transpose of 3x3 matrix mat within out ```c SHZ_INLINE void shz_mat3x3_transpose(const shz_mat3x3_t* mat, shz_mat3x3_t* out) SHZ_NOEXCEPT; ``` Stores the transpose of 3x3 matrix `mat` within `out`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat3x3_t *` | Pointer to the 3x3 matrix to transpose. | | `out` | `shz_mat3x3_t *` | Pointer to the resulting transposed matrix. | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:947`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L947) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Functions" --- # shz_mat3x4_t Source: https://sh4zam.com/api/matrix/shz_mat3x4_t/ ```c typedef struct shz_mat3x4 { union { float elem[12]; float elem2D[4][3]; shz_vec3_t col[4]; struct { shz_vec3_t left; shz_vec3_t up; shz_vec3_t forward; shz_vec3_t pos; }; }; } shz_mat3x4_t; ``` Structure representing a 3x4 column-major matrix. ## Fields | Field | Type | Description | | --- | --- | --- | | `elem` | `float[12]` | | | `elem2D` | `float[4][3]` | | | `col` | `shz_vec3_t[4]` | | | `left` | `shz_vec3_t` | | | `up` | `shz_vec3_t` | | | `forward` | `shz_vec3_t` | | | `pos` | `shz_vec3_t` | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_matrix.h:912`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L912) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Types" --- # shz_mat4x3_t Source: https://sh4zam.com/api/matrix/shz_mat4x3_t/ ```c typedef struct shz_mat4x3 { union { float elem[12]; float elem2D[3][4]; shz_vec4_t col[3]; struct { shz_vec4_t left; shz_vec4_t up; shz_vec4_t forward; }; }; } shz_mat4x3_t; ``` Structure representing a 4x3 column-major matrix. ## Fields | Field | Type | Description | | --- | --- | --- | | `elem` | `float[12]` | | | `elem2D` | `float[3][4]` | | | `col` | `shz_vec4_t[3]` | | | `left` | `shz_vec4_t` | | | `up` | `shz_vec4_t` | | | `forward` | `shz_vec4_t` | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_matrix.h:927`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L927) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Types" --- # shz_mat4x4_3x3_determinant Source: https://sh4zam.com/api/matrix/shz_mat4x4_3x3_determinant/ ```c SHZ_INLINE float shz_mat4x4_3x3_determinant(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Returns the determinant of the given 4x4 matrix's internal top-level 3x3 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns `float` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:339`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L339) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_3x3_inverse_unscaled Source: https://sh4zam.com/api/matrix/shz_mat4x4_3x3_inverse_unscaled/ ```c SHZ_INLINE void shz_mat4x4_3x3_inverse_unscaled(const shz_mat4x4_t* mat4, shz_mat3x3_t* invmat3) SHZ_NOEXCEPT; ``` Extracts and inverts the top-level, unscaled 3x3 of the given 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat4` | `const shz_mat4x4_t *` | | | `invmat3` | `shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:333`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L333) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_3x3_inverse Source: https://sh4zam.com/api/matrix/shz_mat4x4_3x3_inverse/ ```c SHZ_INLINE void shz_mat4x4_3x3_inverse(const shz_mat4x4_t* mat4, shz_mat3x3_t* invmat3) SHZ_NOEXCEPT; ``` Extracts and inverts the top-level 3x3 (which may be scaled) of the given 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat4` | `const shz_mat4x4_t *` | | | `invmat3` | `shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:336`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L336) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_3x3 Source: https://sh4zam.com/api/matrix/shz_mat4x4_3x3/ ```c SHZ_INLINE void shz_mat4x4_3x3(const shz_mat4x4_t* mat4, shz_mat3x3_t* mat3) SHZ_NOEXCEPT; ``` Extracts the top-left 3x3 of the given 4D matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat4` | `const shz_mat4x4_t *` | | | `mat3` | `shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:330`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L330) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_apply_frustum Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_frustum/ ```c SHZ_INLINE void shz_mat4x4_apply_frustum(shz_mat4x4_t* m, float left, float right, float bottom, float top, float znear, float zfar) SHZ_NOEXCEPT; ``` Multiplies and accumulates the frustum matrix constructed from the given values onto the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `shz_mat4x4_t *` | | | `left` | `float` | | | `right` | `float` | | | `bottom` | `float` | | | `top` | `float` | | | `znear` | `float` | | | `zfar` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_frustum`](https://sh4zam.com/api/cpp/mat4x4/#apply_frustum) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:495`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L495) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_lookat Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_lookat/ ```c SHZ_INLINE void shz_mat4x4_apply_lookat(shz_mat4x4_t* m, shz_vec3_t pos, shz_vec3_t target, shz_vec3_t up) SHZ_NOEXCEPT; ``` Applies the 3D "lookAt" matrix constructed with the given vector components onto the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `shz_mat4x4_t *` | | | `pos` | `shz_vec3_t` | | | `target` | `shz_vec3_t` | | | `up` | `shz_vec3_t` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_lookat`](https://sh4zam.com/api/cpp/mat4x4/#apply_lookat) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:483`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L483) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_ortho Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_ortho/ ```c SHZ_INLINE void shz_mat4x4_apply_ortho(shz_mat4x4_t* m, float left, float right, float bottom, float top, float znear, float zfar) SHZ_NOEXCEPT; ``` Multiplies and accumulates the ortho matrix constructed from the given values onto the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `shz_mat4x4_t *` | | | `left` | `float` | | | `right` | `float` | | | `bottom` | `float` | | | `top` | `float` | | | `znear` | `float` | | | `zfar` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_ortho`](https://sh4zam.com/api/cpp/mat4x4/#apply_ortho) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:489`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L489) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_permutation_wxyz Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_permutation_wxyz/ ```c SHZ_INLINE void shz_mat4x4_apply_permutation_wxyz(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_permutation_wxyz`](https://sh4zam.com/api/cpp/mat4x4/#apply_permutation_wxyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:519`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L519) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_permutation_yzwx Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_permutation_yzwx/ ```c SHZ_INLINE void shz_mat4x4_apply_permutation_yzwx(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in YZWX order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_permutation_yzwx`](https://sh4zam.com/api/cpp/mat4x4/#apply_permutation_yzwx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:525`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L525) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_perspective Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_perspective/ ```c SHZ_INLINE void shz_mat4x4_apply_perspective(shz_mat4x4_t* m, float fov, float aspect, float znear) SHZ_NOEXCEPT; ``` Multiplies and accumulates the perspective matrix constructed from the given values onto the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `shz_mat4x4_t *` | | | `fov` | `float` | | | `aspect` | `float` | | | `znear` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_perspective`](https://sh4zam.com/api/cpp/mat4x4/#apply_perspective) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:501`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L501) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation_quat Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_quat/ ```c SHZ_INLINE void shz_mat4x4_apply_rotation_quat(shz_mat4x4_t* m, shz_quat_t q) SHZ_NOEXCEPT; ``` Multiplies and accumulates the given matrix with a rotation matrix whose orientation is given by a quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `shz_mat4x4_t *` | | | `q` | `shz_quat_t` | | ## Returns Nothing (`void`). ## Notes - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:477`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L477) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation_x Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_x/ > Multiplies and accumulates a rotation matrix by xAngle radians about the X-axis onto the given matrix ```c SHZ_INLINE void shz_mat4x4_apply_rotation_x(shz_mat4x4_t* mat, float xAngle) SHZ_NOEXCEPT; ``` Multiplies and accumulates a rotation matrix by `xAngle` radians about the X-axis onto the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `xAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_rotation_x`](https://sh4zam.com/api/cpp/mat4x4/#apply_rotation_x) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:419`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L419) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation_xyz Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_xyz/ ```c SHZ_INLINE void shz_mat4x4_apply_rotation_xyz(shz_mat4x4_t* mat, float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT; ``` Rotates the given transform matrix about the X axis, then the Y axis, then the Z axis by the given angles in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `xAngle` | `float` | | | `yAngle` | `float` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Details Multiplies and accumulates the given matrix with the 3D rotation matrix formed from the intrinsic rotation created by the given Tait-Bryan X-Y-Z angles. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_rotation_xyz`](https://sh4zam.com/api/cpp/mat4x4/#apply_rotation_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:439`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L439) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation_y Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_y/ > Multiplies and accumulates a rotation matrix by yAngle radians about the Y-axis onto the given matrix ```c SHZ_INLINE void shz_mat4x4_apply_rotation_y(shz_mat4x4_t* mat, float yAngle) SHZ_NOEXCEPT; ``` Multiplies and accumulates a rotation matrix by `yAngle` radians about the Y-axis onto the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `yAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_rotation_y`](https://sh4zam.com/api/cpp/mat4x4/#apply_rotation_y) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:425`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L425) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation_yxz Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_yxz/ ```c SHZ_INLINE void shz_mat4x4_apply_rotation_yxz(shz_mat4x4_t* mat, float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT; ``` Rotates the given transform matrix about the Y axis, then the X axis, then the Z axis by the given angles in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `yAngle` | `float` | | | `xAngle` | `float` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Details Multiplies and accumulates the given matrix with the 3D rotation matrix formed from the intrinsic rotation created by the given Tait-Bryan Y-X-Z angles. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_rotation_yxz`](https://sh4zam.com/api/cpp/mat4x4/#apply_rotation_yxz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:463`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L463) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation_z Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_z/ > Multiplies and accumulates a rotation matrix by zAngle radians about the Z-axis onto the given matrix ```c SHZ_INLINE void shz_mat4x4_apply_rotation_z(shz_mat4x4_t* mat, float zAngle) SHZ_NOEXCEPT; ``` Multiplies and accumulates a rotation matrix by `zAngle` radians about the Z-axis onto the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_rotation_z`](https://sh4zam.com/api/cpp/mat4x4/#apply_rotation_z) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:431`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L431) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation_zxy Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_zxy/ ```c SHZ_INLINE void shz_mat4x4_apply_rotation_zxy(shz_mat4x4_t* mat, float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT; ``` Rotates the given transform matrix about the Z axis, then the X axis, then the Y axis by the given angles in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `zAngle` | `float` | | | `xAngle` | `float` | | | `yAngle` | `float` | | ## Returns Nothing (`void`). ## Details Multiplies and accumulates the given matrix with the 3D rotation matrix formed from the intrinsic rotation created by the given Tait-Bryan Z-Y-X angles. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_rotation_zxy`](https://sh4zam.com/api/cpp/mat4x4/#apply_rotation_zxy) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:455`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L455) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation_zyx Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation_zyx/ ```c SHZ_INLINE void shz_mat4x4_apply_rotation_zyx(shz_mat4x4_t* mat, float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT; ``` Rotates the given transform matrix about the Z axis, then the Y axis, then the X axis by the given angles in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `zAngle` | `float` | | | `yAngle` | `float` | | | `xAngle` | `float` | | ## Returns Nothing (`void`). ## Details Multiplies and accumulates the given matrix with the 3D rotation matrix formed from the intrinsic rotation created by the given Tait-Bryan Z-Y-X angles. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_rotation_zyx`](https://sh4zam.com/api/cpp/mat4x4/#apply_rotation_zyx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:447`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L447) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_rotation Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_rotation/ ```c SHZ_INLINE void shz_mat4x4_apply_rotation(shz_mat4x4_t* mat, float angle, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT; ``` Rotates the given transform matrix about the arbitrary axis given by a 3D direction vector and angle of rotation in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `angle` | `float` | | | `xAxis` | `float` | | | `yAxis` | `float` | | | `zAxis` | `float` | | ## Returns Nothing (`void`). ## Details Multiplies and accumulates the given matrix with the 3D rotation matrix formed from the intrinsic rotation created by the given Tait-Bryan Z-Y-X angles. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:471`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L471) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_scale Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_scale/ ```c SHZ_INLINE void shz_mat4x4_apply_scale(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Multiplies and accumulates the scale-related elements of the given matrix by the given 3D components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_scale`](https://sh4zam.com/api/cpp/mat4x4/#apply_scale) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:413`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L413) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_screen Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_screen/ ```c SHZ_INLINE void shz_mat4x4_apply_screen(shz_mat4x4_t* m, float width, float height) SHZ_NOEXCEPT; ``` Multiplies and accumulates the viewport matrix created with the given components ont othe given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `shz_mat4x4_t *` | | | `width` | `float` | | | `height` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_screen`](https://sh4zam.com/api/cpp/mat4x4/#apply_screen) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:507`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L507) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_self Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_self/ ```c SHZ_INLINE void shz_mat4x4_apply_self(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Multiplies and accumulates the given matrix onto itself. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_self`](https://sh4zam.com/api/cpp/mat4x4/#apply_self) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:531`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L531) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_symmetric_skew Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_symmetric_skew/ ```c SHZ_INLINE void shz_mat4x4_apply_symmetric_skew(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Multiplies and accumulates the given matrix with a symmetric skew matrix formed from the given 3D vector components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_symmetric_skew`](https://sh4zam.com/api/cpp/mat4x4/#apply_symmetric_skew) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:513`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L513) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_translation Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_translation/ ```c SHZ_INLINE void shz_mat4x4_apply_translation(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Adds the given 3D vector components to the translational values of the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Notes - This routine does not use XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::apply_translation`](https://sh4zam.com/api/cpp/mat4x4/#apply_translation) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:407`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L407) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_transpose_unaligned Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_transpose_unaligned/ > Multiplies and accumulates the transposed unaligned src 4x4 matrix onto the dst 4x4 matrix ```c SHZ_INLINE void shz_mat4x4_apply_transpose_unaligned(shz_mat4x4_t* dst, const float src[16]) SHZ_NOEXCEPT; ``` Multiplies and accumulates the transposed unaligned `src` 4x4 matrix onto the `dst` 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `shz_mat4x4_t *` | | | `src` | `const float [16]` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:401`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L401) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_transpose Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_transpose/ > Multiplies and accumulates the transposed src 4x4 matrix onto the dst 4x4 matrix ```c SHZ_INLINE void shz_mat4x4_apply_transpose(shz_mat4x4_t* dst, const shz_mat4x4_t* src) SHZ_NOEXCEPT; ``` Multiplies and accumulates the transposed `src` 4x4 matrix onto the `dst` 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `shz_mat4x4_t *` | | | `src` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:395`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L395) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply_unaligned Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply_unaligned/ > Multiplies and accumulates the unaligned src 4x4 matrix onto the dst 4x4 matrix ```c SHZ_INLINE void shz_mat4x4_apply_unaligned(shz_mat4x4_t* dst, const float src[16]) SHZ_NOEXCEPT; ``` Multiplies and accumulates the unaligned `src` 4x4 matrix onto the `dst` 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `shz_mat4x4_t *` | | | `src` | `const float [16]` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:389`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L389) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_apply Source: https://sh4zam.com/api/matrix/shz_mat4x4_apply/ > Multiplies and accumulates the src 4x4 matrix onto the dst 4x4 matrix ```c SHZ_INLINE void shz_mat4x4_apply(shz_mat4x4_t* dst, const shz_mat4x4_t* src) SHZ_NOEXCEPT; ``` Multiplies and accumulates the `src` 4x4 matrix onto the `dst` 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `shz_mat4x4_t *` | | | `src` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:383`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L383) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Applying" --- # shz_mat4x4_blend Source: https://sh4zam.com/api/matrix/shz_mat4x4_blend/ ```c SHZ_INLINE void shz_mat4x4_blend(shz_mat4x4_t* dst, const shz_mat4x4_t* matrix, float weights) SHZ_NOEXCEPT; ``` Adds and accumulates a scaled 4x4 matrix into the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `shz_mat4x4_t *` | | | `matrix` | `const shz_mat4x4_t *` | | | `weights` | `float` | | ## Returns Nothing (`void`). ## Details Each component of `joint_matrix` will be multiplied by `weight`, with the result being added to the existing value of that component in `dst`. This is useful for accumulating weighted joint matrices onto an initially zeroed-out matrix. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::blend`](https://sh4zam.com/api/cpp/mat4x4/#blend) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:879`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L879) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" ## See also [`shz_mat4x4_init_zero`](https://sh4zam.com/api/matrix/shz_mat4x4_init_zero/) --- # shz_mat4x4_col Source: https://sh4zam.com/api/matrix/shz_mat4x4_col/ > Extracts the col index as a 4D column vector from the given matrix ```c SHZ_INLINE shz_vec4_t shz_mat4x4_col(const shz_mat4x4_t* mat, size_t col) SHZ_NOEXCEPT; ``` Extracts the `col` index as a 4D column vector from the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `col` | `size_t` | | ## Returns `shz_vec4_t` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::col`](https://sh4zam.com/api/cpp/mat4x4/#col) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:311`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L311) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_copy_unaligned Source: https://sh4zam.com/api/matrix/shz_mat4x4_copy_unaligned/ > Copies the given unaligned src 4x4 matrix into the given dst 4x4 matrix ```c SHZ_INLINE void shz_mat4x4_copy_unaligned(shz_mat4x4_t* dst, const float src[16]) SHZ_NOEXCEPT; ``` Copies the given unaligned `src` 4x4 matrix into the given `dst` 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `shz_mat4x4_t *` | | | `src` | `const float [16]` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:859`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L859) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4_copy Source: https://sh4zam.com/api/matrix/shz_mat4x4_copy/ > Copies the given src 4x4 matrix into the given dst 4x4 matrix ```c SHZ_INLINE void shz_mat4x4_copy(shz_mat4x4_t* dst, const shz_mat4x4_t* src) SHZ_NOEXCEPT; ``` Copies the given `src` 4x4 matrix into the given `dst` 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `shz_mat4x4_t *` | | | `src` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::mat4x4`](https://sh4zam.com/api/cpp/mat4x4/#mat4x4), [`shz::mat4x4::operator=`](https://sh4zam.com/api/cpp/mat4x4/) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:853`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L853) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4_decompose Source: https://sh4zam.com/api/matrix/shz_mat4x4_decompose/ ```c void shz_mat4x4_decompose(const shz_mat4x4_t* mat, shz_vec3_t* translation, shz_quat_t* rotation, shz_vec3_t* scale) SHZ_NOEXCEPT; ``` Decomposes a 4x4 transform matrix into translation, rotation, and scale. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `translation` | `shz_vec3_t *` | | | `rotation` | `shz_quat_t *` | | | `scale` | `shz_vec3_t *` | | ## Returns Nothing (`void`). ## Notes - Any output pointer may be NULL to skip that component. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::decompose`](https://sh4zam.com/api/cpp/mat4x4/#decompose) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:295`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L295) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Decomposition" --- # shz_mat4x4_determinant Source: https://sh4zam.com/api/matrix/shz_mat4x4_determinant/ ```c SHZ_INLINE float shz_mat4x4_determinant(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Returns the determinant of the given 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns `float` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::determinant`](https://sh4zam.com/api/cpp/mat4x4/#determinant) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:324`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L324) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_equal Source: https://sh4zam.com/api/matrix/shz_mat4x4_equal/ ```c SHZ_INLINE bool shz_mat4x4_equal(const shz_mat4x4_t* SHZ_RESTRICT mat1, const shz_mat4x4_t* mat2) SHZ_NOEXCEPT; ``` Returns true if the two matrices are equal, based on either absolute or relative tolerance. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat1` | `const shz_mat4x4_t *SHZ_RESTRICT` | | | `mat2` | `const shz_mat4x4_t *` | | ## Returns `bool` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:847`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L847) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4_get_scale Source: https://sh4zam.com/api/matrix/shz_mat4x4_get_scale/ ```c SHZ_INLINE shz_vec3_t shz_mat4x4_get_scale(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Exracts the 3D scale factors from the given 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns `shz_vec3_t` ## Warnings - This routine assumes `mat` is a standard TRS-style transform matrix, without shearing or reflection. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::get_scale`](https://sh4zam.com/api/cpp/mat4x4/#get_scale) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:321`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L321) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_get_translation Source: https://sh4zam.com/api/matrix/shz_mat4x4_get_translation/ ```c SHZ_INLINE shz_vec3_t shz_mat4x4_get_translation(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Returns the translational components from the 4th column as a 3D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns `shz_vec3_t` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::get_translation`](https://sh4zam.com/api/cpp/mat4x4/#get_translation) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:314`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L314) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_init_diagonal Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_diagonal/ ```c SHZ_INLINE void shz_mat4x4_init_diagonal(shz_mat4x4_t* mat, float x, float y, float z, float w) SHZ_NOEXCEPT; ``` Initializes the given matrix to a diagonal matrix with the given 4 values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | | `w` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_diagonal`](https://sh4zam.com/api/cpp/mat4x4/#init_diagonal) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:210`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L210) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_fill Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_fill/ ```c SHZ_INLINE void shz_mat4x4_init_fill(shz_mat4x4_t* mat, float value) SHZ_NOEXCEPT; ``` Initializes the given matrix with all elements assigned to the given value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `value` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_fill`](https://sh4zam.com/api/cpp/mat4x4/#init_fill) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:122`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L122) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_frustum Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_frustum/ ```c SHZ_INLINE void shz_mat4x4_init_frustum(shz_mat4x4_t* mat, float left, float right, float bottom, float top, float znear, float zfar) SHZ_NOEXCEPT; ``` Initializes the given matrix to a frustum projection matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `left` | `float` | | | `right` | `float` | | | `bottom` | `float` | | | `top` | `float` | | | `znear` | `float` | | | `zfar` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_frustum`](https://sh4zam.com/api/cpp/mat4x4/#init_frustum) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:274`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L274) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_identity_safe Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_identity_safe/ ```c SHZ_INLINE void shz_mat4x4_init_identity_safe(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Safely initializes the given matrix to the 4x4 identity matrix. **Deprecated:** `shz_mat4x4_init_identity()` is already safe now by default. This routine simply calls directly into it and should not be used. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:104`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L104) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" ## See also [`shz_mat4x4_init_identity`](https://sh4zam.com/api/matrix/shz_mat4x4_init_identity/) --- # shz_mat4x4_init_identity Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_identity/ ```c SHZ_INLINE void shz_mat4x4_init_identity(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Initializes the given matrix to the 4x4 identity matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_identity`](https://sh4zam.com/api/cpp/mat4x4/#init_identity), [`shz::mat4x4::init_identity_safe`](https://sh4zam.com/api/cpp/mat4x4/#init_identity_safe) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:91`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L91) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_lookat Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_lookat/ ```c SHZ_INLINE void shz_mat4x4_init_lookat(shz_mat4x4_t* mat, shz_vec3_t eye, shz_vec3_t center, shz_vec3_t up) SHZ_NOEXCEPT; ``` Initializes the given matrix to a "lookAt" view matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `eye` | `shz_vec3_t` | | | `center` | `shz_vec3_t` | | | `up` | `shz_vec3_t` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_lookat`](https://sh4zam.com/api/cpp/mat4x4/#init_lookat) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:262`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L262) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_lower_triangular Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_lower_triangular/ ```c SHZ_INLINE void shz_mat4x4_init_lower_triangular(shz_mat4x4_t* mat, shz_vec4_t col1, shz_vec3_t col2, shz_vec2_t col3, float col4) SHZ_NOEXCEPT; ``` Initializes the given matrix to a lower triangular matrix whose nonzero entries have the given value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `col1` | `shz_vec4_t` | | | `col2` | `shz_vec3_t` | | | `col3` | `shz_vec2_t` | | | `col4` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_lower_triangular`](https://sh4zam.com/api/cpp/mat4x4/#init_lower_triangular) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:222`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L222) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_one Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_one/ ```c SHZ_INLINE void shz_mat4x4_init_one(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Initializes the given matrix with all 1s for its element values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_one`](https://sh4zam.com/api/cpp/mat4x4/#init_one) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:116`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L116) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_ortho Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_ortho/ ```c SHZ_INLINE void shz_mat4x4_init_ortho(shz_mat4x4_t* mat, float left, float right, float bottom, float top, float znear, float zfar) SHZ_NOEXCEPT; ``` Initializes the given matrix to an orthographic projection matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `left` | `float` | | | `right` | `float` | | | `bottom` | `float` | | | `top` | `float` | | | `znear` | `float` | | | `zfar` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_ortho`](https://sh4zam.com/api/cpp/mat4x4/#init_ortho) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:268`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L268) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_outer_product Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_outer_product/ ```c SHZ_INLINE void shz_mat4x4_init_outer_product(shz_mat4x4_t* mat, shz_vec4_t v1, shz_vec4_t v2) SHZ_NOEXCEPT; ``` Initializes the given matrix to be the result from taking the outer product of the two given 4D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `v1` | `shz_vec4_t` | | | `v2` | `shz_vec4_t` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_outer_product`](https://sh4zam.com/api/cpp/mat4x4/#init_outer_product) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:238`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L238) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_permutation_wxyz Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_permutation_wxyz/ ```c SHZ_INLINE void shz_mat4x4_init_permutation_wxyz(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Initializes the matrix to to a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_permutation_wxyz`](https://sh4zam.com/api/cpp/mat4x4/#init_permutation_wxyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:244`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L244) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_permutation_yzwx Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_permutation_yzwx/ ```c SHZ_INLINE void shz_mat4x4_init_permutation_yzwx(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Initializes the matrix to to a permutation matrix, which reorders the components of transformed vectors to be in YZWX order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_permutation_yzwx`](https://sh4zam.com/api/cpp/mat4x4/#init_permutation_yzwx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:250`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L250) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_perspective Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_perspective/ ```c SHZ_INLINE void shz_mat4x4_init_perspective(shz_mat4x4_t* mat, float fov, float aspect, float znear) SHZ_NOEXCEPT; ``` Initializes the given matrix to a perspective projection matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `fov` | `float` | | | `aspect` | `float` | | | `znear` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_perspective`](https://sh4zam.com/api/cpp/mat4x4/#init_perspective) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:280`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L280) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation_dir Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_dir/ > Initializes the given 4x4 matrix to contain a 3D rotation matrix of angle radians about the given direction ```c SHZ_INLINE void shz_mat4x4_init_rotation_dir(shz_mat4x4_t* mat, float angle, float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes the given 4x4 matrix to contain a 3D rotation matrix of `angle` radians about the given direction. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `angle` | `float` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Details This is a faster version of `shz_mat4x4_init_rotation()` or glRotatef() which requires being passed a unit vector for the rotation axis. ## Warnings - The vector components representing the axis of rotation must be prenormalized! ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_rotation_dir`](https://sh4zam.com/api/cpp/mat4x4/#init_rotation_dir) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:198`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L198) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" ## See also [`shz_mat4x4_init_rotation`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation/) --- # shz_mat4x4_init_rotation_quat Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_quat/ ```c SHZ_INLINE void shz_mat4x4_init_rotation_quat(shz_mat4x4_t* m, shz_quat_t q) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D rotation matrix with its orientation given by a quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `shz_mat4x4_t *` | | | `q` | `shz_quat_t` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:204`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L204) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation_x Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_x/ > Initializes the given matrix to a 3D rotation matrix by xAngle radians over the X-axis ```c SHZ_INLINE void shz_mat4x4_init_rotation_x(shz_mat4x4_t* mat, float xAngle) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D rotation matrix by `xAngle` radians over the X-axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `xAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_rotation_x`](https://sh4zam.com/api/cpp/mat4x4/#init_rotation_x) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:140`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L140) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation_xyz Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_xyz/ ```c SHZ_INLINE void shz_mat4x4_init_rotation_xyz(shz_mat4x4_t* mat, float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D rotation matrix from the intrinsic rotation created by the given Tait-Bryan X-Y-Z angles. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `xAngle` | `float` | | | `yAngle` | `float` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_rotation_xyz`](https://sh4zam.com/api/cpp/mat4x4/#init_rotation_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:158`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L158) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation_y Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_y/ > Initializes the given matrix to a 3D rotation matrix by yAngle radians over the Y-axis ```c SHZ_INLINE void shz_mat4x4_init_rotation_y(shz_mat4x4_t* mat, float yAngle) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D rotation matrix by `yAngle` radians over the Y-axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `yAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_rotation_y`](https://sh4zam.com/api/cpp/mat4x4/#init_rotation_y) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:146`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L146) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation_yxz Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_yxz/ ```c SHZ_INLINE void shz_mat4x4_init_rotation_yxz(shz_mat4x4_t* mat, float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D rotation matrix from the intrinsic rotation created by the given Tait-Bryan Y-X-Z angles. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `yAngle` | `float` | | | `xAngle` | `float` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_rotation_yxz`](https://sh4zam.com/api/cpp/mat4x4/#init_rotation_yxz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:176`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L176) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation_z Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_z/ > Initializes the given matrix to a 3D rotation matrix by zAngle radians over the Z-axis ```c SHZ_INLINE void shz_mat4x4_init_rotation_z(shz_mat4x4_t* mat, float zAngle) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D rotation matrix by `zAngle` radians over the Z-axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobber XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_rotation_z`](https://sh4zam.com/api/cpp/mat4x4/#init_rotation_z) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:152`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L152) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation_zxy Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_zxy/ ```c SHZ_INLINE void shz_mat4x4_init_rotation_zxy(shz_mat4x4_t* mat, float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D rotation matrix from the intrinsic rotation created by the given Tait-Bryan Z-X-Y angles. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `zAngle` | `float` | | | `xAngle` | `float` | | | `yAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_rotation_zxy`](https://sh4zam.com/api/cpp/mat4x4/#init_rotation_zxy) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:170`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L170) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation_zyx Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_zyx/ ```c SHZ_INLINE void shz_mat4x4_init_rotation_zyx(shz_mat4x4_t* mat, float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D rotation matrix from the intrinsic rotation created by the given Tait-Bryan Z-Y-X angles. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `zAngle` | `float` | | | `yAngle` | `float` | | | `xAngle` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_rotation_zyx`](https://sh4zam.com/api/cpp/mat4x4/#init_rotation_zyx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:164`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L164) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_rotation Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation/ > Initializes the given 4x4 matrix to a 3D rotation matrix of angle radians about the vector with the given components ```c SHZ_INLINE void shz_mat4x4_init_rotation(shz_mat4x4_t* mat, float radians, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT; ``` Initializes the given 4x4 matrix to a 3D rotation matrix of `angle` radians about the vector with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `radians` | `float` | | | `xAxis` | `float` | | | `yAxis` | `float` | | | `zAxis` | `float` | | ## Returns Nothing (`void`). ## Notes - This routine works similarly to glRotatef() applied to an identitiy matrix. The given axis will automatically be normalized internally. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:187`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L187) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" ## See also [`shz_mat4x4_init_rotation_dir`](https://sh4zam.com/api/matrix/shz_mat4x4_init_rotation_dir/) --- # shz_mat4x4_init_scale Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_scale/ ```c SHZ_INLINE void shz_mat4x4_init_scale(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D scaling matrix with the given dimensions. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_scale`](https://sh4zam.com/api/cpp/mat4x4/#init_scale) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:134`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L134) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_screen Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_screen/ ```c SHZ_INLINE void shz_mat4x4_init_screen(shz_mat4x4_t* mat, float width, float height) SHZ_NOEXCEPT; ``` Initializes the given matrix to the viewport matrix with the given dimenions. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `width` | `float` | | | `height` | `float` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_screen`](https://sh4zam.com/api/cpp/mat4x4/#init_screen) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:256`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L256) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_symmetric_skew Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_symmetric_skew/ ```c SHZ_INLINE void shz_mat4x4_init_symmetric_skew(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes the given matrix to be the symmetric skew of the given 3D vector components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Notes - This can be useful for batching the cross-product operation against a constant vector. For one-offs, prefer `shz_vec3_cross()`. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_symmetric_skew`](https://sh4zam.com/api/cpp/mat4x4/#init_symmetric_skew) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:232`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L232) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_translation Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_translation/ ```c SHZ_INLINE void shz_mat4x4_init_translation(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes the given matrix to a 3D translation matrix with the given coordinates. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_translation`](https://sh4zam.com/api/cpp/mat4x4/#init_translation) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:128`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L128) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_upper_triangular Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_upper_triangular/ ```c SHZ_INLINE void shz_mat4x4_init_upper_triangular(shz_mat4x4_t* mat, float col1, shz_vec2_t col2, shz_vec3_t col3, shz_vec4_t col4) SHZ_NOEXCEPT; ``` Initializes the given matrix to an upper triangular matrix whose nonzero entries have the given value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `col1` | `float` | | | `col2` | `shz_vec2_t` | | | `col3` | `shz_vec3_t` | | | `col4` | `shz_vec4_t` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_upper_triangular`](https://sh4zam.com/api/cpp/mat4x4/#init_upper_triangular) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:216`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L216) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_init_zero Source: https://sh4zam.com/api/matrix/shz_mat4x4_init_zero/ ```c SHZ_INLINE void shz_mat4x4_init_zero(shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Initializes the given matrix with all 0s for its element values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::init_zero`](https://sh4zam.com/api/cpp/mat4x4/#init_zero) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:110`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L110) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Initialization" --- # shz_mat4x4_inverse_block_triangular Source: https://sh4zam.com/api/matrix/shz_mat4x4_inverse_block_triangular/ ```c void shz_mat4x4_inverse_block_triangular(const shz_mat4x4_t* mtx, shz_mat4x4_t* out) SHZ_NOEXCEPT; ``` Computes the inverse of a 4x4 matrix in block-triangular form. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mtx` | `const shz_mat4x4_t *` | | | `out` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Details This is a special-case faster optimization for 4x4 matrices which take the form: ```text A = [ M b ] [ 0 w ] ``` Where A is 4x4, M is 3x3, b is 3x1, and the bottom row is (0, 0, 0, w) with w != 0. For this block-triangular form, det(A) = det(M) \* w. Then ```text inv(A) = [ inv(M) -inv(M) * b / w ] [ 0 1/w ] ``` ## Notes - A regular 3D transform matrix is already in this form. - `shz_mat4x4_inverse()` will dynamically check whether to use this optimization. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::inverse_block_triangular`](https://sh4zam.com/api/cpp/mat4x4/#inverse_block_triangular) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:844`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L844) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4_inverse Source: https://sh4zam.com/api/matrix/shz_mat4x4_inverse/ ```c void shz_mat4x4_inverse(const shz_mat4x4_t* SHZ_RESTRICT mtrx, shz_mat4x4_t* SHZ_RESTRICT out) SHZ_NOEXCEPT; ``` Computes the inverse of a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mtrx` | `const shz_mat4x4_t *SHZ_RESTRICT` | Pointer to the 4x4 matrix to invert. | | `out` | `shz_mat4x4_t *SHZ_RESTRICT` | Pointer to the resulting inverted matrix. | ## Returns Nothing (`void`). ## Notes - In-place inversion (mtrx == out) is not supported. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::inverse`](https://sh4zam.com/api/cpp/mat4x4/#inverse) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:824`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L824) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4_is_block_triangular Source: https://sh4zam.com/api/matrix/shz_mat4x4_is_block_triangular/ > Returns true if the given matrix is in block-triangular form: having a bottom row in the form of <0.0f, 0.0f, 0.0f, w> ```c SHZ_INLINE bool shz_mat4x4_is_block_triangular(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Returns true if the given matrix is in block-triangular form: having a bottom row in the form of `<0.0f, 0.0f, 0.0f, w>`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns `bool` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:850`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L850) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4_mult_transpose_unaligned Source: https://sh4zam.com/api/matrix/shz_mat4x4_mult_transpose_unaligned/ > Multiplies the regular matrix, lhs, by the transpose of the unaligned matrix, rhs, storing the result into mat ```c SHZ_INLINE void shz_mat4x4_mult_transpose_unaligned(shz_mat4x4_t* mat, const shz_mat4x4_t* lhs, const float rhs[16]) SHZ_NOEXCEPT; ``` Multiplies the regular matrix, `lhs`, by the transpose of the unaligned matrix, `rhs`, storing the result into `mat`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `lhs` | `const shz_mat4x4_t *` | | | `rhs` | `const float [16]` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:651`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L651) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" --- # shz_mat4x4_mult_transpose Source: https://sh4zam.com/api/matrix/shz_mat4x4_mult_transpose/ > Multiplies the regular matrix, lhs, by the transpose of the matrix, rhs, storing the result into mat ```c SHZ_INLINE void shz_mat4x4_mult_transpose(shz_mat4x4_t* mat, const shz_mat4x4_t* lhs, const shz_mat4x4_t* rhs) SHZ_NOEXCEPT; ``` Multiplies the regular matrix, `lhs`, by the transpose of the matrix, `rhs`, storing the result into `mat`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `lhs` | `const shz_mat4x4_t *` | | | `rhs` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:645`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L645) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" --- # shz_mat4x4_mult_unaligned Source: https://sh4zam.com/api/matrix/shz_mat4x4_mult_unaligned/ ```c SHZ_INLINE void shz_mat4x4_mult_unaligned(shz_mat4x4_t* mat, const shz_mat4x4_t* lhs, const float rhs[16]) SHZ_NOEXCEPT; ``` Multiplies two 4x4 matrices together, with the right handed matrix being unaligned, storing the result into a third. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `lhs` | `const shz_mat4x4_t *` | | | `rhs` | `const float [16]` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:639`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L639) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" --- # shz_mat4x4_mult Source: https://sh4zam.com/api/matrix/shz_mat4x4_mult/ ```c SHZ_INLINE void shz_mat4x4_mult(shz_mat4x4_t* mat, const shz_mat4x4_t* lhs, const shz_mat4x4_t* rhs) SHZ_NOEXCEPT; ``` Multiplies two 4x4 matrices together, storing the result into a third. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `lhs` | `const shz_mat4x4_t *` | | | `rhs` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:633`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L633) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" --- # shz_mat4x4_rotate_x Source: https://sh4zam.com/api/matrix/shz_mat4x4_rotate_x/ > Multiplies and accumulates mat by a 3D rotation matrix about the X axis ```c SHZ_INLINE void shz_mat4x4_rotate_x(shz_mat4x4_t* mat, float radians) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by a 3D rotation matrix about the X axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `radians` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::rotate_x`](https://sh4zam.com/api/cpp/mat4x4/#rotate_x) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:558`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L558) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_rotate_xyz Source: https://sh4zam.com/api/matrix/shz_mat4x4_rotate_xyz/ > Multiplies and accumulates mat by 3D rotation matrices about the X then Y then Z axes ```c SHZ_INLINE void shz_mat4x4_rotate_xyz(shz_mat4x4_t* mat, float xRadians, float yRadians, float zRadians) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by 3D rotation matrices about the X then Y then Z axes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `xRadians` | `float` | | | `yRadians` | `float` | | | `zRadians` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::rotate_xyz`](https://sh4zam.com/api/cpp/mat4x4/#rotate_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:576`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L576) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_rotate_y Source: https://sh4zam.com/api/matrix/shz_mat4x4_rotate_y/ > Multiplies and accumulates mat by a 3D rotation matrix about the Y axis ```c SHZ_INLINE void shz_mat4x4_rotate_y(shz_mat4x4_t* mat, float radians) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by a 3D rotation matrix about the Y axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `radians` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::rotate_y`](https://sh4zam.com/api/cpp/mat4x4/#rotate_y) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:564`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L564) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_rotate_yxz Source: https://sh4zam.com/api/matrix/shz_mat4x4_rotate_yxz/ > Multiplies and accumulates mat by 3D rotation matrices about the Y then X then Z axes ```c SHZ_INLINE void shz_mat4x4_rotate_yxz(shz_mat4x4_t* mat, float yRadians, float xRadians, float zRadians) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by 3D rotation matrices about the Y then X then Z axes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `yRadians` | `float` | | | `xRadians` | `float` | | | `zRadians` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::rotate_yxz`](https://sh4zam.com/api/cpp/mat4x4/#rotate_yxz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:594`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L594) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_rotate_z Source: https://sh4zam.com/api/matrix/shz_mat4x4_rotate_z/ > Multiplies and accumulates mat by a 3D rotation matrix about the Z axis ```c SHZ_INLINE void shz_mat4x4_rotate_z(shz_mat4x4_t* mat, float radians) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by a 3D rotation matrix about the Z axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `radians` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::rotate_z`](https://sh4zam.com/api/cpp/mat4x4/#rotate_z) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:570`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L570) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_rotate_zxy Source: https://sh4zam.com/api/matrix/shz_mat4x4_rotate_zxy/ > Multiplies and accumulates mat by 3D rotation matrices about the Z then X then Y axes ```c SHZ_INLINE void shz_mat4x4_rotate_zxy(shz_mat4x4_t* mat, float zRadians, float xRadians, float yRadians) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by 3D rotation matrices about the Z then X then Y axes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `zRadians` | `float` | | | `xRadians` | `float` | | | `yRadians` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::rotate_zxy`](https://sh4zam.com/api/cpp/mat4x4/#rotate_zxy) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:588`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L588) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_rotate_zyx Source: https://sh4zam.com/api/matrix/shz_mat4x4_rotate_zyx/ > Multiplies and accumulates mat by 3D rotation matrices about the Z then Y then X axes ```c SHZ_INLINE void shz_mat4x4_rotate_zyx(shz_mat4x4_t* mat, float zRadians, float yRadians, float xRadians) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by 3D rotation matrices about the Z then Y then X axes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `zRadians` | `float` | | | `yRadians` | `float` | | | `xRadians` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::rotate_zyx`](https://sh4zam.com/api/cpp/mat4x4/#rotate_zyx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:582`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L582) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_rotate Source: https://sh4zam.com/api/matrix/shz_mat4x4_rotate/ > Multiplies and accumulates mat by the 3D rotation matrix formed by the given axis and angle ```c SHZ_INLINE void shz_mat4x4_rotate(shz_mat4x4_t* mat, float radians, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by the 3D rotation matrix formed by the given axis and angle. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `radians` | `float` | | | `xAxis` | `float` | | | `yAxis` | `float` | | | `zAxis` | `float` | | ## Returns Nothing (`void`). ## Notes - Equivalent to glRotatef(). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::rotate`](https://sh4zam.com/api/cpp/mat4x4/#rotate) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:601`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L601) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_row Source: https://sh4zam.com/api/matrix/shz_mat4x4_row/ > Extracts the row index as a 4D row vector from the given matrix ```c SHZ_INLINE shz_vec4_t shz_mat4x4_row(const shz_mat4x4_t* mat, size_t row) SHZ_NOEXCEPT; ``` Extracts the `row` index as a 4D row vector from the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `row` | `size_t` | | ## Returns `shz_vec4_t` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::row`](https://sh4zam.com/api/cpp/mat4x4/#row) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:308`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L308) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_scale_reverse Source: https://sh4zam.com/api/matrix/shz_mat4x4_scale_reverse/ ```c SHZ_INLINE void shz_mat4x4_scale_reverse(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Pre-multiplies and accumulates the given matrix onto the 3D scaling matrix with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX ## Naming and requirements - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::scale_reverse`](https://sh4zam.com/api/cpp/mat4x4/#scale_reverse) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:620`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L620) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Reverse GL Transformations" --- # shz_mat4x4_scale Source: https://sh4zam.com/api/matrix/shz_mat4x4_scale/ > Multiplies and accumulates mat by a 3D scaling matrix with the given components ```c SHZ_INLINE void shz_mat4x4_scale(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by a 3D scaling matrix with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Notes - glScalef() equivalent. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::scale`](https://sh4zam.com/api/cpp/mat4x4/#scale) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:552`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L552) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_set_col Source: https://sh4zam.com/api/matrix/shz_mat4x4_set_col/ > Sets the values of mat at the given col to those of the 4D vector, vec ```c SHZ_INLINE void shz_mat4x4_set_col(shz_mat4x4_t* mat, size_t col, shz_vec4_t vec) SHZ_NOEXCEPT; ``` Sets the values of `mat` at the given `col` to those of the 4D vector, `vec`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `col` | `size_t` | | | `vec` | `shz_vec4_t` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::set_col`](https://sh4zam.com/api/cpp/mat4x4/#set_col) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:352`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L352) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Setting" --- # shz_mat4x4_set_diagonal Source: https://sh4zam.com/api/matrix/shz_mat4x4_set_diagonal/ ```c SHZ_INLINE void shz_mat4x4_set_diagonal(shz_mat4x4_t* mat, float x, float y, float z, float w) SHZ_NOEXCEPT; ``` Assigns only the 4 elements along the diagonal of the given matrix to the given values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | | `w` | `float` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::set_diagonal`](https://sh4zam.com/api/cpp/mat4x4/#set_diagonal) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:370`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L370) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Setting" --- # shz_mat4x4_set_rotation_quat Source: https://sh4zam.com/api/matrix/shz_mat4x4_set_rotation_quat/ ```c SHZ_INLINE void shz_mat4x4_set_rotation_quat(shz_mat4x4_t* m, shz_quat_t q) SHZ_NOEXCEPT; ``` Sets just the rotational component of the matrix to the orientation given by a quaternion, keeping the other elements in-tact. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `shz_mat4x4_t *` | | | `q` | `shz_quat_t` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::set_rotation`](https://sh4zam.com/api/cpp/mat4x4/#set_rotation) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:367`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L367) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Setting" --- # shz_mat4x4_set_row Source: https://sh4zam.com/api/matrix/shz_mat4x4_set_row/ > Sets the values of mat at the given row to those of the 4D vector, vec ```c SHZ_INLINE void shz_mat4x4_set_row(shz_mat4x4_t* mat, size_t row, shz_vec4_t vec) SHZ_NOEXCEPT; ``` Sets the values of `mat` at the given `row` to those of the 4D vector, `vec`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `row` | `size_t` | | | `vec` | `shz_vec4_t` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::set_row`](https://sh4zam.com/api/cpp/mat4x4/#set_row) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:349`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L349) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Setting" --- # shz_mat4x4_set_scale Source: https://sh4zam.com/api/matrix/shz_mat4x4_set_scale/ ```c SHZ_INLINE void shz_mat4x4_set_scale(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Assigns only the 3D scale-related elements of the given matrix to the given values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::set_scale`](https://sh4zam.com/api/cpp/mat4x4/#set_scale) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:364`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L364) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Setting" --- # shz_mat4x4_set_translation Source: https://sh4zam.com/api/matrix/shz_mat4x4_set_translation/ ```c SHZ_INLINE void shz_mat4x4_set_translation(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Assigns only the 3D translation-related elements of the given matrix to the given values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::set_translation`](https://sh4zam.com/api/cpp/mat4x4/#set_translation) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:361`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L361) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Setting" --- # shz_mat4x4_swap_cols Source: https://sh4zam.com/api/matrix/shz_mat4x4_swap_cols/ > Swaps the 4D column vectors located at col1 and col2 within mat ```c SHZ_INLINE void shz_mat4x4_swap_cols(shz_mat4x4_t* mat, size_t col1, size_t col2) SHZ_NOEXCEPT; ``` Swaps the 4D column vectors located at `col1` and `col2` within `mat`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `col1` | `size_t` | | | `col2` | `size_t` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::swap_cols`](https://sh4zam.com/api/cpp/mat4x4/#swap_cols) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:358`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L358) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Setting" --- # shz_mat4x4_swap_rows Source: https://sh4zam.com/api/matrix/shz_mat4x4_swap_rows/ > Swaps the 4D row vectors located at row1 and row2 within mat ```c SHZ_INLINE void shz_mat4x4_swap_rows(shz_mat4x4_t* mat, size_t row1, size_t row2) SHZ_NOEXCEPT; ``` Swaps the 4D row vectors located at `row1` and `row2` within `mat`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `row1` | `size_t` | | | `row2` | `size_t` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::swap_rows`](https://sh4zam.com/api/cpp/mat4x4/#swap_rows) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:355`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L355) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Setting" --- # shz_mat4x4_swap Source: https://sh4zam.com/api/matrix/shz_mat4x4_swap/ > Swaps the contents of the two given matrices, matA and matB ```c SHZ_INLINE void shz_mat4x4_swap(shz_mat4x4_t* matA, shz_mat4x4_t* matB) SHZ_NOEXCEPT; ``` Swaps the contents of the two given matrices, `matA` and `matB`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matA` | `shz_mat4x4_t *` | | | `matB` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:865`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L865) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4_t Source: https://sh4zam.com/api/matrix/shz_mat4x4_t/ ```c typedef SHZ_ALIGNAS(8) struct shz_mat4x4 { union { //!< Inner convenience union. float elem[16]; //!< Access the matrix as a 1D array of 16 single-precision floats. float elem2D[4][4]; //!< Access the matrix as a 2D array of 4x4 single-precision floats. shz_vec4_t col[4]; //!< Access the matrix as an array of 4 1x4 column vectors. struct { //!< Named column vectors. shz_vec4_t left; //!< Access the first column of the matrix as a 1x4 vector. shz_vec4_t up; //!< Access the second column of the matrix as a 1x4 vector. shz_vec4_t forward; //!< Access the third column of the matrix as a 1x4 vector. shz_vec4_t pos; //!< Access the last column of the matrix as a 1x4 vector. }; }; } shz_mat4x4_t; ``` Structure representing a 4x4 column-major matrix. ## Fields | Field | Type | Description | | --- | --- | --- | | `elem` | `float[16]` | \< Inner convenience union. | | `elem2D` | `float[4][4]` | Access the matrix as a 2D array of 4x4 single-precision floats. | | `col` | `shz_vec4_t[4]` | Access the matrix as an array of 4 1x4 column vectors. | | `left` | `shz_vec4_t` | \< Named column vectors. | | `up` | `shz_vec4_t` | Access the second column of the matrix as a 1x4 vector. | | `forward` | `shz_vec4_t` | Access the third column of the matrix as a 1x4 vector. | | `pos` | `shz_vec4_t` | Access the last column of the matrix as a 1x4 vector. | ## Warnings - This structure MUST be aligned on 8-byte boundaries! ## Availability - **C++ equivalent:** [`shz::mat4x4`](https://sh4zam.com/api/cpp/mat4x4/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_matrix.h:65`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L65) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Types" --- # shz_mat4x4_to_quat Source: https://sh4zam.com/api/matrix/shz_mat4x4_to_quat/ ```c SHZ_INLINE shz_quat_t shz_mat4x4_to_quat(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Converts the given 4x4 orientation matrix into a quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns `shz_quat_t` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::to_quat`](https://sh4zam.com/api/cpp/mat4x4/#to_quat) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:806`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L806) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4_trace Source: https://sh4zam.com/api/matrix/shz_mat4x4_trace/ ```c SHZ_INLINE float shz_mat4x4_trace(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Returns the trace of the given 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns `float` ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::trace`](https://sh4zam.com/api/cpp/mat4x4/#trace) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:327`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L327) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Getting" --- # shz_mat4x4_transform_point2_transpose Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_point2_transpose/ ```c SHZ_INLINE shz_vec2_t shz_mat4x4_transform_point2_transpose(const shz_mat4x4_t* mat, shz_vec2_t pt) SHZ_NOEXCEPT; ``` Transforms a 2D point by the transpose of a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `pt` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Details This is a routine specializing in one-off transforms of a *single* 2D point by the transpose of a a *single* 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 2D points against the same 4x4 matrix, preload the matrix into XMTRX, use `shz_xmtrx_transpose()`, then use `shz_xmtrx_transform_point2()`. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:781`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L781) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_xmtrx_transpose`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transpose/), [`shz_xmtrx_transform_point2`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point2/) --- # shz_mat4x4_transform_point2 Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_point2/ ```c SHZ_INLINE shz_vec2_t shz_mat4x4_transform_point2(const shz_mat4x4_t* mat, shz_vec2_t pt) SHZ_NOEXCEPT; ``` Transforms a 2D point by a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `pt` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Details This is a routine specializing in one-off transforms of a *single* 2D point by a *single* 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 2D points against the same 4x4 matrix, preload the matrix into XMTRX, then use `shz_xmtrx_transform_point2()`. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:752`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L752) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_xmtrx_transform_point2`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point2/) --- # shz_mat4x4_transform_point3_transpose Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_point3_transpose/ ```c SHZ_INLINE shz_vec3_t shz_mat4x4_transform_point3_transpose(const shz_mat4x4_t* mat, shz_vec3_t pt) SHZ_NOEXCEPT; ``` Transforms a 3D point by the transpose of a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `pt` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Details This is a routine specializing in one-off transforms of a *single* 3D point by the transpose of a a *single* 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 3D points against the same 4x4 matrix, preload the matrix into XMTRX, use `shz_xmtrx_transpose()`, then use `shz_xmtrx_transform_point2()`. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:796`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L796) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_xmtrx_transpose`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transpose/), [`shz_xmtrx_transform_point3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point3/) --- # shz_mat4x4_transform_point3 Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_point3/ ```c SHZ_INLINE shz_vec3_t shz_mat4x4_transform_point3(const shz_mat4x4_t* mat, shz_vec3_t pt) SHZ_NOEXCEPT; ``` Transforms a 3D point by a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `pt` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Details This is a routine specializing in one-off transforms of a *single* 3D point by a *single* 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 3D points against the same 4x4 matrix, preload the matrix into XMTRX, then use `shz_xmtrx_transform_point3()`. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:766`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L766) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_xmtrx_transform_point3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point3/) --- # shz_mat4x4_transform_vec2_transpose Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec2_transpose/ ```c SHZ_INLINE shz_vec2_t shz_mat4x4_transform_vec2_transpose(const shz_mat4x4_t* m, shz_vec2_t v) SHZ_NOEXCEPT; ``` Transforms a 2D vector the the transpose of a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `const shz_mat4x4_t *` | | | `v` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Details This is a routine specializing in one-off transforms of a **single** 2D vector by the transpose of a **single** 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 2D vectors against the transpose of the same 4x4 matrix, preload the matrix into XMTRX, take its transpose with `shz_xmtrx_transpose()`, then use `shz_xmtrx_transform_vec2()`. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:708`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L708) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_xmtrx_transpose`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transpose/), [`shz_xmtrx_transform_vec2`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec2/) --- # shz_mat4x4_transform_vec2 Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec2/ ```c SHZ_INLINE shz_vec2_t shz_mat4x4_transform_vec2(const shz_mat4x4_t* m, shz_vec2_t v) SHZ_NOEXCEPT; ``` Transforms a 2D vector by a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `const shz_mat4x4_t *` | | | `v` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Details This is a routine specializing in one-off transforms of a **single** 2D vector by a **single** 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 2D vectors against the same 4x4 matrix, preload the matrix into XMTRX, then use `shz_xmtrx_transform_vec2()`. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:665`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L665) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_xmtrx_transform_vec3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec3/) --- # shz_mat4x4_transform_vec3_transpose Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec3_transpose/ ```c SHZ_INLINE shz_vec3_t shz_mat4x4_transform_vec3_transpose(const shz_mat4x4_t* m, shz_vec3_t v) SHZ_NOEXCEPT; ``` Transforms a 3D vector the the transpose of a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `const shz_mat4x4_t *` | | | `v` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Details This is a routine specializing in one-off transforms of a **single** 3D vector by the transpose of a **single** 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 3D vectors against the transpose of the same 4x4 matrix, preload the matrix into XMTRX, take its transpose with `shz_xmtrx_transpose()`, then use `shz_xmtrx_transform_vec3()`. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:723`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L723) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_xmtrx_transpose`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transpose/), [`shz_xmtrx_transform_vec3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec3/) --- # shz_mat4x4_transform_vec3 Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec3/ ```c SHZ_INLINE shz_vec3_t shz_mat4x4_transform_vec3(const shz_mat4x4_t* m, shz_vec3_t v) SHZ_NOEXCEPT; ``` Transforms a 3D vector by a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `const shz_mat4x4_t *` | | | `v` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Details This is a routine specializing in one-off transforms of a **single** 3D vector (such as a normal, without a W component) by a **single** 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 3D vectors against the same 4x4 matrix, preload the matrix into XMTRX, then use `shz_xmtrx_transform_vec3()`. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:679`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L679) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_mat4x4_transform_vec4`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec4/), [`shz_xmtrx_transform_vec3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec3/) --- # shz_mat4x4_transform_vec4_transpose Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec4_transpose/ ```c SHZ_INLINE shz_vec4_t shz_mat4x4_transform_vec4_transpose(const shz_mat4x4_t* m, shz_vec4_t v) SHZ_NOEXCEPT; ``` Transforms a 4D vector the the transpose of a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `m` | `const shz_mat4x4_t *` | | | `v` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Details This is a routine specializing in one-off transforms of a **single** 4D vector by the transpose of a **single** 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 4D vectors against the transpose of the same 4x4 matrix, preload the matrix into XMTRX, take its transpose with `shz_xmtrx_transpose()`, then use `shz_xmtrx_transform_vec4()`. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:738`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L738) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_xmtrx_transpose`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transpose/), [`shz_xmtrx_transform_vec4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec4/) --- # shz_mat4x4_transform_vec4 Source: https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec4/ ```c SHZ_INLINE shz_vec4_t shz_mat4x4_transform_vec4(const shz_mat4x4_t* mat, shz_vec4_t in) SHZ_NOEXCEPT; ``` Transforms a 4D vector by a 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `in` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Details This is a routine specializing in one-off transforms of a *single* 4D vector by a *single* 4x4 matrix. It should be faster than going through XMTRX. ## Notes - For batch transforming multiple 4D vectors against the same 4x4 matrix, preload the matrix into XMTRX, then use `shz_xmtrx_transform_vec4()`. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:693`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L693) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Transforming" ## See also [`shz_mat4x4_transform_vec3`](https://sh4zam.com/api/matrix/shz_mat4x4_transform_vec3/), [`shz_xmtrx_transform_vec4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec4/) --- # shz_mat4x4_translate_reverse Source: https://sh4zam.com/api/matrix/shz_mat4x4_translate_reverse/ ```c SHZ_INLINE void shz_mat4x4_translate_reverse(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Pre-multiplies and accumulates the given matrix onto the 3D translation matrix with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routin clobbers XMTRX. ## Naming and requirements - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::translate_reverse`](https://sh4zam.com/api/cpp/mat4x4/#translate_reverse) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:614`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L614) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Reverse GL Transformations" --- # shz_mat4x4_translate Source: https://sh4zam.com/api/matrix/shz_mat4x4_translate/ > Multiplies and accumulates mat by a 3D translation matrix with the given components ```c SHZ_INLINE void shz_mat4x4_translate(shz_mat4x4_t* mat, float x, float y, float z) SHZ_NOEXCEPT; ``` Multiplies and accumulates `mat` by a 3D translation matrix with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `shz_mat4x4_t *` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Notes - glTranslatef() equivalent. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::mat4x4::translate`](https://sh4zam.com/api/cpp/mat4x4/#translate) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:545`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L545) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "GL Transformations" --- # shz_mat4x4_transpose Source: https://sh4zam.com/api/matrix/shz_mat4x4_transpose/ > Stores the transpose of mat within out ```c SHZ_INLINE void shz_mat4x4_transpose(const shz_mat4x4_t* mat, shz_mat4x4_t* out) SHZ_NOEXCEPT; ``` Stores the transpose of `mat` within `out`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | | `out` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_matrix.h:812`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L812) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous" --- # shz_mat4x4 Source: https://sh4zam.com/api/matrix/shz_mat4x4/ > Alternate shz_mat4x4_t C typedef for those who hate POSIX style ```c typedef shz_mat4x4_t shz_mat4x4; ``` Alternate [`shz_mat4x4_t`](https://sh4zam.com/api/matrix/shz_mat4x4_t/) C typedef for those who hate POSIX style. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_matrix.h:80`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L80) - **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Types" --- # Memory API Source: https://sh4zam.com/api/memory/ > Routines for copying memory, store queues, cache operations and prefetching This API provides special instruction intrinsics, cache operations and `memcpy()`-type routines. `shz_memcpy()` is a generic drop-in `memcpy()` replacement; when you know and control the alignment and batch sizes, you can micro-optimize by calling the most specific specialization instead. `sq_` routines write through the SH4 store queues, and `_xmtrx` routines use the XMTRX register bank as a scratch buffer, clobbering it. `memcpy()`-like routines will typically always check for proper alignment and size increments of parameters using `assert()`, so make sure to build a release build (`-DNDEBUG`) for maximal gainz when not debugging. There is no `shz_memset()` yet; it is listed as a TODO in the header. - **C header:** `#include ` - **C++ header:** `#include ` - **Symbols:** 23 ## Suffixes Suffixes used in this module. The full list is in [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). - `sq_`: Writes through the SH4 store queues (burst writes to memory or the PVR). - `_xmtrx`: Uses the XMTRX register bank as a 64-byte scratch buffer. Clobbers XMTRX. - `memcpyN`: A numeric suffix on `memcpy`/`memset` names the element granularity or count, e.g. `shz_memcpy32_1` copies exactly one 32-byte line. ## C stdlib Replacements Routine replacing the C standard library copy/set API. | Symbol | Description | | --- | --- | | [`shz_memcpy`](https://sh4zam.com/api/memory/shz_memcpy/) | Generic drop-in fast memcpy() replacement. | | [`shz_memmove`](https://sh4zam.com/api/memory/shz_memmove/) | Generic drop-in fast memmove() replacement. | ## Specializations Specialized routines for specific sizes + alignments. | Symbol | Description | | --- | --- | | [`shz_memcpy1`](https://sh4zam.com/api/memory/shz_memcpy1/) | Copies an unaligned buffer to another one byte at a time. | | [`shz_memcpy2`](https://sh4zam.com/api/memory/shz_memcpy2/) | Copies from one 2-byte aligned buffer to another two bytes at a time. | | [`shz_memcpy4`](https://sh4zam.com/api/memory/shz_memcpy4/) | Copies a from one 4-byte aligned buffer to another 4 bytes at a time. | | [`shz_memcpy8`](https://sh4zam.com/api/memory/shz_memcpy8/) | Copies a from one 8-byte aligned buffer to another 8 bytes at a time. | | [`shz_memset8`](https://sh4zam.com/api/memory/shz_memset8/) | Assigns the given 8-byte `value` to the `bytes` in `dst`. | | [`shz_memcpy32`](https://sh4zam.com/api/memory/shz_memcpy32/) | Copies `bytes` from the `src` to the `dst` buffer in 32-byte chunks. | | [`shz_sq_memcpy32`](https://sh4zam.com/api/memory/shz_sq_memcpy32/) | Copies `bytes` from `src` to `dst` in 32-byte chunks, using the Store Queues. | | [`shz_sq_memcpy32_xmtrx`](https://sh4zam.com/api/memory/shz_sq_memcpy32_xmtrx/) | Copies `bytes` from `src` to `dst` in 32-byte chunks, using the Store Queues and XMTRX. | | [`shz_memcpy64`](https://sh4zam.com/api/memory/shz_memcpy64/) | Specialized memcpy() variant for copying multiples of 64-bytes. | | [`shz_memcpy128`](https://sh4zam.com/api/memory/shz_memcpy128/) | Specialized memcpy() variant for copying multiples of 128 bytes. | ## Constant-sized Operations Specialized routines for operating on statically sized buffers. | Symbol | Description | | --- | --- | | [`shz_memcpy2_8`](https://sh4zam.com/api/memory/shz_memcpy2_8/) | Copies 8 shorts from `src` to `dst`. | | [`shz_memcpy2_16`](https://sh4zam.com/api/memory/shz_memcpy2_16/) | Copies 16 shorts from `src` to `dst`. | | [`shz_memset2_16`](https://sh4zam.com/api/memory/shz_memset2_16/) | Sets the values of the 16 shorts pointed to by `dst` to the given `value`. | | [`shz_memcpy4_16`](https://sh4zam.com/api/memory/shz_memcpy4_16/) | Copies 16 4-byte, long values from `src` to `dst`. | | [`shz_memcpy32_1`](https://sh4zam.com/api/memory/shz_memcpy32_1/) | Copies 32 bytes from `p1` to `p2` as a single chunk. | | [`shz_memswap32_1`](https://sh4zam.com/api/memory/shz_memswap32_1/) | Swaps the values within the given 32-byte buffers. | | [`shz_memswap32_1_xmtrx`](https://sh4zam.com/api/memory/shz_memswap32_1_xmtrx/) | Swaps the values within the given 32-byte buffers, using XMTRX. | | [`shz_sq_memcpy32_1`](https://sh4zam.com/api/memory/shz_sq_memcpy32_1/) | Copies `src` to `dst` in a single 32-byte transaction using the Store Queues. | | [`shz_sq_memcpy32_1_xmtrx`](https://sh4zam.com/api/memory/shz_sq_memcpy32_1_xmtrx/) | Copies `src` to `dst` in a single 32-byte transaction using the Store Queues and XMTRX. | | [`shz_dcache_alloc_line`](https://sh4zam.com/api/memory/shz_dcache_alloc_line/) | Intrinsic around the SH4 `MOVCA.L` instruction. | ## Macros | Symbol | Description | | --- | --- | | [`SHZ_PREFETCH`](https://sh4zam.com/api/memory/SHZ_PREFETCH/) | Used to prepopulate the cache line mapping to the given address, before it is used. | --- # shz_dcache_alloc_line Source: https://sh4zam.com/api/memory/shz_dcache_alloc_line/ > Intrinsic around the SH4 MOVCA.L instruction ```c SHZ_INLINE void shz_dcache_alloc_line(void* src) SHZ_NOEXCEPT; ``` Intrinsic around the SH4 `MOVCA.L` instruction. ## Parameters | Name | Type | Description | | --- | --- | --- | | `src` | `void *` | | ## Returns Nothing (`void`). ## Details Preallocates the cache-line containing `src`. Zero-initializes all 32-bytes within the `src` cache-line, setting the valid bit to `1`. ## Availability - **C++ equivalent:** [`shz::dcache_alloc_line`](https://sh4zam.com/api/cpp/#shzdcache_alloc_line) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:365`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L365) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" --- # shz_memcpy Source: https://sh4zam.com/api/memory/shz_memcpy/ ```c SHZ_INLINE void* shz_memcpy( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Generic drop-in fast memcpy() replacement. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details Copies `bytes` from `src` to `dst`, determining the most efficient specialization to call into at run-time, returning `dst`. There are no alignment or size requirements for this routine, but it is specifically optimized for 2-, 4-, 8-, and 32-byte alignments, with bigger alignments bringing bigger gainz. ## Notes - When you know of and can control the `src` and `dst` alignments and batch sizes, you can micro-optimize by calling into the most specific memcpy() specialization for your given scenario, over just using this generic implementation, which must choose which one to use at run-time. ## Warnings - `dst` and `src` buffers should not be overlapping. ## Availability - **C++ equivalent:** [`shz::memcpy`](https://sh4zam.com/api/cpp/#shzmemcpy) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:75`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L75) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "C stdlib Replacements" ## See also [`shz_memcpy1`](https://sh4zam.com/api/memory/shz_memcpy1/), [`shz_memcpy2`](https://sh4zam.com/api/memory/shz_memcpy2/), [`shz_memcpy4`](https://sh4zam.com/api/memory/shz_memcpy4/), [`shz_memcpy8`](https://sh4zam.com/api/memory/shz_memcpy8/), [`shz_memcpy32`](https://sh4zam.com/api/memory/shz_memcpy32/), [`shz_memcpy64`](https://sh4zam.com/api/memory/shz_memcpy64/), [`shz_memcpy128`](https://sh4zam.com/api/memory/shz_memcpy128/) --- # shz_memcpy1 Source: https://sh4zam.com/api/memory/shz_memcpy1/ ```c SHZ_INLINE void* shz_memcpy1( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Copies an unaligned buffer to another one byte at a time. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details The `dst` pointer is returned. ## Notes - Typically, unless you know you are copying a tiny number of definitely unaligned bytes, you want to use `shz_memcpy()`, which automatically handles arbitrary alignment for you, potentially more efficiently than copying byte-by-byte. ## Warnings - `dst` and `src` buffers should not be overlapping. ## Availability - **C++ equivalent:** [`shz::memcpy1`](https://sh4zam.com/api/cpp/#shzmemcpy1) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:114`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L114) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" ## See also [`shz_memcpy`](https://sh4zam.com/api/memory/shz_memcpy/) --- # shz_memcpy2_8 Source: https://sh4zam.com/api/memory/shz_memcpy2_8/ > Copies 8 shorts from src to dst ```c SHZ_INLINE void shz_memcpy2_8( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src) SHZ_NOEXCEPT; ``` Copies 8 shorts from `src` to `dst`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | ## Returns Nothing (`void`). ## Warnings - `src` and `dst` buffers must not overlap. - `dst` and `src` must both be aligned by at least two bytes. ## Availability - **C++ equivalent:** [`shz::memcpy2_8`](https://sh4zam.com/api/cpp/#shzmemcpy2_8) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:273`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L273) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" --- # shz_memcpy2_16 Source: https://sh4zam.com/api/memory/shz_memcpy2_16/ > Copies 16 shorts from src to dst ```c SHZ_INLINE void shz_memcpy2_16( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src) SHZ_NOEXCEPT; ``` Copies 16 shorts from `src` to `dst`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | ## Returns Nothing (`void`). ## Warnings - `src` and `dst` buffers must not overlap. - `dst` and `src` must both be aligned by at least two bytes. ## Availability - **C++ equivalent:** [`shz::memcpy2_16`](https://sh4zam.com/api/cpp/#shzmemcpy2_16) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:284`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L284) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" --- # shz_memcpy2 Source: https://sh4zam.com/api/memory/shz_memcpy2/ ```c SHZ_INLINE void* shz_memcpy2( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Copies from one 2-byte aligned buffer to another two bytes at a time. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details The `dst` pointer is returned. ## Warnings - `dst` and `src` must both be aligned by at least 2 bytes, and `bytes` must be a multiple of 2. - `dst` and `src` buffers should not be overlapping. ## Availability - **C++ equivalent:** [`shz::memcpy2`](https://sh4zam.com/api/cpp/#shzmemcpy2) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:129`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L129) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" --- # shz_memcpy4_16 Source: https://sh4zam.com/api/memory/shz_memcpy4_16/ > Copies 16 4-byte, long values from src to dst ```c SHZ_INLINE void shz_memcpy4_16( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src) SHZ_NOEXCEPT; ``` Copies 16 4-byte, long values from `src` to `dst`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | ## Returns Nothing (`void`). ## Warnings - `src` and `dst` buffers must not overlap. - The `src` and `dst` buffers must both be at least 4-byte aligned. ## Availability - **C++ equivalent:** [`shz::memcpy4_16`](https://sh4zam.com/api/cpp/#shzmemcpy4_16) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:302`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L302) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" --- # shz_memcpy4 Source: https://sh4zam.com/api/memory/shz_memcpy4/ ```c SHZ_INLINE void* shz_memcpy4( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Copies a from one 4-byte aligned buffer to another 4 bytes at a time. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details The `dst` buffer is returned. ## Warnings - `dst` and `src` must both be aligned by at least 4 bytes, and `bytes` must be a multiple of 4. - `dst` and `src` buffers should not be overlapping. ## Availability - **C++ equivalent:** [`shz::memcpy4`](https://sh4zam.com/api/cpp/#shzmemcpy4) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:144`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L144) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" --- # shz_memcpy8 Source: https://sh4zam.com/api/memory/shz_memcpy8/ ```c SHZ_INLINE void* shz_memcpy8( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Copies a from one 8-byte aligned buffer to another 8 bytes at a time. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details The `dst` buffer is returned. ## Warnings - `dst` and `src` must both be aligned by at least 8 bytes, and `bytes` must be a multiple of 8. - `src` and `dst` should not overlap. ## Availability - **C++ equivalent:** [`shz::memcpy8`](https://sh4zam.com/api/cpp/#shzmemcpy8) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:159`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L159) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" --- # shz_memcpy32_1 Source: https://sh4zam.com/api/memory/shz_memcpy32_1/ > Copies 32 bytes from p1 to p2 as a single chunk ```c SHZ_INLINE void shz_memcpy32_1( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src) SHZ_NOEXCEPT; ``` Copies 32 bytes from `p1` to `p2` as a single chunk. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | ## Returns Nothing (`void`). ## Warnings - `dst` must be 32-byte aligned, while `src` can be only 8-byte aligned. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:310`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L310) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" --- # shz_memcpy32 Source: https://sh4zam.com/api/memory/shz_memcpy32/ > Copies bytes from the src to the dst buffer in 32-byte chunks ```c SHZ_INLINE void* shz_memcpy32( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Copies `bytes` from the `src` to the `dst` buffer in 32-byte chunks. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details Transfers from 8-byte aligned buffer, `src` to 32-byte aligned buffer, `dst`, 32 bytes at a time. Returns the `dst` address. ## Notes - This is the quickest way to move 32-byte chunks of data around *within memory*, but the `shz_sq_memcpy32()` will be faster when writing through the cache to external memory. ## Warnings - `dst` must be 32-byte aligned, while `src` can be only 8-byte aligned. `bytes` must be a multiple of 32. - `src` and `dst` buffers must not overlap. ## Availability - **C++ equivalent:** [`shz::memcpy32`](https://sh4zam.com/api/cpp/#shzmemcpy32) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:189`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L189) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" ## See also [`shz_sq_memcpy32`](https://sh4zam.com/api/memory/shz_sq_memcpy32/) --- # shz_memcpy64 Source: https://sh4zam.com/api/memory/shz_memcpy64/ ```c SHZ_INLINE void* shz_memcpy64( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Specialized memcpy() variant for copying multiples of 64-bytes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details Copies a from an 8-byte aligned buffer to a 32-byte aligned buffer, 64 bytes at a time. Returns the `dst` address. ## Warnings - `src` and `dst` buffers must not overlap. - `dst` must be 32-byte aligned, while `src` can be only 8-byte aligned. `bytes` must be a multiple of 64. ## Availability - **C++ equivalent:** [`shz::memcpy64`](https://sh4zam.com/api/cpp/#shzmemcpy64) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:238`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L238) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" --- # shz_memcpy128 Source: https://sh4zam.com/api/memory/shz_memcpy128/ ```c SHZ_INLINE void* shz_memcpy128( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Specialized memcpy() variant for copying multiples of 128 bytes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details Copies a from an 8-byte aligned buffer to a 32-byte aligned buffer, 128 bytes at a time. Returns the `dst` address. ## Warnings - `src` and `dst` buffers must not overlap. - `dst` must be 32-byte aligned, while `src` can be only 8-byte aligned. `bytes` must be a multiple of 128. ## Availability - **C++ equivalent:** [`shz::memcpy128`](https://sh4zam.com/api/cpp/#shzmemcpy128) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:254`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L254) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" --- # shz_memmove Source: https://sh4zam.com/api/memory/shz_memmove/ ```c SHZ_INLINE void* shz_memmove(void* dst, const void* src, size_t bytes) SHZ_NOEXCEPT; ``` Generic drop-in fast memmove() replacement. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *` | | | `src` | `const void *` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details Copies `bytes` from `src` to `dst`, determining the most efficient specialization to call into at run-time, return `dst`. The source and destination buffers are allowed to overlap, making this routine slightly less efficient, but more versatile than `shz_memcpy()`. There is no alignment or size requirement for this routine. ## Availability - **C++ equivalent:** [`shz::memmove`](https://sh4zam.com/api/cpp/#shzmemmove) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:90`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L90) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "C stdlib Replacements" ## See also [`shz_memcpy`](https://sh4zam.com/api/memory/shz_memcpy/) --- # shz_memset2_16 Source: https://sh4zam.com/api/memory/shz_memset2_16/ > Sets the values of the 16 shorts pointed to by dst to the given value ```c SHZ_INLINE void shz_memset2_16(void* dst, uint16_t value) SHZ_NOEXCEPT; ``` Sets the values of the 16 shorts pointed to by `dst` to the given `value`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *` | | | `value` | `uint16_t` | | ## Returns Nothing (`void`). ## Warnings - `dst` must be aligned by at least two bytes. ## Availability - **C++ equivalent:** [`shz::memset2_16`](https://sh4zam.com/api/cpp/#shzmemset2_16) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:292`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L292) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" --- # shz_memset8 Source: https://sh4zam.com/api/memory/shz_memset8/ > Assigns the given 8-byte value to the bytes in dst ```c SHZ_INLINE void* shz_memset8(void* dst, uint64_t value, size_t bytes) SHZ_NOEXCEPT; ``` Assigns the given 8-byte `value` to the `bytes` in `dst`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *` | | | `value` | `uint64_t` | | | `bytes` | `size_t` | | ## Returns `void *` ## Warnings - `dst` should be at least 8-byte aligned, and `bytes` should be a multiple of 8! ## Availability - **C++ equivalent:** [`shz::memset8`](https://sh4zam.com/api/cpp/#shzmemset8) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:169`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L169) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" --- # shz_memswap32_1_xmtrx Source: https://sh4zam.com/api/memory/shz_memswap32_1_xmtrx/ ```c SHZ_INLINE void shz_memswap32_1_xmtrx(void* SHZ_RESTRICT p1, void* SHZ_RESTRICT p2) SHZ_NOEXCEPT; ``` Swaps the values within the given 32-byte buffers, using XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `p1` | `void *SHZ_RESTRICT` | | | `p2` | `void *SHZ_RESTRICT` | | ## Returns Nothing (`void`). ## Details Equivalent to `shz_memcpy32_1()`, except copying is done through XMTRX. ## Warnings - This routine clobbers XMTRX! ## Naming and requirements - `_xmtrx`: Uses the XMTRX register bank as a 64-byte scratch buffer. Clobbers XMTRX. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::memswap32_1_xmtrx`](https://sh4zam.com/api/cpp/#shzmemswap32_1_xmtrx) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:328`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L328) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" --- # shz_memswap32_1 Source: https://sh4zam.com/api/memory/shz_memswap32_1/ ```c SHZ_INLINE void shz_memswap32_1(void* SHZ_RESTRICT p1, void* SHZ_RESTRICT p2) SHZ_NOEXCEPT; ``` Swaps the values within the given 32-byte buffers. ## Parameters | Name | Type | Description | | --- | --- | --- | | `p1` | `void *SHZ_RESTRICT` | | | `p2` | `void *SHZ_RESTRICT` | | ## Returns Nothing (`void`). ## Warnings - `p1` and `p2` must be at least 8-byte aligned. ## Availability - **C++ equivalent:** [`shz::memswap32_1`](https://sh4zam.com/api/cpp/#shzmemswap32_1) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:318`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L318) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" --- # SHZ_PREFETCH Source: https://sh4zam.com/api/memory/SHZ_PREFETCH/ ```c #define SHZ_PREFETCH(ptr) SHZ_PREFETCH_(ptr) ``` Used to prepopulate the cache line mapping to the given address, before it is used. ## Parameters | Name | Type | Description | | --- | --- | --- | | `ptr` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_mem.h:45`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L45) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Macros" --- # shz_sq_memcpy32_1_xmtrx Source: https://sh4zam.com/api/memory/shz_sq_memcpy32_1_xmtrx/ > Copies src to dst in a single 32-byte transaction using the Store Queues and XMTRX ```c SHZ_INLINE void* shz_sq_memcpy32_1_xmtrx( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src) SHZ_NOEXCEPT; ``` Copies `src` to `dst` in a single 32-byte transaction using the Store Queues and XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | ## Returns `void *` ## Details Equivalent to `shz_sq_memcpy32_1()`, except copying is done through XMTRX. ## Warnings - This routine clobberx XMTRX. ## Naming and requirements - `_xmtrx`: Uses the XMTRX register bank as a 64-byte scratch buffer. Clobbers XMTRX. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `sq_`: Writes through the SH4 store queues (burst writes to memory or the PVR). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::sq_memcpy32_1_xmtrx`](https://sh4zam.com/api/cpp/#shzsq_memcpy32_1_xmtrx) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:355`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L355) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" ## See also [`shz_memcpy32`](https://sh4zam.com/api/memory/shz_memcpy32/) --- # shz_sq_memcpy32_1 Source: https://sh4zam.com/api/memory/shz_sq_memcpy32_1/ > Copies src to dst in a single 32-byte transaction using the Store Queues ```c SHZ_INLINE void* shz_sq_memcpy32_1( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src) SHZ_NOEXCEPT; ``` Copies `src` to `dst` in a single 32-byte transaction using the Store Queues. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | ## Returns `void *` ## Notes - The Store Queues bypass the SH4's data-cache! They are typically used to transfer to *external memory* and are slower for memory-to-memory transactions. ## Warnings - `dst` must be at least 4-byte aligned, while `src` must be at least 8-byte aligned. ## Naming and requirements - `sq_`: Writes through the SH4 store queues (burst writes to memory or the PVR). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::sq_memcpy32_1`](https://sh4zam.com/api/cpp/#shzsq_memcpy32_1) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:342`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L342) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Constant-sized Operations" ## See also [`shz_memcpy32`](https://sh4zam.com/api/memory/shz_memcpy32/) --- # shz_sq_memcpy32_xmtrx Source: https://sh4zam.com/api/memory/shz_sq_memcpy32_xmtrx/ > Copies bytes from src to dst in 32-byte chunks, using the Store Queues and XMTRX ```c SHZ_INLINE void* shz_sq_memcpy32_xmtrx( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Copies `bytes` from `src` to `dst` in 32-byte chunks, using the Store Queues and XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details Equiavalent to `shz_sq_memcpy32()`, except copying is done through XMTRX. ## Warnings - This routine clobbers XMTRX. ## Naming and requirements - `_xmtrx`: Uses the XMTRX register bank as a 64-byte scratch buffer. Clobbers XMTRX. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `sq_`: Writes through the SH4 store queues (burst writes to memory or the PVR). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::sq_memcpy32_xmtrx`](https://sh4zam.com/api/cpp/#shzsq_memcpy32_xmtrx) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:222`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L222) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" --- # shz_sq_memcpy32 Source: https://sh4zam.com/api/memory/shz_sq_memcpy32/ > Copies bytes from src to dst in 32-byte chunks, using the Store Queues ```c SHZ_INLINE void* shz_sq_memcpy32( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT; ``` Copies `bytes` from `src` to `dst` in 32-byte chunks, using the Store Queues. ## Parameters | Name | Type | Description | | --- | --- | --- | | `dst` | `void *SHZ_RESTRICT` | | | `src` | `const void *SHZ_RESTRICT` | | | `bytes` | `size_t` | | ## Returns `void *` ## Details Transfers from 8-byte aligned buffer, `src` to 4-byte aligned address, `dst`, 32 bytes at a time, writing through the cache, using the SH4's Store Queues. Returns the `dst` address. ## Notes - This is the quickest way to move 32-byte chunks of data to *external memory*. When copying to cached memory, you must invalidate the cache lines containing `dst` before initiating the copy... Which means this routine becomes slower than doing memory-to-memory copies with `shz_memcpy32()`. ## Warnings - `src` must be at least 8-byte aligned, while `dst` can be only 4-byte aligned. `bytes` must be a multiple of 32. ## Naming and requirements - `sq_`: Writes through the SH4 store queues (burst writes to memory or the PVR). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::sq_memcpy32`](https://sh4zam.com/api/cpp/#shzsq_memcpy32) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_mem.h:211`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L211) - **Module:** [Memory](https://sh4zam.com/api/memory/), section "Specializations" ## See also [`shz_memcpy32`](https://sh4zam.com/api/memory/shz_memcpy32/), [`shz_sq_memcpy32_1`](https://sh4zam.com/api/memory/shz_sq_memcpy32_1/) --- # Quaternion API Source: https://sh4zam.com/api/quat/ > Routines for quaternion math This module contains the public type(s) and interface providing the quaternion math API. Quaternions are a mathematical structure representing a rotation about a single arbitrary axis. `shz_quat_t` is stored in `` order, with W first, and the identity quaternion is (1, 0, 0, 0). Interpolation covers `lerp`, `nlerp`, `slerp` and `squad`, and C++ users get the same API on `shz::quat`. - **C header:** `#include ` - **C++ header:** `#include ` - **C++ types:** [`shz::quat`](https://sh4zam.com/api/cpp/quat/) - **Symbols:** 47 ## Suffixes Suffixes used in this module. The full list is in [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). - `_safe`: Guards degenerate input (zero-length vectors, zero denominators) at a small cost. - `_deg`: Angle argument is in degrees. The default is radians. - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ## Initialization Routines for creating and initializing quaternions. | Symbol | Description | | --- | --- | | [`shz_quat_init`](https://sh4zam.com/api/quat/shz_quat_init/) | Initializes and returns a new quaternion with the given components, in WXYZ order. | | [`shz_quat_identity`](https://sh4zam.com/api/quat/shz_quat_identity/) | Initializes and returns an identity quaternion. | | [`shz_quat_equal`](https://sh4zam.com/api/quat/shz_quat_equal/) | Returns true if the two given quaternions are considered equal based on either absolute or relative tolerance. | | [`shz_quat_from_angles_xyz`](https://sh4zam.com/api/quat/shz_quat_from_angles_xyz/) | Initializes and returns a quaternion with the given X-Y-Z rotations in radians. | | [`shz_quat_from_rotation_xyz`](https://sh4zam.com/api/quat/shz_quat_from_rotation_xyz/) | Returns the quaternion of the rotation `shz_xmtrx_init_rotation_xyz()` builds, from angles in radians. | | [`shz_quat_from_rotation_zyx`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zyx/) | Returns the quaternion of the rotation `shz_xmtrx_init_rotation_zyx()` builds, Qz \* Qy \* Qx, from angles in radians. | | [`shz_quat_from_rotation_zxy`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zxy/) | Returns the quaternion of the rotation `shz_xmtrx_init_rotation_zxy()` builds, Qz \* Qx \* Qy, from angles in radians. | | [`shz_quat_from_rotation_yxz`](https://sh4zam.com/api/quat/shz_quat_from_rotation_yxz/) | Returns the quaternion of the rotation `shz_xmtrx_init_rotation_yxz()` builds, Qy \* Qx \* Qz, from angles in radians. | | [`shz_quat_from_rotation_xyz_u16`](https://sh4zam.com/api/quat/shz_quat_from_rotation_xyz_u16/) | Equivalent to `shz_quat_from_rotation_xyz()`, with 16-bit binary angles (65536 per turn, the FSCA unit). | | [`shz_quat_from_rotation_zyx_u16`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zyx_u16/) | Equivalent to `shz_quat_from_rotation_zyx()`, with 16-bit binary angles. | | [`shz_quat_from_rotation_zxy_u16`](https://sh4zam.com/api/quat/shz_quat_from_rotation_zxy_u16/) | Equivalent to `shz_quat_from_rotation_zxy()`, with 16-bit binary angles. | | [`shz_quat_from_rotation_yxz_u16`](https://sh4zam.com/api/quat/shz_quat_from_rotation_yxz_u16/) | Equivalent to `shz_quat_from_rotation_yxz()`, with 16-bit binary angles. | | [`shz_quat_from_axis_angle`](https://sh4zam.com/api/quat/shz_quat_from_axis_angle/) | Initializes and returns a quaternion representing a rotation of `angle` radians about the given `axis`. | | [`shz_quat_from_look_axis`](https://sh4zam.com/api/quat/shz_quat_from_look_axis/) | Creates a quaternion looking in the given direction with the given reference direction. | | [`shz_quat_from_rotated_axis`](https://sh4zam.com/api/quat/shz_quat_from_rotated_axis/) | Returns the quaternion representing the rotation from axis `v1` to `v2`. | | [`shz_quat_lerp`](https://sh4zam.com/api/quat/shz_quat_lerp/) | Returns the quaternion that is linearly interpolating `a` to `b`, by a t factor of `0.0f-1.0f`. | | [`shz_quat_nlerp`](https://sh4zam.com/api/quat/shz_quat_nlerp/) | Equivalent to `shz_quat_lerp()`, except that the resulting quaternion is normalized. | | [`shz_quat_slerp`](https://sh4zam.com/api/quat/shz_quat_slerp/) | Returns the quaternion that is spherically linearly interpolating `a` to `b`, by a `t` factor of `0.0f-1.0f`. | | [`shz_quat_squad`](https://sh4zam.com/api/quat/shz_quat_squad/) | Evaluates a smooth cubic spherical interpolation (SQUAD) at parameter `t`. | ## Properties Routines returning derived values from a quaternion. | Symbol | Description | | --- | --- | | [`shz_quat_angle`](https://sh4zam.com/api/quat/shz_quat_angle/) | Returns the angle of rotation from the given quaternion. | | [`shz_quat_axis`](https://sh4zam.com/api/quat/shz_quat_axis/) | Returns the axis of rotation from the given quaternion. | | [`shz_quat_angle_x`](https://sh4zam.com/api/quat/shz_quat_angle_x/) | Returns the angle of rotation the quaternion represents about the X axis in radians. | | [`shz_quat_angle_y`](https://sh4zam.com/api/quat/shz_quat_angle_y/) | Returns the angle of rotation the quaternion represents about the Y axis in radians. | | [`shz_quat_angle_z`](https://sh4zam.com/api/quat/shz_quat_angle_z/) | Returns the angle of rotation the quaternion represents about the Z axis in radians. | | [`shz_quat_to_axis_angle`](https://sh4zam.com/api/quat/shz_quat_to_axis_angle/) | Returns both the axis and angle of rotation simultaneously (faster if both are needed) from the given quaternion. | | [`shz_quat_to_angles_xyz`](https://sh4zam.com/api/quat/shz_quat_to_angles_xyz/) | Returns the roll, pitch, and yaw angles of rotation represented by the given quaternion. | | [`shz_quat_magnitude_sqr`](https://sh4zam.com/api/quat/shz_quat_magnitude_sqr/) | Returns the squared magnitude of the given quaternion. | | [`shz_quat_magnitude`](https://sh4zam.com/api/quat/shz_quat_magnitude/) | Returns the magnitude of the given quaternion. | | [`shz_quat_magnitude_inv`](https://sh4zam.com/api/quat/shz_quat_magnitude_inv/) | Returns the inverse magnitude of the given quaternion. | ## Modifiers Routines for returning new quaternions derived from existing ones. | Symbol | Description | | --- | --- | | [`shz_quat_normalize`](https://sh4zam.com/api/quat/shz_quat_normalize/) | Returns the normalized form of the given quaternion. | | [`shz_quat_normalize_safe`](https://sh4zam.com/api/quat/shz_quat_normalize_safe/) | SAFELY returns the normalized form of the given quaternion. | | [`shz_quat_conjugate`](https://sh4zam.com/api/quat/shz_quat_conjugate/) | Returns the conjugate of the given quaternion. | | [`shz_quat_inv`](https://sh4zam.com/api/quat/shz_quat_inv/) | Returns the inverse of the given quaternion. | | [`shz_quat_neg`](https://sh4zam.com/api/quat/shz_quat_neg/) | Returns the negation of the given quaternion. | ## Arithmetic Routines performing calculations with quaternions. | Symbol | Description | | --- | --- | | [`shz_quat_add`](https://sh4zam.com/api/quat/shz_quat_add/) | Returns the quaternion produced from adding each component of the given quaternions. | | [`shz_quat_sub`](https://sh4zam.com/api/quat/shz_quat_sub/) | Returns the quaternion produced from subtracting each component of quaternion `p` from quaterion `q`. | | [`shz_quat_scale`](https://sh4zam.com/api/quat/shz_quat_scale/) | Scales the components of the given quaternion by the given factor. | | [`shz_quat_mult`](https://sh4zam.com/api/quat/shz_quat_mult/) | Multiplies the two quaternions, returning the result as a new quaternion. | | [`shz_quat_div`](https://sh4zam.com/api/quat/shz_quat_div/) | Divides quaternion `p` by quaternion `q` (multiplying by its inverse), returning the resulting quaternion. | | [`shz_quat_dot`](https://sh4zam.com/api/quat/shz_quat_dot/) | Returns the dot product of the two quaternions. | | [`shz_quat_dot2`](https://sh4zam.com/api/quat/shz_quat_dot2/) | Returns the two dot products taken between the `l` quaternion and the `r1` and `r2` quaternions. | | [`shz_quat_dot3`](https://sh4zam.com/api/quat/shz_quat_dot3/) | Returns the two dot products taken between the `l` quaternion and the `r1`, `r2`, and `r3` quaternions. | ## Miscellaneous Other types of quaternion operations. | Symbol | Description | | --- | --- | | [`shz_quat_angle_between`](https://sh4zam.com/api/quat/shz_quat_angle_between/) | Returns the angle in radians between the rotations represented by quaternions `q` and `p`. | | [`shz_quat_rotate_towards`](https://sh4zam.com/api/quat/shz_quat_rotate_towards/) | Rotates quaternion `from` towards quaternion `to` by at most `max_angle` radians. | ## Transformations Routines for applying quaternion transforms. | Symbol | Description | | --- | --- | | [`shz_quat_transform_vec3`](https://sh4zam.com/api/quat/shz_quat_transform_vec3/) | Rotates a vector by the given quaternion. | ## Types | Symbol | Description | | --- | --- | | [`shz_quat_t`](https://sh4zam.com/api/quat/shz_quat_t/) | Represents a 3D quaternion. | | [`shz_quat`](https://sh4zam.com/api/quat/shz_quat/) | Alternate [`shz_quat_t`](https://sh4zam.com/api/quat/shz_quat_t/) C typedef for those who hate POSIX style. | --- # shz_quat_add Source: https://sh4zam.com/api/quat/shz_quat_add/ ```c SHZ_INLINE shz_quat_t shz_quat_add(shz_quat_t q, shz_quat_t p) SHZ_NOEXCEPT; ``` Returns the quaternion produced from adding each component of the given quaternions. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | | `p` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::add`](https://sh4zam.com/api/cpp/quat/#add) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:215`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L215) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Arithmetic" --- # shz_quat_angle_between Source: https://sh4zam.com/api/quat/shz_quat_angle_between/ > Returns the angle in radians between the rotations represented by quaternions q and p ```c SHZ_INLINE float shz_quat_angle_between(shz_quat_t q, shz_quat_t p) SHZ_NOEXCEPT; ``` Returns the angle in radians between the rotations represented by quaternions `q` and `p`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | | `p` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::quat::angle_between`](https://sh4zam.com/api/cpp/quat/#angle_between) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:246`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L246) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Miscellaneous" --- # shz_quat_angle_x Source: https://sh4zam.com/api/quat/shz_quat_angle_x/ ```c SHZ_INLINE float shz_quat_angle_x(shz_quat_t q) SHZ_NOEXCEPT; ``` Returns the angle of rotation the quaternion represents about the X axis in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::quat::angle_x`](https://sh4zam.com/api/cpp/quat/#angle_x) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:159`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L159) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_angle_y Source: https://sh4zam.com/api/quat/shz_quat_angle_y/ ```c SHZ_INLINE float shz_quat_angle_y(shz_quat_t q) SHZ_NOEXCEPT; ``` Returns the angle of rotation the quaternion represents about the Y axis in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::quat::angle_y`](https://sh4zam.com/api/cpp/quat/#angle_y) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:162`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L162) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_angle_z Source: https://sh4zam.com/api/quat/shz_quat_angle_z/ ```c SHZ_INLINE float shz_quat_angle_z(shz_quat_t q) SHZ_NOEXCEPT; ``` Returns the angle of rotation the quaternion represents about the Z axis in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::quat::angle_z`](https://sh4zam.com/api/cpp/quat/#angle_z) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:165`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L165) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_angle Source: https://sh4zam.com/api/quat/shz_quat_angle/ ```c SHZ_INLINE float shz_quat_angle(shz_quat_t q) SHZ_NOEXCEPT; ``` Returns the angle of rotation from the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::quat::angle`](https://sh4zam.com/api/cpp/quat/#angle) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:153`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L153) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_axis Source: https://sh4zam.com/api/quat/shz_quat_axis/ ```c SHZ_INLINE shz_vec3_t shz_quat_axis(shz_quat_t q) SHZ_NOEXCEPT; ``` Returns the axis of rotation from the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::quat::axis`](https://sh4zam.com/api/cpp/quat/#axis) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:156`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L156) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_conjugate Source: https://sh4zam.com/api/quat/shz_quat_conjugate/ ```c SHZ_INLINE shz_quat_t shz_quat_conjugate(shz_quat_t quat) SHZ_NOEXCEPT; ``` Returns the conjugate of the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::conjugated`](https://sh4zam.com/api/cpp/quat/#conjugated) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:199`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L199) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Modifiers" --- # shz_quat_div Source: https://sh4zam.com/api/quat/shz_quat_div/ > Divides quaternion p by quaternion q (multiplying by its inverse), returning the resulting quaternion ```c SHZ_INLINE shz_quat_t shz_quat_div(shz_quat_t q, shz_quat_t p) SHZ_NOEXCEPT; ``` Divides quaternion `p` by quaternion `q` (multiplying by its inverse), returning the resulting quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | | `p` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::div`](https://sh4zam.com/api/cpp/quat/#div) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:227`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L227) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Arithmetic" --- # shz_quat_dot Source: https://sh4zam.com/api/quat/shz_quat_dot/ ```c SHZ_INLINE float shz_quat_dot(shz_quat_t q1, shz_quat_t q2) SHZ_NOEXCEPT; ``` Returns the dot product of the two quaternions. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q1` | `shz_quat_t` | | | `q2` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:230`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L230) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Arithmetic" --- # shz_quat_dot2 Source: https://sh4zam.com/api/quat/shz_quat_dot2/ > Returns the two dot products taken between the l quaternion and the r1 and r2 quaternions ```c SHZ_INLINE shz_vec2_t shz_quat_dot2(shz_quat_t l, shz_quat_t r1, shz_quat_t r2) SHZ_NOEXCEPT; ``` Returns the two dot products taken between the `l` quaternion and the `r1` and `r2` quaternions. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | `shz_quat_t` | | | `r1` | `shz_quat_t` | | | `r2` | `shz_quat_t` | | ## Returns `shz_vec2_t` ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:233`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L233) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Arithmetic" --- # shz_quat_dot3 Source: https://sh4zam.com/api/quat/shz_quat_dot3/ > Returns the two dot products taken between the l quaternion and the r1, r2, and r3 quaternions ```c SHZ_INLINE shz_vec3_t shz_quat_dot3(shz_quat_t l, shz_quat_t r1, shz_quat_t r2, shz_quat_t r3) SHZ_NOEXCEPT; ``` Returns the two dot products taken between the `l` quaternion and the `r1`, `r2`, and `r3` quaternions. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | `shz_quat_t` | | | `r1` | `shz_quat_t` | | | `r2` | `shz_quat_t` | | | `r3` | `shz_quat_t` | | ## Returns `shz_vec3_t` ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:236`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L236) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Arithmetic" --- # shz_quat_equal Source: https://sh4zam.com/api/quat/shz_quat_equal/ ```c SHZ_INLINE bool shz_quat_equal(shz_quat_t a, shz_quat_t b) SHZ_NOEXCEPT; ``` Returns true if the two given quaternions are considered equal based on either absolute or relative tolerance. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_quat_t` | | | `b` | `shz_quat_t` | | ## Returns `bool` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:63`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L63) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_angles_xyz Source: https://sh4zam.com/api/quat/shz_quat_from_angles_xyz/ ```c SHZ_INLINE shz_quat_t shz_quat_from_angles_xyz(float xangle, float yangle, float zangle) SHZ_NOEXCEPT; ``` Initializes and returns a quaternion with the given X-Y-Z rotations in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `xangle` | `float` | | | `yangle` | `float` | | | `zangle` | `float` | | ## Returns `shz_quat_t` ## Details The rotation is applied first around the X-axis, then the Y-, then the Z-axis. ## Notes - These angles are Tait-Bryan angles representing an intrinsic rotation. ## Availability - **C++ equivalent:** [`shz::quat::from_angles_xyz`](https://sh4zam.com/api/cpp/quat/#from_angles_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:73`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L73) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_axis_angle Source: https://sh4zam.com/api/quat/shz_quat_from_axis_angle/ > Initializes and returns a quaternion representing a rotation of angle radians about the given axis ```c SHZ_INLINE shz_quat_t shz_quat_from_axis_angle(shz_vec3_t axis, float angle) SHZ_NOEXCEPT; ``` Initializes and returns a quaternion representing a rotation of `angle` radians about the given `axis`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `axis` | `shz_vec3_t` | | | `angle` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::from_axis_angle`](https://sh4zam.com/api/cpp/quat/#from_axis_angle) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:113`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L113) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_look_axis Source: https://sh4zam.com/api/quat/shz_quat_from_look_axis/ ```c shz_quat_t shz_quat_from_look_axis(shz_vec3_t forward, shz_vec3_t up) SHZ_NOEXCEPT; ``` Creates a quaternion looking in the given direction with the given reference direction. ## Parameters | Name | Type | Description | | --- | --- | --- | | `forward` | `shz_vec3_t` | | | `up` | `shz_vec3_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::from_look_axis`](https://sh4zam.com/api/cpp/quat/#from_look_axis) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:116`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L116) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_rotated_axis Source: https://sh4zam.com/api/quat/shz_quat_from_rotated_axis/ > Returns the quaternion representing the rotation from axis v1 to v2 ```c SHZ_INLINE shz_quat_t shz_quat_from_rotated_axis(shz_vec3_t v1, shz_vec3_t v2) SHZ_NOEXCEPT; ``` Returns the quaternion representing the rotation from axis `v1` to `v2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `v1` | `shz_vec3_t` | | | `v2` | `shz_vec3_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::from_rotated_axis`](https://sh4zam.com/api/cpp/quat/#from_rotated_axis) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:119`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L119) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_rotation_xyz_u16 Source: https://sh4zam.com/api/quat/shz_quat_from_rotation_xyz_u16/ > Equivalent to shz_quat_from_rotation_xyz(), with 16-bit binary angles (65536 per turn, the FSCA unit) ```c SHZ_INLINE shz_quat_t shz_quat_from_rotation_xyz_u16(uint16_t xAngle, uint16_t yAngle, uint16_t zAngle) SHZ_NOEXCEPT; ``` Equivalent to `shz_quat_from_rotation_xyz()`, with 16-bit binary angles (65536 per turn, the FSCA unit). ## Parameters | Name | Type | Description | | --- | --- | --- | | `xAngle` | `uint16_t` | | | `yAngle` | `uint16_t` | | | `zAngle` | `uint16_t` | | ## Returns `shz_quat_t` ## Details For games whose orientations are stored as 16-bit angles, such as N64 titles. Signed 16-bit angles can be passed as they are. The half angles go to FSCA directly, without a conversion to radians, so an odd angle is off by half a unit (1/131072 of a turn) in its half angle. ## Naming and requirements - `u16`: Angle is a 16-bit fixed-point value: 0..65535 maps to 0..2π, the native `FSCA` input format. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::quat::from_rotation_xyz_u16`](https://sh4zam.com/api/cpp/quat/#from_rotation_xyz_u16) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:101`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L101) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" ## See also [`shz_sincosu16`](https://sh4zam.com/api/trig/shz_sincosu16/) --- # shz_quat_from_rotation_xyz Source: https://sh4zam.com/api/quat/shz_quat_from_rotation_xyz/ > Returns the quaternion of the rotation shz_xmtrx_init_rotation_xyz() builds, from angles in radians ```c SHZ_INLINE shz_quat_t shz_quat_from_rotation_xyz(float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT; ``` Returns the quaternion of the rotation `shz_xmtrx_init_rotation_xyz()` builds, from angles in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `xAngle` | `float` | | | `yAngle` | `float` | | | `zAngle` | `float` | | ## Returns `shz_quat_t` ## Details The result equals the product of the axis quaternions in the order of the name, Qx \* Qy \* Qz, so it describes the same orientation as the matrix of the same name. ## Availability - **C++ equivalent:** [`shz::quat::from_rotation_xyz`](https://sh4zam.com/api/cpp/quat/#from_rotation_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:82`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L82) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" ## See also [`shz_quat_from_rotation_xyz_u16`](https://sh4zam.com/api/quat/shz_quat_from_rotation_xyz_u16/), [`shz_xmtrx_init_rotation_xyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_xyz/), [`shz_xmtrx_init_rotation_quat`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_quat/) --- # shz_quat_from_rotation_yxz_u16 Source: https://sh4zam.com/api/quat/shz_quat_from_rotation_yxz_u16/ > Equivalent to shz_quat_from_rotation_yxz(), with 16-bit binary angles ```c SHZ_INLINE shz_quat_t shz_quat_from_rotation_yxz_u16(uint16_t yAngle, uint16_t xAngle, uint16_t zAngle) SHZ_NOEXCEPT; ``` Equivalent to `shz_quat_from_rotation_yxz()`, with 16-bit binary angles. ## Parameters | Name | Type | Description | | --- | --- | --- | | `yAngle` | `uint16_t` | | | `xAngle` | `uint16_t` | | | `zAngle` | `uint16_t` | | ## Returns `shz_quat_t` ## Naming and requirements - `u16`: Angle is a 16-bit fixed-point value: 0..65535 maps to 0..2π, the native `FSCA` input format. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::quat::from_rotation_yxz_u16`](https://sh4zam.com/api/cpp/quat/#from_rotation_yxz_u16) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:110`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L110) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_rotation_yxz Source: https://sh4zam.com/api/quat/shz_quat_from_rotation_yxz/ > Returns the quaternion of the rotation shz_xmtrx_init_rotation_yxz() builds, Qy \ Qx \ Qz, from angles in radians ```c SHZ_INLINE shz_quat_t shz_quat_from_rotation_yxz(float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT; ``` Returns the quaternion of the rotation `shz_xmtrx_init_rotation_yxz()` builds, Qy \* Qx \* Qz, from angles in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `yAngle` | `float` | | | `xAngle` | `float` | | | `zAngle` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::from_rotation_yxz`](https://sh4zam.com/api/cpp/quat/#from_rotation_yxz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:91`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L91) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_rotation_zxy_u16 Source: https://sh4zam.com/api/quat/shz_quat_from_rotation_zxy_u16/ > Equivalent to shz_quat_from_rotation_zxy(), with 16-bit binary angles ```c SHZ_INLINE shz_quat_t shz_quat_from_rotation_zxy_u16(uint16_t zAngle, uint16_t xAngle, uint16_t yAngle) SHZ_NOEXCEPT; ``` Equivalent to `shz_quat_from_rotation_zxy()`, with 16-bit binary angles. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zAngle` | `uint16_t` | | | `xAngle` | `uint16_t` | | | `yAngle` | `uint16_t` | | ## Returns `shz_quat_t` ## Naming and requirements - `u16`: Angle is a 16-bit fixed-point value: 0..65535 maps to 0..2π, the native `FSCA` input format. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::quat::from_rotation_zxy_u16`](https://sh4zam.com/api/cpp/quat/#from_rotation_zxy_u16) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:107`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L107) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_rotation_zxy Source: https://sh4zam.com/api/quat/shz_quat_from_rotation_zxy/ > Returns the quaternion of the rotation shz_xmtrx_init_rotation_zxy() builds, Qz \ Qx \ Qy, from angles in radians ```c SHZ_INLINE shz_quat_t shz_quat_from_rotation_zxy(float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT; ``` Returns the quaternion of the rotation `shz_xmtrx_init_rotation_zxy()` builds, Qz \* Qx \* Qy, from angles in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zAngle` | `float` | | | `xAngle` | `float` | | | `yAngle` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::from_rotation_zxy`](https://sh4zam.com/api/cpp/quat/#from_rotation_zxy) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:88`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L88) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_rotation_zyx_u16 Source: https://sh4zam.com/api/quat/shz_quat_from_rotation_zyx_u16/ > Equivalent to shz_quat_from_rotation_zyx(), with 16-bit binary angles ```c SHZ_INLINE shz_quat_t shz_quat_from_rotation_zyx_u16(uint16_t zAngle, uint16_t yAngle, uint16_t xAngle) SHZ_NOEXCEPT; ``` Equivalent to `shz_quat_from_rotation_zyx()`, with 16-bit binary angles. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zAngle` | `uint16_t` | | | `yAngle` | `uint16_t` | | | `xAngle` | `uint16_t` | | ## Returns `shz_quat_t` ## Naming and requirements - `u16`: Angle is a 16-bit fixed-point value: 0..65535 maps to 0..2π, the native `FSCA` input format. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::quat::from_rotation_zyx_u16`](https://sh4zam.com/api/cpp/quat/#from_rotation_zyx_u16) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:104`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L104) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_from_rotation_zyx Source: https://sh4zam.com/api/quat/shz_quat_from_rotation_zyx/ > Returns the quaternion of the rotation shz_xmtrx_init_rotation_zyx() builds, Qz \ Qy \ Qx, from angles in radians ```c SHZ_INLINE shz_quat_t shz_quat_from_rotation_zyx(float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT; ``` Returns the quaternion of the rotation `shz_xmtrx_init_rotation_zyx()` builds, Qz \* Qy \* Qx, from angles in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zAngle` | `float` | | | `yAngle` | `float` | | | `xAngle` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::from_rotation_zyx`](https://sh4zam.com/api/cpp/quat/#from_rotation_zyx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:85`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L85) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_identity Source: https://sh4zam.com/api/quat/shz_quat_identity/ ```c SHZ_INLINE shz_quat_t shz_quat_identity(void) SHZ_NOEXCEPT; ``` Initializes and returns an identity quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::identity`](https://sh4zam.com/api/cpp/quat/#identity) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:60`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L60) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_init Source: https://sh4zam.com/api/quat/shz_quat_init/ ```c SHZ_INLINE shz_quat_t shz_quat_init(float w, float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes and returns a new quaternion with the given components, in WXYZ order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `w` | `float` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:57`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L57) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_inv Source: https://sh4zam.com/api/quat/shz_quat_inv/ ```c SHZ_INLINE shz_quat_t shz_quat_inv(shz_quat_t quat) SHZ_NOEXCEPT; ``` Returns the inverse of the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::inverse`](https://sh4zam.com/api/cpp/quat/#inverse) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:202`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L202) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Modifiers" --- # shz_quat_lerp Source: https://sh4zam.com/api/quat/shz_quat_lerp/ > Returns the quaternion that is linearly interpolating a to b, by a t factor of 0.0f-1.0f ```c SHZ_INLINE shz_quat_t shz_quat_lerp(shz_quat_t a, shz_quat_t b, float t) SHZ_NOEXCEPT; ``` Returns the quaternion that is linearly interpolating `a` to `b`, by a t factor of `0.0f-1.0f`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_quat_t` | | | `b` | `shz_quat_t` | | | `t` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::lerp`](https://sh4zam.com/api/cpp/quat/#lerp) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:122`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L122) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_magnitude_inv Source: https://sh4zam.com/api/quat/shz_quat_magnitude_inv/ ```c SHZ_INLINE float shz_quat_magnitude_inv(shz_quat_t quat) SHZ_NOEXCEPT; ``` Returns the inverse magnitude of the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::quat::magnitude_inv`](https://sh4zam.com/api/cpp/quat/#magnitude_inv) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:180`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L180) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_magnitude_sqr Source: https://sh4zam.com/api/quat/shz_quat_magnitude_sqr/ ```c SHZ_INLINE float shz_quat_magnitude_sqr(shz_quat_t quat) SHZ_NOEXCEPT; ``` Returns the squared magnitude of the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::quat::magnitude_sqr`](https://sh4zam.com/api/cpp/quat/#magnitude_sqr) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:174`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L174) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_magnitude Source: https://sh4zam.com/api/quat/shz_quat_magnitude/ ```c SHZ_INLINE float shz_quat_magnitude(shz_quat_t quat) SHZ_NOEXCEPT; ``` Returns the magnitude of the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::quat::magnitude`](https://sh4zam.com/api/cpp/quat/#magnitude) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:177`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L177) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_mult Source: https://sh4zam.com/api/quat/shz_quat_mult/ ```c SHZ_INLINE shz_quat_t shz_quat_mult(shz_quat_t q1, shz_quat_t q2) SHZ_NOEXCEPT; ``` Multiplies the two quaternions, returning the result as a new quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q1` | `shz_quat_t` | | | `q2` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::mult`](https://sh4zam.com/api/cpp/quat/#mult) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:224`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L224) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Arithmetic" --- # shz_quat_neg Source: https://sh4zam.com/api/quat/shz_quat_neg/ ```c SHZ_INLINE shz_quat_t shz_quat_neg(shz_quat_t quat) SHZ_NOEXCEPT; ``` Returns the negation of the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::negated`](https://sh4zam.com/api/cpp/quat/#negated) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:205`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L205) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Modifiers" --- # shz_quat_nlerp Source: https://sh4zam.com/api/quat/shz_quat_nlerp/ > Equivalent to shz_quat_lerp(), except that the resulting quaternion is normalized ```c SHZ_INLINE shz_quat_t shz_quat_nlerp(shz_quat_t a, shz_quat_t b, float t) SHZ_NOEXCEPT; ``` Equivalent to `shz_quat_lerp()`, except that the resulting quaternion is normalized. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_quat_t` | | | `b` | `shz_quat_t` | | | `t` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::nlerp`](https://sh4zam.com/api/cpp/quat/#nlerp) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:125`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L125) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_normalize_safe Source: https://sh4zam.com/api/quat/shz_quat_normalize_safe/ ```c SHZ_INLINE shz_quat_t shz_quat_normalize_safe(shz_quat_t quat) SHZ_NOEXCEPT; ``` SAFELY returns the normalized form of the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Details Returns the identity quaternion when magnitude is 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::quat::normalized_safe`](https://sh4zam.com/api/cpp/quat/#normalized_safe) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:196`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L196) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Modifiers" --- # shz_quat_normalize Source: https://sh4zam.com/api/quat/shz_quat_normalize/ ```c SHZ_INLINE shz_quat_t shz_quat_normalize(shz_quat_t quat) SHZ_NOEXCEPT; ``` Returns the normalized form of the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::normalized`](https://sh4zam.com/api/cpp/quat/#normalized) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:190`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L190) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Modifiers" --- # shz_quat_rotate_towards Source: https://sh4zam.com/api/quat/shz_quat_rotate_towards/ > Rotates quaternion from towards quaternion to by at most max_angle radians ```c SHZ_INLINE shz_quat_t shz_quat_rotate_towards(shz_quat_t from, shz_quat_t to, float max_angle) SHZ_NOEXCEPT; ``` Rotates quaternion `from` towards quaternion `to` by at most `max_angle` radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `from` | `shz_quat_t` | | | `to` | `shz_quat_t` | | | `max_angle` | `float` | | ## Returns `shz_quat_t` ## Notes - Returns `to` if the angle between them is already less than `max_angle`. ## Availability - **C++ equivalent:** [`shz::quat::rotate_towards`](https://sh4zam.com/api/cpp/quat/#rotate_towards) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:252`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L252) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Miscellaneous" --- # shz_quat_scale Source: https://sh4zam.com/api/quat/shz_quat_scale/ ```c SHZ_INLINE shz_quat_t shz_quat_scale(shz_quat_t q, float f) SHZ_NOEXCEPT; ``` Scales the components of the given quaternion by the given factor. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | | `f` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::scaled`](https://sh4zam.com/api/cpp/quat/#scaled) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:221`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L221) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Arithmetic" --- # shz_quat_slerp Source: https://sh4zam.com/api/quat/shz_quat_slerp/ > Returns the quaternion that is spherically linearly interpolating a to b, by a t factor of 0.0f-1.0f ```c SHZ_INLINE shz_quat_t shz_quat_slerp(shz_quat_t q, shz_quat_t p, float t) SHZ_NOEXCEPT; ``` Returns the quaternion that is spherically linearly interpolating `a` to `b`, by a `t` factor of `0.0f-1.0f`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | | `p` | `shz_quat_t` | | | `t` | `float` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::slerp`](https://sh4zam.com/api/cpp/quat/#slerp) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:128`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L128) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_squad Source: https://sh4zam.com/api/quat/shz_quat_squad/ > Evaluates a smooth cubic spherical interpolation (SQUAD) at parameter t ```c SHZ_INLINE shz_quat_t shz_quat_squad(shz_quat_t q1, shz_quat_t q2, shz_quat_t s1, shz_quat_t s2, float t) SHZ_NOEXCEPT; ``` Evaluates a smooth cubic spherical interpolation (SQUAD) at parameter `t`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q1` | `shz_quat_t` | Start quaternion. | | `q2` | `shz_quat_t` | End quaternion. | | `s1` | `shz_quat_t` | Inner control point for `q1` (typically computed from surrounding keyframes). | | `s2` | `shz_quat_t` | Inner control point for `q2` (typically computed from surrounding keyframes). | | `t` | `float` | Interpolation factor in \[0, 1\]. | ## Returns Resulting interpolated quaternion ## Notes - SQUAD(q1, q2, s1, s2, t) = slerp(slerp(q1, q2, t), slerp(s1, s2, t), 2t(1-t)) ## Availability - **C++ equivalent:** [`shz::quat::squad`](https://sh4zam.com/api/cpp/quat/#squad) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:143`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L143) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Initialization" --- # shz_quat_sub Source: https://sh4zam.com/api/quat/shz_quat_sub/ > Returns the quaternion produced from subtracting each component of quaternion p from quaterion q ```c SHZ_INLINE shz_quat_t shz_quat_sub(shz_quat_t q, shz_quat_t p) SHZ_NOEXCEPT; ``` Returns the quaternion produced from subtracting each component of quaternion `p` from quaterion `q`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | | `p` | `shz_quat_t` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::quat::sub`](https://sh4zam.com/api/cpp/quat/#sub) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:218`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L218) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Arithmetic" --- # shz_quat_t Source: https://sh4zam.com/api/quat/shz_quat_t/ ```c typedef struct shz_quat { union { //!< Convenience anonymous union between named and array-indexed components. struct { //!< Anonymous structure with named components. float w; //!< W or scalar component/real part of quaternion. union { //!< Convenience anonymous union for vector components. struct { float x; //!< X component of axis of rotation (imaginary) float y; //!< Y component of axis of rotation (imaginary) float z; //!< Z component of axis of rotation (imaginary) }; shz_vec3_t axis; //!< 3D vector representing axis of rotation }; }; float e[4]; //!< Array-indexed components. }; } shz_quat_t; ``` Represents a 3D quaternion. ## Fields | Field | Type | Description | | --- | --- | --- | | `e` | `float[4]` | Array-indexed components. | | `w` | `float` | \< Anonymous structure with named components. | | `axis` | `shz_vec3_t` | 3D vector representing axis of rotation | | `x` | `float` | X component of axis of rotation (imaginary). | | `y` | `float` | Y component of axis of rotation (imaginary). | | `z` | `float` | Z component of axis of rotation (imaginary). | ## Details Quaternions are a mathematical structure representing a rotation about a single arbitrary axis. ## Availability - **C++ equivalent:** [`shz::quat`](https://sh4zam.com/api/cpp/quat/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_quat.h:31`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L31) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Types" --- # shz_quat_to_angles_xyz Source: https://sh4zam.com/api/quat/shz_quat_to_angles_xyz/ ```c SHZ_INLINE shz_vec3_t shz_quat_to_angles_xyz(shz_quat_t q) SHZ_NOEXCEPT; ``` Returns the roll, pitch, and yaw angles of rotation represented by the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::quat::to_angles_xyz`](https://sh4zam.com/api/cpp/quat/#to_angles_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:171`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L171) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_to_axis_angle Source: https://sh4zam.com/api/quat/shz_quat_to_axis_angle/ ```c SHZ_INLINE void shz_quat_to_axis_angle(shz_quat_t q, shz_vec3_t* vec, float* angle) SHZ_NOEXCEPT; ``` Returns both the axis and angle of rotation simultaneously (faster if both are needed) from the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | | `vec` | `shz_vec3_t *` | | | `angle` | `float *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::quat::to_axis_angle`](https://sh4zam.com/api/cpp/quat/#to_axis_angle) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:168`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L168) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Properties" --- # shz_quat_transform_vec3 Source: https://sh4zam.com/api/quat/shz_quat_transform_vec3/ ```c SHZ_INLINE shz_vec3_t shz_quat_transform_vec3(shz_quat_t q, shz_vec3_t v) SHZ_NOEXCEPT; ``` Rotates a vector by the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | | `v` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Notes - This routine is meant for one-off rotations of a single vector by a single quaternion. If you plan to rotate multiple vectors by the same quaternion, you should use the XMTRX API to apply the quaternion as a rotation matrix. ## Availability - **C++ equivalent:** [`shz::quat::transform`](https://sh4zam.com/api/cpp/quat/#transform) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_quat.h:270`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L270) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Transformations" ## See also [`shz_xmtrx_apply_rotation_quat`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_quat/) --- # shz_quat Source: https://sh4zam.com/api/quat/shz_quat/ > Alternate shz_quat_t C typedef for those who hate POSIX style ```c typedef shz_quat_t shz_quat; ``` Alternate [`shz_quat_t`](https://sh4zam.com/api/quat/shz_quat_t/) C typedef for those who hate POSIX style. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_quat.h:49`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_quat.h#L49) - **Module:** [Quaternion](https://sh4zam.com/api/quat/), section "Types" --- # Scalar API Source: https://sh4zam.com/api/scalar/ > Scalar functions and utilities, including faster replacements This API is designed around performing various scalar operations, providing alternatives for routines typically found within ``. Many are drop-in replacements that beat libm on the SH4 by staying in single-precision `float`: no libm call and no promotion to `double`. Unlike the standard C floating-point routines, these routines are often saving cycles by not handling NaN and INF values as well as by not reporting rounding and domain errors back to the user. The `_fsrra` variants use the SH4 `FSRRA` instruction (fast approximate reciprocal square root) and the FIPR helpers run raw dot products through the vector FPU. In C++ every routine is also available as an alias in `namespace shz` with the `shz_` prefix dropped, for example `shz::floorf`. - **C header:** `#include ` - **C++ header:** `#include ` - **Symbols:** 56 ## Suffixes Suffixes used in this module. The full list is in [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. - `_safe`: Guards degenerate input (zero-length vectors, zero denominators) at a small cost. ## Comparisons Routines for comparing and classifying floating-point values. | Symbol | Description | | --- | --- | | [`shz_fminf`](https://sh4zam.com/api/scalar/shz_fminf/) | Returns the minimum value of two given floats. | | [`shz_fmaxf`](https://sh4zam.com/api/scalar/shz_fmaxf/) | Returns the maximum value of two given floats. | | [`shz_equalf`](https://sh4zam.com/api/scalar/shz_equalf/) | Checks for equality based on EITHER the absolute tolerance or relative tolerance, using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). | | [`shz_equalf_abs`](https://sh4zam.com/api/scalar/shz_equalf_abs/) | Checks for equality based on the absolute tolerance using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). | | [`shz_equalf_rel`](https://sh4zam.com/api/scalar/shz_equalf_rel/) | Checks for equality based on the relative tolerance using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). | ## Rounding Routines for rounding and manipulating floats. | Symbol | Description | | --- | --- | | [`shz_floorf`](https://sh4zam.com/api/scalar/shz_floorf/) | Replacement for the \ routine, floorf(). | | [`shz_ceilf`](https://sh4zam.com/api/scalar/shz_ceilf/) | Replacement for the \ routine, ceilf(). | | [`shz_roundf`](https://sh4zam.com/api/scalar/shz_roundf/) | Replacement for the \ routine, roundf(). | | [`shz_truncf`](https://sh4zam.com/api/scalar/shz_truncf/) | Replacement for the \ routine, truncf(). | | [`shz_remainderf`](https://sh4zam.com/api/scalar/shz_remainderf/) | Replacement for the \ routine, remainderf(). | | [`shz_fmodf`](https://sh4zam.com/api/scalar/shz_fmodf/) | Replacement for the \ routine, fmodf(). | | [`shz_remquof`](https://sh4zam.com/api/scalar/shz_remquof/) | (Sorta) Replacement for the \ routine, remquof(). | ## Mapping Routines for mapping a number to another range. | Symbol | Description | | --- | --- | | [`shz_clampf`](https://sh4zam.com/api/scalar/shz_clampf/) | Clamps a floating-point value by the given `min` and `max` values. | | [`shz_normalizef`](https://sh4zam.com/api/scalar/shz_normalizef/) | Maps a value within the given range `from` to `to`, to be within the range of `0.0f += 1.0f`. | | [`shz_normalizef_fsrra`](https://sh4zam.com/api/scalar/shz_normalizef_fsrra/) | Maps a value within the given range `from` to `to`, to be within the range of `0.0f + 1.0f` more quickly, provided `to` - `from` is a positive difference. | | [`shz_remapf`](https://sh4zam.com/api/scalar/shz_remapf/) | Maps a value within the given range `inputStart` to `inputEnd`, to be within the range of `outputStart` to `outputEnd`. | | [`shz_remapf_fsrra`](https://sh4zam.com/api/scalar/shz_remapf_fsrra/) | Maps a value within the given range `inputStart` to `inputEnd`, to be within the range of `outputStart` to `outputEnd` more quickly, provided the `outputEnd` - `outputStart` is a positive difference. | | [`shz_wrapf`](https://sh4zam.com/api/scalar/shz_wrapf/) | Wraps the given `value` back to be within the range of `min` to `max`. | | [`shz_wrapf_fsrra`](https://sh4zam.com/api/scalar/shz_wrapf_fsrra/) | Wraps the given `value` back to be within the range of `min` to `max` more quickly, provided `max` - `min` is a positive difference. | | [`shz_fractf`](https://sh4zam.com/api/scalar/shz_fractf/) | Returns the fractional part of `x`, equivalent to GLSL `fract()`. | | [`shz_signf`](https://sh4zam.com/api/scalar/shz_signf/) | Returns -1.0f if `x` \< 0, 0.0f if `x` == 0, or 1.0f if `x` > 0. | | [`shz_saturatef`](https://sh4zam.com/api/scalar/shz_saturatef/) | Clamps `x` to the range \[0.0f, 1.0f\]. | ## Miscellaneous Assorted routines implementing other fp operations. | Symbol | Description | | --- | --- | | [`shz_fabsf`](https://sh4zam.com/api/scalar/shz_fabsf/) | Replacement for the \ routine, fabsf(). | | [`shz_copysignf`](https://sh4zam.com/api/scalar/shz_copysignf/) | Replacement for the \ routine, copysignf(). | | [`shz_fmaf`](https://sh4zam.com/api/scalar/shz_fmaf/) | Replacement for the \ routine, fmaf(). | | [`shz_fdimf`](https://sh4zam.com/api/scalar/shz_fdimf/) | Replacement for the \ routine, fdimf(),. | | [`shz_hypotf`](https://sh4zam.com/api/scalar/shz_hypotf/) | Replacement for the \ routine, hypotf(). | | [`shz_cbrtf`](https://sh4zam.com/api/scalar/shz_cbrtf/) | Replacement for the \ routine, cbrtf(). | | [`shz_lerpf`](https://sh4zam.com/api/scalar/shz_lerpf/) | Returns a value that is linearly interpolated between `a` and `b` by the given ratio, `t`. | | [`shz_barycentric_lerpf`](https://sh4zam.com/api/scalar/shz_barycentric_lerpf/) | Returns a value that is barycentrically interpolated between `a`, `b`, and `c` using the given barycentric coordinates, `u` and `v`. | | [`shz_quadratic_roots`](https://sh4zam.com/api/scalar/shz_quadratic_roots/) | Uses the quadratic formula with the given coefficients to solve for the two roots, returning `true` if any real roots exist, and `false` if the roots are only imaginary. | | [`shz_randf`](https://sh4zam.com/api/scalar/shz_randf/) | Returns a random floating-point number between `0.0f` and `1.0f`, using and updating the given seed. | | [`shz_randf_range`](https://sh4zam.com/api/scalar/shz_randf_range/) | Returns a random floating-point number between `min` and `max`, using and updating the given seed. | | [`shz_stepf`](https://sh4zam.com/api/scalar/shz_stepf/) | returns 0.0f if x \< edge, otherwise 1.0f | | [`shz_smoothstepf`](https://sh4zam.com/api/scalar/shz_smoothstepf/) | Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. edge0 must be less than edge1 or result is undefined. | | [`shz_smoothstepf_safe`](https://sh4zam.com/api/scalar/shz_smoothstepf_safe/) | Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. | ## FSRRA Routines built around fast reciprocal square root instruction. | Symbol | Description | | --- | --- | | [`shz_inv_sqrtf_fsrra`](https://sh4zam.com/api/scalar/shz_inv_sqrtf_fsrra/) | Calculates 1.0f/sqrtf( `x`), using a fast approximation. | | [`shz_inv_sqrtf`](https://sh4zam.com/api/scalar/shz_inv_sqrtf/) | Calculates 1.0f/sqrtf( `x` ), using a fast approximation, while safely protecting against division-by-zero. | | [`shz_sqrtf_fsrra`](https://sh4zam.com/api/scalar/shz_sqrtf_fsrra/) | Returns the fast approximate square root of the given value, `x`. | | [`shz_sqrtf`](https://sh4zam.com/api/scalar/shz_sqrtf/) | Returns the fast approximate square root of the given value, `x`, safely returning `0.0f` is `x` == `0.0f`. | | [`shz_invf_fsrra`](https://sh4zam.com/api/scalar/shz_invf_fsrra/) | Takes the inverse of `x` using a very fast approximation, returning a positive result. | | [`shz_invf`](https://sh4zam.com/api/scalar/shz_invf/) | Takes the inverse of `x` using a slighty faster approximation than doing a full division, safely handling negative values. | | [`shz_divf_fsrra`](https://sh4zam.com/api/scalar/shz_divf_fsrra/) | Divides `num` by `denom` using a very fast approximation, which requires `denom` be a positive value. | | [`shz_divf`](https://sh4zam.com/api/scalar/shz_divf/) | Divides `num` by `denom` using a slightly faster approximation, allowing `denom` to be negative. | ## FIPR Routines built around fast 4D dot product. | Symbol | Description | | --- | --- | | [`shz_dot6f`](https://sh4zam.com/api/scalar/shz_dot6f/) | Takes two sets of 3D vectors as 3 floats and calculates their dot product using an approximation. | | [`shz_dot8f`](https://sh4zam.com/api/scalar/shz_dot8f/) | Takes two sets of 4D vectors as 4 floats and calculates their dot product using an approximation. | | [`shz_mag_sqr3f`](https://sh4zam.com/api/scalar/shz_mag_sqr3f/) | Takes a 3D vector as 3 floats and calculates its squared magnitude using a fast approximation. | | [`shz_mag_sqr4f`](https://sh4zam.com/api/scalar/shz_mag_sqr4f/) | Takes a 4D vector as 4 floats and calculates its squared magnitude using a fast approximation. | ## Transcendental Fast approximations for non-trig transcendental functions. | Symbol | Description | | --- | --- | | [`shz_pow2f`](https://sh4zam.com/api/scalar/shz_pow2f/) | Fast approximation for raising 2 to a floating-point power. | | [`shz_powf`](https://sh4zam.com/api/scalar/shz_powf/) | Fast approximation for C's powf(). | | [`shz_pow10f`](https://sh4zam.com/api/scalar/shz_pow10f/) | Fast approximation of POSIX's pow10f(). | | [`shz_log2f`](https://sh4zam.com/api/scalar/shz_log2f/) | Fast approximation for C's log2f(). | | [`shz_logf`](https://sh4zam.com/api/scalar/shz_logf/) | Fast approximation for C's logf(). | | [`shz_log10f`](https://sh4zam.com/api/scalar/shz_log10f/) | Fast approximation for C's log10f(). | | [`shz_expf`](https://sh4zam.com/api/scalar/shz_expf/) | Fast approximation for C's expf(). | ## Macros | Symbol | Description | | --- | --- | | [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/) | Floating-point epsilon used with inexact FP-based comparisons. | --- # shz_barycentric_lerpf Source: https://sh4zam.com/api/scalar/shz_barycentric_lerpf/ > Returns a value that is barycentrically interpolated between a, b, and c using the given barycentric coordinates, u and v ```c SHZ_INLINE float shz_barycentric_lerpf(float a, float b, float c, float u, float v) SHZ_NOEXCEPT; ``` Returns a value that is barycentrically interpolated between `a`, `b`, and `c` using the given barycentric coordinates, `u` and `v`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | | `c` | `float` | | | `u` | `float` | | | `v` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::barycentric_lerpf`](https://sh4zam.com/api/cpp/#shzbarycentric_lerpf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:249`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L249) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_cbrtf Source: https://sh4zam.com/api/scalar/shz_cbrtf/ > Replacement for the routine, cbrtf() ```c SHZ_INLINE float shz_cbrtf(float x) SHZ_NOEXCEPT; ``` Replacement for the \ routine, cbrtf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Details Returns the cubed root of `x`, using a fast approximation. ## Availability - **C++ equivalent:** [`shz::cbrtf`](https://sh4zam.com/api/cpp/#shzcbrtf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:243`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L243) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_ceilf Source: https://sh4zam.com/api/scalar/shz_ceilf/ > Replacement for the routine, ceilf() ```c SHZ_INLINE float shz_ceilf(float x) SHZ_NOEXCEPT; ``` Replacement for the \ routine, ceilf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Details Returns the closest integral value to `x`, rounded up, as a float. ## Warnings - This routine only returns valid values for the input range INT32_MIN \<= `x` \<= INT32_MAX. ## Availability - **C++ equivalent:** [`shz::ceilf`](https://sh4zam.com/api/cpp/#shzceilf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:92`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L92) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Rounding" --- # shz_clampf Source: https://sh4zam.com/api/scalar/shz_clampf/ > Clamps a floating-point value by the given min and max values ```c SHZ_INLINE float shz_clampf(float value, float min, float max) SHZ_NOEXCEPT; ``` Clamps a floating-point value by the given `min` and `max` values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | `float` | | | `min` | `float` | | | `max` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::clampf`](https://sh4zam.com/api/cpp/#shzclampf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:164`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L164) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_copysignf Source: https://sh4zam.com/api/scalar/shz_copysignf/ > Replacement for the routine, copysignf() ```c SHZ_INLINE float shz_copysignf(float x, float y) SHZ_NOEXCEPT; ``` Replacement for the \ routine, copysignf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | ## Returns `float` ## Details Returns the value of `x` with the sign of `y`. ## Warnings - When `y == -0.0f`, a positive value is returned. ## Availability - **C++ equivalent:** [`shz::copysignf`](https://sh4zam.com/api/cpp/#shzcopysignf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:212`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L212) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_divf_fsrra Source: https://sh4zam.com/api/scalar/shz_divf_fsrra/ > Divides num by denom using a very fast approximation, which requires denom be a positive value ```c SHZ_INLINE float shz_divf_fsrra(float num, float denom) SHZ_NOEXCEPT; ``` Divides `num` by `denom` using a very fast approximation, which requires `denom` be a positive value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `num` | `float` | | | `denom` | `float` | | ## Returns `float` ## Naming and requirements - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::divf_fsrra`](https://sh4zam.com/api/cpp/#shzdivf_fsrra) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:295`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L295) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FSRRA" --- # shz_divf Source: https://sh4zam.com/api/scalar/shz_divf/ > Divides num by denom using a slightly faster approximation, allowing denom to be negative ```c SHZ_INLINE float shz_divf(float num, float denom) SHZ_NOEXCEPT; ``` Divides `num` by `denom` using a slightly faster approximation, allowing `denom` to be negative. ## Parameters | Name | Type | Description | | --- | --- | --- | | `num` | `float` | | | `denom` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::divf`](https://sh4zam.com/api/cpp/#shzdivf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:298`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L298) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FSRRA" --- # shz_dot6f Source: https://sh4zam.com/api/scalar/shz_dot6f/ ```c SHZ_INLINE float shz_dot6f(float x1, float y1, float z1, float x2, float y2, float z2) SHZ_NOEXCEPT; ``` Takes two sets of 3D vectors as 3 floats and calculates their dot product using an approximation. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x1` | `float` | | | `y1` | `float` | | | `z1` | `float` | | | `x2` | `float` | | | `y2` | `float` | | | `z2` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::dot6f`](https://sh4zam.com/api/cpp/#shzdot6f) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:309`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L309) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FIPR" --- # shz_dot8f Source: https://sh4zam.com/api/scalar/shz_dot8f/ ```c SHZ_INLINE float shz_dot8f(float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2) SHZ_NOEXCEPT; ``` Takes two sets of 4D vectors as 4 floats and calculates their dot product using an approximation. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x1` | `float` | | | `y1` | `float` | | | `z1` | `float` | | | `w1` | `float` | | | `x2` | `float` | | | `y2` | `float` | | | `z2` | `float` | | | `w2` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::dot8f`](https://sh4zam.com/api/cpp/#shzdot8f) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:313`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L313) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FIPR" --- # shz_equalf_abs Source: https://sh4zam.com/api/scalar/shz_equalf_abs/ > Checks for equality based on the absolute tolerance using SHZ_FLT_EPSILON ```c SHZ_INLINE bool shz_equalf_abs(float a, float b) SHZ_NOEXCEPT; ``` Checks for equality based on the absolute tolerance using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | ## Returns `bool` ## Availability - **C++ equivalent:** [`shz::equalf_abs`](https://sh4zam.com/api/cpp/#shzequalf_abs) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:59`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L59) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Comparisons" --- # shz_equalf_rel Source: https://sh4zam.com/api/scalar/shz_equalf_rel/ > Checks for equality based on the relative tolerance using SHZ_FLT_EPSILON ```c SHZ_INLINE bool shz_equalf_rel(float a, float b) SHZ_NOEXCEPT; ``` Checks for equality based on the relative tolerance using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | ## Returns `bool` ## Availability - **C++ equivalent:** [`shz::equalf_rel`](https://sh4zam.com/api/cpp/#shzequalf_rel) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:62`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L62) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Comparisons" --- # shz_equalf Source: https://sh4zam.com/api/scalar/shz_equalf/ > Checks for equality based on EITHER the absolute tolerance or relative tolerance, using SHZ_FLT_EPSILON ```c SHZ_INLINE bool shz_equalf(float a, float b) SHZ_NOEXCEPT; ``` Checks for equality based on EITHER the absolute tolerance or relative tolerance, using [`SHZ_FLT_EPSILON`](https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/). ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | ## Returns `bool` ## Availability - **C++ equivalent:** [`shz::equalf`](https://sh4zam.com/api/cpp/#shzequalf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:56`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L56) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Comparisons" --- # shz_expf Source: https://sh4zam.com/api/scalar/shz_expf/ ```c SHZ_INLINE float shz_expf(float p) SHZ_NOEXCEPT; ``` Fast approximation for C's expf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `p` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::expf`](https://sh4zam.com/api/cpp/#shzexpf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:348`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L348) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Transcendental" --- # shz_fabsf Source: https://sh4zam.com/api/scalar/shz_fabsf/ > Replacement for the routine, fabsf() ```c SHZ_INLINE float shz_fabsf(float x) SHZ_NOEXCEPT; ``` Replacement for the \ routine, fabsf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Details Returns the absolute value of `x`. ## Availability - **C++ equivalent:** [`shz::fabsf`](https://sh4zam.com/api/cpp/#shzfabsf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:204`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L204) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_fdimf Source: https://sh4zam.com/api/scalar/shz_fdimf/ > Replacement for the routine, fdimf(), ```c SHZ_INLINE float shz_fdimf(float x, float y) SHZ_NOEXCEPT; ``` Replacement for the \ routine, fdimf(),. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | ## Returns `float` ## Details Returns the positive difference between `x` and `y` or zero if y >= x. ## Warnings - Unlike fdimf(), this routine does not handle INF and NAN values. ## Availability - **C++ equivalent:** [`shz::fdimf`](https://sh4zam.com/api/cpp/#shzfdimf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:228`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L228) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_floorf Source: https://sh4zam.com/api/scalar/shz_floorf/ > Replacement for the routine, floorf() ```c SHZ_INLINE float shz_floorf(float x) SHZ_NOEXCEPT; ``` Replacement for the \ routine, floorf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Details Returns the closest integral value to `x`, rounded down, as a float. ## Warnings - This routine is only valid for for the range INT32_MIN \<= `x` \<= INT32_MAX. ## Availability - **C++ equivalent:** [`shz::floorf`](https://sh4zam.com/api/cpp/#shzfloorf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:80`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L80) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Rounding" --- # SHZ_FLT_EPSILON Source: https://sh4zam.com/api/scalar/SHZ_FLT_EPSILON/ ```c #define SHZ_FLT_EPSILON 0.01f ``` Floating-point epsilon used with inexact FP-based comparisons. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_scalar.h:40`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L40) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Macros" --- # shz_fmaf Source: https://sh4zam.com/api/scalar/shz_fmaf/ > Replacement for the routine, fmaf() ```c SHZ_INLINE float shz_fmaf(float a, float b, float c) SHZ_NOEXCEPT; ``` Replacement for the \ routine, fmaf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | | `c` | `float` | | ## Returns `float` ## Details Returns `a` \* `b` + `c`, performing an FP multiply + accumulate operation. ## Availability - **C++ equivalent:** [`shz::fmaf`](https://sh4zam.com/api/cpp/#shzfmaf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:218`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L218) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_fmaxf Source: https://sh4zam.com/api/scalar/shz_fmaxf/ ```c SHZ_INLINE float shz_fmaxf(float a, float b) SHZ_NOEXCEPT; ``` Returns the maximum value of two given floats. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::fmaxf`](https://sh4zam.com/api/cpp/#shzfmaxf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:53`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L53) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Comparisons" --- # shz_fminf Source: https://sh4zam.com/api/scalar/shz_fminf/ ```c SHZ_INLINE float shz_fminf(float a, float b) SHZ_NOEXCEPT; ``` Returns the minimum value of two given floats. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::fminf`](https://sh4zam.com/api/cpp/#shzfminf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:50`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L50) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Comparisons" --- # shz_fmodf Source: https://sh4zam.com/api/scalar/shz_fmodf/ > Replacement for the routine, fmodf() ```c SHZ_INLINE float shz_fmodf(float num, float denom) SHZ_NOEXCEPT; ``` Replacement for the \ routine, fmodf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `num` | `float` | | | `denom` | `float` | | ## Returns `float` ## Details Returns the floating-point remainder of `num` divided by `denom`, rounded towards zero. ## Warnings - This routine does not gracefully handle dividing by zero. ## Availability - **C++ equivalent:** [`shz::fmodf`](https://sh4zam.com/api/cpp/#shzfmodf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:137`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L137) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Rounding" ## See also [`shz_remainderf`](https://sh4zam.com/api/scalar/shz_remainderf/) --- # shz_fractf Source: https://sh4zam.com/api/scalar/shz_fractf/ > Returns the fractional part of x, equivalent to GLSL fract() ```c SHZ_INLINE float shz_fractf(float x) SHZ_NOEXCEPT; ``` Returns the fractional part of `x`, equivalent to GLSL `fract()`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::fractf`](https://sh4zam.com/api/cpp/#shzfractf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:185`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L185) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_hypotf Source: https://sh4zam.com/api/scalar/shz_hypotf/ > Replacement for the routine, hypotf() ```c SHZ_INLINE float shz_hypotf(float x, float y) SHZ_NOEXCEPT; ``` Replacement for the \ routine, hypotf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | ## Returns `float` ## Details Returns the hypoteneuse of the right triangle with the given legs. ## Warnings - Unlike hypotf(), this routine has no error or overflow handling. ## Availability - **C++ equivalent:** [`shz::hypotf`](https://sh4zam.com/api/cpp/#shzhypotf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:237`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L237) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_inv_sqrtf_fsrra Source: https://sh4zam.com/api/scalar/shz_inv_sqrtf_fsrra/ > Calculates 1.0f/sqrtf( x), using a fast approximation ```c SHZ_INLINE float shz_inv_sqrtf_fsrra(float x) SHZ_NOEXCEPT; ``` Calculates 1.0f/sqrtf( `x`), using a fast approximation. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Naming and requirements - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::inv_sqrtf_fsrra`](https://sh4zam.com/api/cpp/#shzinv_sqrtf_fsrra) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:277`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L277) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FSRRA" --- # shz_inv_sqrtf Source: https://sh4zam.com/api/scalar/shz_inv_sqrtf/ > Calculates 1.0f/sqrtf( x ), using a fast approximation, while safely protecting against division-by-zero ```c SHZ_INLINE float shz_inv_sqrtf(float x) SHZ_NOEXCEPT; ``` Calculates 1.0f/sqrtf( `x` ), using a fast approximation, while safely protecting against division-by-zero. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::inv_sqrtf`](https://sh4zam.com/api/cpp/#shzinv_sqrtf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:280`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L280) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FSRRA" --- # shz_invf_fsrra Source: https://sh4zam.com/api/scalar/shz_invf_fsrra/ > Takes the inverse of x using a very fast approximation, returning a positive result ```c SHZ_INLINE float shz_invf_fsrra(float x) SHZ_NOEXCEPT; ``` Takes the inverse of `x` using a very fast approximation, returning a positive result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Naming and requirements - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::invf_fsrra`](https://sh4zam.com/api/cpp/#shzinvf_fsrra) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:289`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L289) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FSRRA" --- # shz_invf Source: https://sh4zam.com/api/scalar/shz_invf/ > Takes the inverse of x using a slighty faster approximation than doing a full division, safely handling negative values ```c SHZ_INLINE float shz_invf(float x) SHZ_NOEXCEPT; ``` Takes the inverse of `x` using a slighty faster approximation than doing a full division, safely handling negative values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::invf`](https://sh4zam.com/api/cpp/#shzinvf), [`shz::operator/`](https://sh4zam.com/api/cpp/#shzoperator/), [`shz::quat::operator/=`](https://sh4zam.com/api/cpp/quat/) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:292`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L292) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FSRRA" --- # shz_lerpf Source: https://sh4zam.com/api/scalar/shz_lerpf/ > Returns a value that is linearly interpolated between a and b by the given ratio, t ```c SHZ_INLINE float shz_lerpf(float a, float b, float t) SHZ_NOEXCEPT; ``` Returns a value that is linearly interpolated between `a` and `b` by the given ratio, `t`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | | `t` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::lerpf`](https://sh4zam.com/api/cpp/#shzlerpf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:246`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L246) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_log2f Source: https://sh4zam.com/api/scalar/shz_log2f/ ```c SHZ_INLINE float shz_log2f(float x) SHZ_NOEXCEPT; ``` Fast approximation for C's log2f(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::log2f`](https://sh4zam.com/api/cpp/#shzlog2f) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:339`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L339) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Transcendental" --- # shz_log10f Source: https://sh4zam.com/api/scalar/shz_log10f/ ```c SHZ_INLINE float shz_log10f(float x) SHZ_NOEXCEPT; ``` Fast approximation for C's log10f(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::log10f`](https://sh4zam.com/api/cpp/#shzlog10f) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:345`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L345) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Transcendental" --- # shz_logf Source: https://sh4zam.com/api/scalar/shz_logf/ ```c SHZ_INLINE float shz_logf(float x) SHZ_NOEXCEPT; ``` Fast approximation for C's logf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::logf`](https://sh4zam.com/api/cpp/#shzlogf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:342`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L342) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Transcendental" --- # shz_mag_sqr3f Source: https://sh4zam.com/api/scalar/shz_mag_sqr3f/ ```c SHZ_INLINE float shz_mag_sqr3f(float x, float y, float z) SHZ_NOEXCEPT; ``` Takes a 3D vector as 3 floats and calculates its squared magnitude using a fast approximation. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::mag_sqr3f`](https://sh4zam.com/api/cpp/#shzmag_sqr3f) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:317`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L317) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FIPR" --- # shz_mag_sqr4f Source: https://sh4zam.com/api/scalar/shz_mag_sqr4f/ ```c SHZ_INLINE float shz_mag_sqr4f(float x, float y, float z, float w) SHZ_NOEXCEPT; ``` Takes a 4D vector as 4 floats and calculates its squared magnitude using a fast approximation. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | | `w` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::mag_sqr4f`](https://sh4zam.com/api/cpp/#shzmag_sqr4f) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:320`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L320) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FIPR" --- # shz_normalizef_fsrra Source: https://sh4zam.com/api/scalar/shz_normalizef_fsrra/ > Maps a value within the given range from to to, to be within the range of 0.0f + 1.0f more quickly, provided to - from is a positive difference ```c SHZ_INLINE float shz_normalizef_fsrra(float current, float from, float to) SHZ_NOEXCEPT; ``` Maps a value within the given range `from` to `to`, to be within the range of `0.0f + 1.0f` more quickly, provided `to` - `from` is a positive difference. ## Parameters | Name | Type | Description | | --- | --- | --- | | `current` | `float` | | | `from` | `float` | | | `to` | `float` | | ## Returns `float` ## Naming and requirements - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::normalizef_fsrra`](https://sh4zam.com/api/cpp/#shznormalizef_fsrra) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:170`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L170) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_normalizef Source: https://sh4zam.com/api/scalar/shz_normalizef/ > Maps a value within the given range from to to, to be within the range of 0.0f += 1.0f ```c SHZ_INLINE float shz_normalizef(float current, float from, float to) SHZ_NOEXCEPT; ``` Maps a value within the given range `from` to `to`, to be within the range of `0.0f += 1.0f`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `current` | `float` | | | `from` | `float` | | | `to` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::normalizef`](https://sh4zam.com/api/cpp/#shznormalizef) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:167`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L167) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_pow2f Source: https://sh4zam.com/api/scalar/shz_pow2f/ ```c SHZ_INLINE float shz_pow2f(float p) SHZ_NOEXCEPT; ``` Fast approximation for raising 2 to a floating-point power. ## Parameters | Name | Type | Description | | --- | --- | --- | | `p` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::pow2f`](https://sh4zam.com/api/cpp/#shzpow2f) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:330`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L330) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Transcendental" --- # shz_pow10f Source: https://sh4zam.com/api/scalar/shz_pow10f/ ```c SHZ_INLINE float shz_pow10f(float x) SHZ_NOEXCEPT; ``` Fast approximation of POSIX's pow10f(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::pow10f`](https://sh4zam.com/api/cpp/#shzpow10f) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:336`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L336) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Transcendental" --- # shz_powf Source: https://sh4zam.com/api/scalar/shz_powf/ ```c SHZ_INLINE float shz_powf(float x, float p) SHZ_NOEXCEPT; ``` Fast approximation for C's powf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `p` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::powf`](https://sh4zam.com/api/cpp/#shzpowf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:333`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L333) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Transcendental" --- # shz_quadratic_roots Source: https://sh4zam.com/api/scalar/shz_quadratic_roots/ > Uses the quadratic formula with the given coefficients to solve for the two roots, returning true if any real roots exist, and false if the roots are only.. ```c SHZ_INLINE bool shz_quadratic_roots(float a, float b, float c, float* root1, float* root2) SHZ_NOEXCEPT; ``` Uses the quadratic formula with the given coefficients to solve for the two roots, returning `true` if any real roots exist, and `false` if the roots are only imaginary. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `float` | | | `b` | `float` | | | `c` | `float` | | | `root1` | `float *` | | | `root2` | `float *` | | ## Returns `bool` ## Availability - **C++ equivalent:** [`shz::quadratic_roots`](https://sh4zam.com/api/cpp/#shzquadratic_roots) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:252`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L252) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_randf_range Source: https://sh4zam.com/api/scalar/shz_randf_range/ > Returns a random floating-point number between min and max, using and updating the given seed ```c SHZ_INLINE float shz_randf_range(int* seed, float min, float max) SHZ_NOEXCEPT; ``` Returns a random floating-point number between `min` and `max`, using and updating the given seed. ## Parameters | Name | Type | Description | | --- | --- | --- | | `seed` | `int *` | | | `min` | `float` | | | `max` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::randf_range`](https://sh4zam.com/api/cpp/#shzrandf_range) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:258`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L258) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_randf Source: https://sh4zam.com/api/scalar/shz_randf/ > Returns a random floating-point number between 0.0f and 1.0f, using and updating the given seed ```c SHZ_INLINE float shz_randf(int* seed) SHZ_NOEXCEPT; ``` Returns a random floating-point number between `0.0f` and `1.0f`, using and updating the given seed. ## Parameters | Name | Type | Description | | --- | --- | --- | | `seed` | `int *` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::randf`](https://sh4zam.com/api/cpp/#shzrandf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:255`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L255) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_remainderf Source: https://sh4zam.com/api/scalar/shz_remainderf/ > Replacement for the routine, remainderf() ```c SHZ_INLINE float shz_remainderf(float num, float denom) SHZ_NOEXCEPT; ``` Replacement for the \ routine, remainderf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `num` | `float` | | | `denom` | `float` | | ## Returns `float` ## Details Returns the floating-point remainder of `num` divided by `denom`, rounded to the nearest integer (as a float). ## Warnings - This routine does not gracefully handle dividing by zero, and it is only valid for the input range INT32_MIN \<= `num` / `denom` \<= INT32_MAX. ## Availability - **C++ equivalent:** [`shz::remainderf`](https://sh4zam.com/api/cpp/#shzremainderf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:125`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L125) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Rounding" ## See also [`shz_fmodf`](https://sh4zam.com/api/scalar/shz_fmodf/), [`shz_remquof`](https://sh4zam.com/api/scalar/shz_remquof/), [`shz_truncf`](https://sh4zam.com/api/scalar/shz_truncf/) --- # shz_remapf_fsrra Source: https://sh4zam.com/api/scalar/shz_remapf_fsrra/ > Maps a value within the given range inputStart to inputEnd, to be within the range of outputStart to outputEnd more quickly, provided the outputEnd -.. ```c SHZ_INLINE float shz_remapf_fsrra(float value, float inputStart, float inputEnd, float outputStart, float outputEnd) SHZ_NOEXCEPT; ``` Maps a value within the given range `inputStart` to `inputEnd`, to be within the range of `outputStart` to `outputEnd` more quickly, provided the `outputEnd` - `outputStart` is a positive difference. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | `float` | | | `inputStart` | `float` | | | `inputEnd` | `float` | | | `outputStart` | `float` | | | `outputEnd` | `float` | | ## Returns `float` ## Naming and requirements - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::remapf_fsrra`](https://sh4zam.com/api/cpp/#shzremapf_fsrra) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:176`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L176) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_remapf Source: https://sh4zam.com/api/scalar/shz_remapf/ > Maps a value within the given range inputStart to inputEnd, to be within the range of outputStart to outputEnd ```c SHZ_INLINE float shz_remapf(float value, float inputStart, float inputEnd, float outputStart, float outputEnd) SHZ_NOEXCEPT; ``` Maps a value within the given range `inputStart` to `inputEnd`, to be within the range of `outputStart` to `outputEnd`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | `float` | | | `inputStart` | `float` | | | `inputEnd` | `float` | | | `outputStart` | `float` | | | `outputEnd` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::remapf`](https://sh4zam.com/api/cpp/#shzremapf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:173`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L173) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_remquof Source: https://sh4zam.com/api/scalar/shz_remquof/ > (Sorta) Replacement for the routine, remquof() ```c SHZ_INLINE float shz_remquof(float num, float denom, float* quot) SHZ_NOEXCEPT; ``` (Sorta) Replacement for the \ routine, remquof(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `num` | `float` | | | `denom` | `float` | | | `quot` | `float *` | | ## Returns `float` ## Details Returns the floating-point remainder of `num` divided by `denom`, rounded to the nearest integer (as a float). `quot` is set equal to the quotient which is used as part of the calculation. ## Notes - `quot` is returning as a `float` rather than an `int` as with standard C. Simply cast to an `int` manually afterwards if that is the desired behavior. ## Warnings - This routine does not gracefully handle dividing by zero. ## Availability - **C++ equivalent:** [`shz::remquof`](https://sh4zam.com/api/cpp/#shzremquof) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:154`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L154) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Rounding" ## See also [`shz_remainderf`](https://sh4zam.com/api/scalar/shz_remainderf/) --- # shz_roundf Source: https://sh4zam.com/api/scalar/shz_roundf/ > Replacement for the routine, roundf() ```c SHZ_INLINE float shz_roundf(float x) SHZ_NOEXCEPT; ``` Replacement for the \ routine, roundf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Details Returns the value of `x` rounded to the nearest integer, as a float. ## Warnings - This routine only returns valid values for the input range -UINT32_MAX \<= `x` \<= UINT32_MAX. ## Availability - **C++ equivalent:** [`shz::roundf`](https://sh4zam.com/api/cpp/#shzroundf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:102`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L102) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Rounding" --- # shz_saturatef Source: https://sh4zam.com/api/scalar/shz_saturatef/ > Clamps x to the range [0.0f, 1.0f] ```c SHZ_INLINE float shz_saturatef(float x) SHZ_NOEXCEPT; ``` Clamps `x` to the range \[0.0f, 1.0f\]. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::saturatef`](https://sh4zam.com/api/cpp/#shzsaturatef) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:191`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L191) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_signf Source: https://sh4zam.com/api/scalar/shz_signf/ > Returns -1.0f if x < 0, 0.0f if x == 0, or 1.0f if x > 0 ```c SHZ_INLINE float shz_signf(float x) SHZ_NOEXCEPT; ``` Returns -1.0f if `x` \< 0, 0.0f if `x` == 0, or 1.0f if `x` > 0. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::signf`](https://sh4zam.com/api/cpp/#shzsignf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:188`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L188) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_smoothstepf_safe Source: https://sh4zam.com/api/scalar/shz_smoothstepf_safe/ ```c SHZ_INLINE float shz_smoothstepf_safe(float x, float edge0, float edge1) SHZ_NOEXCEPT; ``` Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `edge0` | `float` | | | `edge1` | `float` | | ## Returns `float` ## 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::smoothstepf_safe`](https://sh4zam.com/api/cpp/#shzsmoothstepf_safe) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:267`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L267) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_smoothstepf Source: https://sh4zam.com/api/scalar/shz_smoothstepf/ ```c SHZ_INLINE float shz_smoothstepf(float x, float edge0, float edge1) SHZ_NOEXCEPT; ``` Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. edge0 must be less than edge1 or result is undefined. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `edge0` | `float` | | | `edge1` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::smoothstepf`](https://sh4zam.com/api/cpp/#shzsmoothstepf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:264`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L264) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_sqrtf_fsrra Source: https://sh4zam.com/api/scalar/shz_sqrtf_fsrra/ > Returns the fast approximate square root of the given value, x ```c SHZ_INLINE float shz_sqrtf_fsrra(float x) SHZ_NOEXCEPT; ``` Returns the fast approximate square root of the given value, `x`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Naming and requirements - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::sqrtf_fsrra`](https://sh4zam.com/api/cpp/#shzsqrtf_fsrra) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:283`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L283) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FSRRA" --- # shz_sqrtf Source: https://sh4zam.com/api/scalar/shz_sqrtf/ > Returns the fast approximate square root of the given value, x, safely returning 0.0f is x == 0.0f ```c SHZ_INLINE float shz_sqrtf(float x) SHZ_NOEXCEPT; ``` Returns the fast approximate square root of the given value, `x`, safely returning `0.0f` is `x` == `0.0f`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::sqrtf`](https://sh4zam.com/api/cpp/#shzsqrtf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:286`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L286) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "FSRRA" --- # shz_stepf Source: https://sh4zam.com/api/scalar/shz_stepf/ > returns 0.0f if x < edge, otherwise 1.0f ```c SHZ_INLINE float shz_stepf(float x, float edge) SHZ_NOEXCEPT; ``` returns 0.0f if x \< edge, otherwise 1.0f ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `edge` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::stepf`](https://sh4zam.com/api/cpp/#shzstepf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:261`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L261) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Miscellaneous" --- # shz_truncf Source: https://sh4zam.com/api/scalar/shz_truncf/ > Replacement for the routine, truncf() ```c SHZ_INLINE float shz_truncf(float x) SHZ_NOEXCEPT; ``` Replacement for the \ routine, truncf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Details Returns the value of `with` its fractional component discarded. ## Warnings - This routine only returns valid values for the input range INT32_MIN \<= `x` \<= INT32_MAX. ## Availability - **C++ equivalent:** [`shz::truncf`](https://sh4zam.com/api/cpp/#shztruncf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:112`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L112) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Rounding" --- # shz_wrapf_fsrra Source: https://sh4zam.com/api/scalar/shz_wrapf_fsrra/ > Wraps the given value back to be within the range of min to max more quickly, provided max - min is a positive difference ```c SHZ_INLINE float shz_wrapf_fsrra(float value, float min, float max) SHZ_NOEXCEPT; ``` Wraps the given `value` back to be within the range of `min` to `max` more quickly, provided `max` - `min` is a positive difference. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | `float` | | | `min` | `float` | | | `max` | `float` | | ## Returns `float` ## Naming and requirements - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::wrapf_fsrra`](https://sh4zam.com/api/cpp/#shzwrapf_fsrra) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:182`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L182) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # shz_wrapf Source: https://sh4zam.com/api/scalar/shz_wrapf/ > Wraps the given value back to be within the range of min to max ```c SHZ_INLINE float shz_wrapf(float value, float min, float max) SHZ_NOEXCEPT; ``` Wraps the given `value` back to be within the range of `min` to `max`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | `float` | | | `min` | `float` | | | `max` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::wrapf`](https://sh4zam.com/api/cpp/#shzwrapf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_scalar.h:179`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_scalar.h#L179) - **Module:** [Scalar](https://sh4zam.com/api/scalar/), section "Mapping" --- # Trigonometry API Source: https://sh4zam.com/api/trig/ > Trig functions and utilities built around the SH4 FSCA instruction The following API provides a series of routines implementing trigonometric functions. While some of these are specialized, many are meant to be drop-in replacements for the equivalent functions provided by ``. The SH4 provides a single instruction, `FSCA`, for retrieving fast approximations of both the sine and cosine of a given angle, so when you need both values it is most efficient to grab them at once as a `shz_sincos_t` pair. Angles are in radians by default; `_deg` variants take degrees and `u16` variants take the 16-bit fixed-point angle that `FSCA` consumes natively. - **C header:** `#include ` - **C++ header:** `#include ` - **C++ types:** [`shz::sincos`](https://sh4zam.com/api/cpp/sincos/) - **Symbols:** 51 ## Suffixes Suffixes used in this module. The full list is in [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). - `_deg`: Angle argument is in degrees. The default is radians. - `u16`: Angle is a 16-bit fixed-point value: 0..65535 maps to 0..2π, the native `FSCA` input format. - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. ## Sin/Cos Pairs Routines involving precomputed sine + cosine pairs. | Symbol | Description | | --- | --- | | [`shz_sincosu16`](https://sh4zam.com/api/trig/shz_sincosu16/) | Returns sinf()/cosf() pairs for the given unsigned 16-bit angle in radians. | | [`shz_sincosf`](https://sh4zam.com/api/trig/shz_sincosf/) | Returns sinf()/cosf() pairs for the given floating-point angle in radians. | | [`shz_sincosf_deg`](https://sh4zam.com/api/trig/shz_sincosf_deg/) | Returns sinf/cosf() pairs for the given floating-point angle in degrees. | | [`shz_sincos_tanf`](https://sh4zam.com/api/trig/shz_sincos_tanf/) | Returns tanf() from the given pre-computed `sincos` pair. | | [`shz_sincos_secf`](https://sh4zam.com/api/trig/shz_sincos_secf/) | Returns the floating-point secant (1.0f / cosf(x)) from the given pre-computed `sincos` pair. | | [`shz_sincos_cscf`](https://sh4zam.com/api/trig/shz_sincos_cscf/) | Returns the floating-point cosecant (1.0f / sinf(x)) from the given pre-computed `sincos` pair. | | [`shz_sincos_cotf`](https://sh4zam.com/api/trig/shz_sincos_cotf/) | Returns the floating-point cotangent (1.0f / tanf(x)) from the given pre-computed `sincos` pair. | ## Independent Functions Routines providing single trigonometric functions. | Symbol | Description | | --- | --- | | [`shz_sinf`](https://sh4zam.com/api/trig/shz_sinf/) | One-off routine for returning only sinf() from an angle in radians. | | [`shz_sinf_deg`](https://sh4zam.com/api/trig/shz_sinf_deg/) | One-off routine for returning only sinf() from an angle in degrees. | | [`shz_cosf`](https://sh4zam.com/api/trig/shz_cosf/) | One-off routine for returning only cosf() from an angle in radians. | | [`shz_cosf_deg`](https://sh4zam.com/api/trig/shz_cosf_deg/) | One-off routine for returning only cosf() from an angle in degrees. | | [`shz_tanf`](https://sh4zam.com/api/trig/shz_tanf/) | One-off routine for returning only tanf() from an angle in radians. | | [`shz_tanf_deg`](https://sh4zam.com/api/trig/shz_tanf_deg/) | One-off routine for returning only tanf() from an angle in degrees. | | [`shz_secf`](https://sh4zam.com/api/trig/shz_secf/) | One-off routine for returning only secant (1 / cos(x)) from an angle in radians. | | [`shz_secf_deg`](https://sh4zam.com/api/trig/shz_secf_deg/) | One-off routine for returning only secant (1 / cos(x)) from an angle in degrees. | | [`shz_cscf`](https://sh4zam.com/api/trig/shz_cscf/) | One-off routine for returning only cosecant (1 / sin(x)) from an angle in radians. | | [`shz_cscf_deg`](https://sh4zam.com/api/trig/shz_cscf_deg/) | One-off routine for returning only cosecant (1 / sin(x)) from an angle in degrees. | | [`shz_cotf`](https://sh4zam.com/api/trig/shz_cotf/) | One-off routine for returning only cotangent (1 / tan(x)) from an angle in radians. | | [`shz_cotf_deg`](https://sh4zam.com/api/trig/shz_cotf_deg/) | One-off routine for returning only cotangent (1 / cot(x)) from an angle in degrees. | ## Inverse Functions Routines providing inverse trigonometric functions. | Symbol | Description | | --- | --- | | [`shz_asinf`](https://sh4zam.com/api/trig/shz_asinf/) | Fast arcsine approximation; equivalent to C's asinf(). | | [`shz_acosf`](https://sh4zam.com/api/trig/shz_acosf/) | Fast arccosine approximation; equivalent to C's acosf(). | | [`shz_atanf_unit`](https://sh4zam.com/api/trig/shz_atanf_unit/) | Fast arctangent approximation for unit values between `0.0f` and `1.0f`. | | [`shz_atanf_q1`](https://sh4zam.com/api/trig/shz_atanf_q1/) | Fast arctangent approximation for values lying within the first quadrant (`>= 0.0f`). | | [`shz_atanf`](https://sh4zam.com/api/trig/shz_atanf/) | Fast arctangent approximation; equvalent to C's atanf(). | | [`shz_atan2f`](https://sh4zam.com/api/trig/shz_atan2f/) | Computes arctangent of `y / x`, using the signs of arguments to determine correct quadtrant. Equivalent to C's atan2f(). | | [`shz_asecf`](https://sh4zam.com/api/trig/shz_asecf/) | Fast arcsecant/inverse secant approximation, taking units in radians. | | [`shz_acscf`](https://sh4zam.com/api/trig/shz_acscf/) | Fast arccosecant/inverse cosecant approximation; taking units in radians. | | [`shz_acotf`](https://sh4zam.com/api/trig/shz_acotf/) | Fast arccotangent/inverse cotangent approximation; taking units in radians. | ## Hyperbolic Functions Trigonometric functions for hyperbolas | Symbol | Description | | --- | --- | | [`shz_sinhf`](https://sh4zam.com/api/trig/shz_sinhf/) | Fast hyperbolic sine function. | | [`shz_coshf`](https://sh4zam.com/api/trig/shz_coshf/) | Fast hyperbolic cosine function. | | [`shz_tanhf`](https://sh4zam.com/api/trig/shz_tanhf/) | Fast hyperbolic tangent function. | | [`shz_cschf`](https://sh4zam.com/api/trig/shz_cschf/) | Fast hyperbolic cosecant function. | | [`shz_sechf`](https://sh4zam.com/api/trig/shz_sechf/) | Fast hyperbolic secant function. | | [`shz_cothf`](https://sh4zam.com/api/trig/shz_cothf/) | Fast hyperbolic cotangent function. | ## Inverse Hyperbolic Functions Inverse trigonometric functions for hyperbolas | Symbol | Description | | --- | --- | | [`shz_asinhf`](https://sh4zam.com/api/trig/shz_asinhf/) | Fast hyperbolic arcsine function. | | [`shz_acoshf`](https://sh4zam.com/api/trig/shz_acoshf/) | Fast hyperbolic arccosine function. | | [`shz_atanhf`](https://sh4zam.com/api/trig/shz_atanhf/) | Fast hyperbolic arctangent function. | | [`shz_acschf`](https://sh4zam.com/api/trig/shz_acschf/) | Fast hyperbolic arccosecant function. | | [`shz_asechf`](https://sh4zam.com/api/trig/shz_asechf/) | Fast hyperbolic arcsecant function. | | [`shz_acothf`](https://sh4zam.com/api/trig/shz_acothf/) | Fast hyperbolic arccotangent function. | ## Macros | Symbol | Description | | --- | --- | | [`SHZ_F_PI`](https://sh4zam.com/api/trig/SHZ_F_PI/) | Single-precision floating-point PI approximation (do not use M_PI!). | | [`SHZ_F_TAU`](https://sh4zam.com/api/trig/SHZ_F_TAU/) | Single-precision FP PI approximation times 2. | | [`SHZ_F_PI_2`](https://sh4zam.com/api/trig/SHZ_F_PI_2/) | Single-precision FP PI approximation divided by 2. | | [`SHZ_F_PI_4`](https://sh4zam.com/api/trig/SHZ_F_PI_4/) | Single-precision FP PI approximation divided by 4. | | [`SHZ_FSCA_RAD_FACTOR`](https://sh4zam.com/api/trig/SHZ_FSCA_RAD_FACTOR/) | Multiplicative factor for passing the FSCA instruction angles in radians. | | [`SHZ_FSCA_DEG_FACTOR`](https://sh4zam.com/api/trig/SHZ_FSCA_DEG_FACTOR/) | Multiplicative factor for passing the FSCA instrution angles in degrees. | | [`SHZ_FSCA_ERROR_MAX`](https://sh4zam.com/api/trig/SHZ_FSCA_ERROR_MAX/) | Maximum FP error for FSCA instruction. | | [`SHZ_DEG_TO_RAD`](https://sh4zam.com/api/trig/SHZ_DEG_TO_RAD/) | Converts the given angle in degrees to radians. | | [`SHZ_RAD_TO_DEG`](https://sh4zam.com/api/trig/SHZ_RAD_TO_DEG/) | Converts the given angle in radians to degrees. | ## Types | Symbol | Description | | --- | --- | | [`shz_sincos_t`](https://sh4zam.com/api/trig/shz_sincos_t/) | Pair representing the sine and cosine of a given angle. | | [`shz_sincos`](https://sh4zam.com/api/trig/shz_sincos/) | Alternate C [`shz_sincos_t`](https://sh4zam.com/api/trig/shz_sincos_t/) typedef for those who hate POSIX style. | --- # shz_acosf Source: https://sh4zam.com/api/trig/shz_acosf/ ```c SHZ_INLINE float shz_acosf(float x) SHZ_NOEXCEPT; ``` Fast arccosine approximation; equivalent to C's acosf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::acosf`](https://sh4zam.com/api/cpp/#shzacosf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:145`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L145) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_acoshf Source: https://sh4zam.com/api/trig/shz_acoshf/ ```c SHZ_INLINE float shz_acoshf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic arccosine function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::acoshf`](https://sh4zam.com/api/cpp/#shzacoshf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:204`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L204) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Hyperbolic Functions" --- # shz_acotf Source: https://sh4zam.com/api/trig/shz_acotf/ ```c SHZ_INLINE float shz_acotf(float x) SHZ_NOEXCEPT; ``` Fast arccotangent/inverse cotangent approximation; taking units in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::acotf`](https://sh4zam.com/api/cpp/#shzacotf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:166`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L166) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_acothf Source: https://sh4zam.com/api/trig/shz_acothf/ ```c SHZ_INLINE float shz_acothf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic arccotangent function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::acothf`](https://sh4zam.com/api/cpp/#shzacothf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:216`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L216) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Hyperbolic Functions" --- # shz_acscf Source: https://sh4zam.com/api/trig/shz_acscf/ ```c SHZ_INLINE float shz_acscf(float x) SHZ_NOEXCEPT; ``` Fast arccosecant/inverse cosecant approximation; taking units in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::acscf`](https://sh4zam.com/api/cpp/#shzacscf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:163`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L163) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_acschf Source: https://sh4zam.com/api/trig/shz_acschf/ ```c SHZ_INLINE float shz_acschf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic arccosecant function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::acschf`](https://sh4zam.com/api/cpp/#shzacschf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:210`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L210) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Hyperbolic Functions" --- # shz_asecf Source: https://sh4zam.com/api/trig/shz_asecf/ ```c SHZ_INLINE float shz_asecf(float x) SHZ_NOEXCEPT; ``` Fast arcsecant/inverse secant approximation, taking units in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::asecf`](https://sh4zam.com/api/cpp/#shzasecf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:160`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L160) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_asechf Source: https://sh4zam.com/api/trig/shz_asechf/ ```c SHZ_INLINE float shz_asechf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic arcsecant function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::asechf`](https://sh4zam.com/api/cpp/#shzasechf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:213`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L213) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Hyperbolic Functions" --- # shz_asinf Source: https://sh4zam.com/api/trig/shz_asinf/ ```c SHZ_INLINE float shz_asinf(float x) SHZ_NOEXCEPT; ``` Fast arcsine approximation; equivalent to C's asinf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::asinf`](https://sh4zam.com/api/cpp/#shzasinf) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:142`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L142) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_asinhf Source: https://sh4zam.com/api/trig/shz_asinhf/ ```c SHZ_INLINE float shz_asinhf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic arcsine function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::asinhf`](https://sh4zam.com/api/cpp/#shzasinhf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:201`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L201) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Hyperbolic Functions" --- # shz_atan2f Source: https://sh4zam.com/api/trig/shz_atan2f/ > Computes arctangent of y / x, using the signs of arguments to determine correct quadtrant. Equivalent to C's atan2f() ```c SHZ_INLINE float shz_atan2f(float y, float x) SHZ_NOEXCEPT; ``` Computes arctangent of `y / x`, using the signs of arguments to determine correct quadtrant. Equivalent to C's atan2f(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `y` | `float` | | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::atan2f`](https://sh4zam.com/api/cpp/#shzatan2f) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:157`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L157) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_atanf_q1 Source: https://sh4zam.com/api/trig/shz_atanf_q1/ > Fast arctangent approximation for values lying within the first quadrant (>= 0.0f) ```c SHZ_INLINE float shz_atanf_q1(float x) SHZ_NOEXCEPT; ``` Fast arctangent approximation for values lying within the first quadrant (`>= 0.0f`). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::atanf_q1`](https://sh4zam.com/api/cpp/#shzatanf_q1) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:151`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L151) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_atanf_unit Source: https://sh4zam.com/api/trig/shz_atanf_unit/ > Fast arctangent approximation for unit values between 0.0f and 1.0f ```c SHZ_INLINE float shz_atanf_unit(float x) SHZ_NOEXCEPT; ``` Fast arctangent approximation for unit values between `0.0f` and `1.0f`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::atanf_unit`](https://sh4zam.com/api/cpp/#shzatanf_unit) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:148`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L148) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_atanf Source: https://sh4zam.com/api/trig/shz_atanf/ ```c SHZ_INLINE float shz_atanf(float x) SHZ_NOEXCEPT; ``` Fast arctangent approximation; equvalent to C's atanf(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::atanf`](https://sh4zam.com/api/cpp/#shzatanf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:154`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L154) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Functions" --- # shz_atanhf Source: https://sh4zam.com/api/trig/shz_atanhf/ ```c SHZ_INLINE float shz_atanhf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic arctangent function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::atanhf`](https://sh4zam.com/api/cpp/#shzatanhf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:207`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L207) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Inverse Hyperbolic Functions" --- # shz_cosf_deg Source: https://sh4zam.com/api/trig/shz_cosf_deg/ ```c SHZ_INLINE float shz_cosf_deg(float degrees) SHZ_NOEXCEPT; ``` One-off routine for returning only cosf() from an angle in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `degrees` | `float` | | ## Returns `float` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::cosf_deg`](https://sh4zam.com/api/cpp/#shzcosf_deg) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:108`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L108) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_cosf Source: https://sh4zam.com/api/trig/shz_cosf/ ```c SHZ_INLINE float shz_cosf(float radians) SHZ_NOEXCEPT; ``` One-off routine for returning only cosf() from an angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cosf`](https://sh4zam.com/api/cpp/#shzcosf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:105`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L105) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_coshf Source: https://sh4zam.com/api/trig/shz_coshf/ ```c SHZ_INLINE float shz_coshf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic cosine function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::coshf`](https://sh4zam.com/api/cpp/#shzcoshf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:179`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L179) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Hyperbolic Functions" --- # shz_cotf_deg Source: https://sh4zam.com/api/trig/shz_cotf_deg/ ```c SHZ_INLINE float shz_cotf_deg(float degrees) SHZ_NOEXCEPT; ``` One-off routine for returning only cotangent (1 / cot(x)) from an angle in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `degrees` | `float` | | ## Returns `float` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::cotf_deg`](https://sh4zam.com/api/cpp/#shzcotf_deg) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:132`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L132) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_cotf Source: https://sh4zam.com/api/trig/shz_cotf/ ```c SHZ_INLINE float shz_cotf(float radians) SHZ_NOEXCEPT; ``` One-off routine for returning only cotangent (1 / tan(x)) from an angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cotf`](https://sh4zam.com/api/cpp/#shzcotf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:129`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L129) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_cothf Source: https://sh4zam.com/api/trig/shz_cothf/ ```c SHZ_INLINE float shz_cothf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic cotangent function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cothf`](https://sh4zam.com/api/cpp/#shzcothf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:191`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L191) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Hyperbolic Functions" --- # shz_cscf_deg Source: https://sh4zam.com/api/trig/shz_cscf_deg/ ```c SHZ_INLINE float shz_cscf_deg(float degrees) SHZ_NOEXCEPT; ``` One-off routine for returning only cosecant (1 / sin(x)) from an angle in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `degrees` | `float` | | ## Returns `float` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::cscf_deg`](https://sh4zam.com/api/cpp/#shzcscf_deg) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:126`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L126) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_cscf Source: https://sh4zam.com/api/trig/shz_cscf/ ```c SHZ_INLINE float shz_cscf(float radians) SHZ_NOEXCEPT; ``` One-off routine for returning only cosecant (1 / sin(x)) from an angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cscf`](https://sh4zam.com/api/cpp/#shzcscf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:123`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L123) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_cschf Source: https://sh4zam.com/api/trig/shz_cschf/ ```c SHZ_INLINE float shz_cschf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic cosecant function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::cschf`](https://sh4zam.com/api/cpp/#shzcschf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:185`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L185) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Hyperbolic Functions" --- # SHZ_DEG_TO_RAD Source: https://sh4zam.com/api/trig/SHZ_DEG_TO_RAD/ ```c #define SHZ_DEG_TO_RAD(deg) ((deg) * SHZ_F_PI / 180.0f) ``` Converts the given angle in degrees to radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `deg` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:42`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L42) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # SHZ_F_PI_2 Source: https://sh4zam.com/api/trig/SHZ_F_PI_2/ ```c #define SHZ_F_PI_2 (SHZ_F_PI * 0.5f) ``` Single-precision FP PI approximation divided by 2. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:31`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L31) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # SHZ_F_PI_4 Source: https://sh4zam.com/api/trig/SHZ_F_PI_4/ ```c #define SHZ_F_PI_4 (SHZ_F_PI * 0.25f) ``` Single-precision FP PI approximation divided by 4. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:33`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L33) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # SHZ_F_PI Source: https://sh4zam.com/api/trig/SHZ_F_PI/ ```c #define SHZ_F_PI 3.14159265359f ``` Single-precision floating-point PI approximation (do not use M_PI!). ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:27`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L27) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # SHZ_F_TAU Source: https://sh4zam.com/api/trig/SHZ_F_TAU/ ```c #define SHZ_F_TAU (SHZ_F_PI * 2.0f) ``` Single-precision FP PI approximation times 2. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:29`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L29) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # SHZ_FSCA_DEG_FACTOR Source: https://sh4zam.com/api/trig/SHZ_FSCA_DEG_FACTOR/ ```c #define SHZ_FSCA_DEG_FACTOR 182.04444443f ``` Multiplicative factor for passing the FSCA instrution angles in degrees. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:37`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L37) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # SHZ_FSCA_ERROR_MAX Source: https://sh4zam.com/api/trig/SHZ_FSCA_ERROR_MAX/ ```c #define SHZ_FSCA_ERROR_MAX 4.76837158e-7 ``` Maximum FP error for FSCA instruction. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:39`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L39) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # SHZ_FSCA_RAD_FACTOR Source: https://sh4zam.com/api/trig/SHZ_FSCA_RAD_FACTOR/ ```c #define SHZ_FSCA_RAD_FACTOR 10430.37835f ``` Multiplicative factor for passing the FSCA instruction angles in radians. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:35`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L35) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # SHZ_RAD_TO_DEG Source: https://sh4zam.com/api/trig/SHZ_RAD_TO_DEG/ ```c #define SHZ_RAD_TO_DEG(rad) ((rad) * 180.0f / SHZ_F_PI) ``` Converts the given angle in radians to degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `rad` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:44`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L44) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Macros" --- # shz_secf_deg Source: https://sh4zam.com/api/trig/shz_secf_deg/ ```c SHZ_INLINE float shz_secf_deg(float degrees) SHZ_NOEXCEPT; ``` One-off routine for returning only secant (1 / cos(x)) from an angle in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `degrees` | `float` | | ## Returns `float` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::secf_deg`](https://sh4zam.com/api/cpp/#shzsecf_deg) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:120`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L120) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_secf Source: https://sh4zam.com/api/trig/shz_secf/ ```c SHZ_INLINE float shz_secf(float radians) SHZ_NOEXCEPT; ``` One-off routine for returning only secant (1 / cos(x)) from an angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::secf`](https://sh4zam.com/api/cpp/#shzsecf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:117`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L117) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_sechf Source: https://sh4zam.com/api/trig/shz_sechf/ ```c SHZ_INLINE float shz_sechf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic secant function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::sechf`](https://sh4zam.com/api/cpp/#shzsechf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:188`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L188) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Hyperbolic Functions" --- # shz_sincos_cotf Source: https://sh4zam.com/api/trig/shz_sincos_cotf/ > Returns the floating-point cotangent (1.0f / tanf(x)) from the given pre-computed sincos pair ```c SHZ_INLINE float shz_sincos_cotf(shz_sincos_t sincos) SHZ_NOEXCEPT; ``` Returns the floating-point cotangent (1.0f / tanf(x)) from the given pre-computed `sincos` pair. ## Parameters | Name | Type | Description | | --- | --- | --- | | `sincos` | `shz_sincos_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::sincos::cotf`](https://sh4zam.com/api/cpp/sincos/#cotf), [`shz::sincos_cotf`](https://sh4zam.com/api/cpp/#shzsincos_cotf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:89`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L89) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Sin/Cos Pairs" --- # shz_sincos_cscf Source: https://sh4zam.com/api/trig/shz_sincos_cscf/ > Returns the floating-point cosecant (1.0f / sinf(x)) from the given pre-computed sincos pair ```c SHZ_INLINE float shz_sincos_cscf(shz_sincos_t sincos) SHZ_NOEXCEPT; ``` Returns the floating-point cosecant (1.0f / sinf(x)) from the given pre-computed `sincos` pair. ## Parameters | Name | Type | Description | | --- | --- | --- | | `sincos` | `shz_sincos_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::sincos::cscf`](https://sh4zam.com/api/cpp/sincos/#cscf), [`shz::sincos_cscf`](https://sh4zam.com/api/cpp/#shzsincos_cscf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:86`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L86) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Sin/Cos Pairs" --- # shz_sincos_secf Source: https://sh4zam.com/api/trig/shz_sincos_secf/ > Returns the floating-point secant (1.0f / cosf(x)) from the given pre-computed sincos pair ```c SHZ_INLINE float shz_sincos_secf(shz_sincos_t sincos) SHZ_NOEXCEPT; ``` Returns the floating-point secant (1.0f / cosf(x)) from the given pre-computed `sincos` pair. ## Parameters | Name | Type | Description | | --- | --- | --- | | `sincos` | `shz_sincos_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::sincos::secf`](https://sh4zam.com/api/cpp/sincos/#secf), [`shz::sincos_secf`](https://sh4zam.com/api/cpp/#shzsincos_secf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:83`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L83) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Sin/Cos Pairs" --- # shz_sincos_t Source: https://sh4zam.com/api/trig/shz_sincos_t/ ```c typedef struct shz_sincos { float sin; //!< sinf() approximation for the angle float cos; //!< cosf() approximation for the angle } shz_sincos_t; ``` Pair representing the sine and cosine of a given angle. ## Fields | Field | Type | Description | | --- | --- | --- | | `sin` | `float` | sinf() approximation for the angle | | `cos` | `float` | cosf() approximation for the angle | ## Details The SH4 provides a single instruction, `FSCA`, for retrieving fast approximations of **both** the sine and cosine of a given angle. As such, when you need both values, it's most efficient to grab them both at once as a pair using this structure than it is to retrieve them separately. ## Availability - **C++ equivalent:** [`shz::sincos`](https://sh4zam.com/api/cpp/sincos/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:57`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L57) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Types" ## See also [`shz_sincosf`](https://sh4zam.com/api/trig/shz_sincosf/), [`shz_sincosf_deg`](https://sh4zam.com/api/trig/shz_sincosf_deg/) --- # shz_sincos_tanf Source: https://sh4zam.com/api/trig/shz_sincos_tanf/ > Returns tanf() from the given pre-computed sincos pair ```c SHZ_INLINE float shz_sincos_tanf(shz_sincos_t sincos) SHZ_NOEXCEPT; ``` Returns tanf() from the given pre-computed `sincos` pair. ## Parameters | Name | Type | Description | | --- | --- | --- | | `sincos` | `shz_sincos_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::sincos::tanf`](https://sh4zam.com/api/cpp/sincos/#tanf), [`shz::sincos_tanf`](https://sh4zam.com/api/cpp/#shzsincos_tanf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:80`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L80) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Sin/Cos Pairs" --- # shz_sincos Source: https://sh4zam.com/api/trig/shz_sincos/ > Alternate C shz_sincos_t typedef for those who hate POSIX style ```c typedef shz_sincos_t shz_sincos; ``` Alternate C [`shz_sincos_t`](https://sh4zam.com/api/trig/shz_sincos_t/) typedef for those who hate POSIX style. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_trig.h:63`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L63) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Types" --- # shz_sincosf_deg Source: https://sh4zam.com/api/trig/shz_sincosf_deg/ ```c SHZ_INLINE shz_sincos_t shz_sincosf_deg(float degrees) SHZ_NOEXCEPT; ``` Returns sinf/cosf() pairs for the given floating-point angle in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `degrees` | `float` | | ## Returns `shz_sincos_t` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::sincos::from_degrees`](https://sh4zam.com/api/cpp/sincos/#from_degrees), [`shz::sincosf_deg`](https://sh4zam.com/api/cpp/#shzsincosf_deg) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:77`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L77) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Sin/Cos Pairs" --- # shz_sincosf Source: https://sh4zam.com/api/trig/shz_sincosf/ ```c SHZ_INLINE shz_sincos_t shz_sincosf(float radians) SHZ_NOEXCEPT; ``` Returns sinf()/cosf() pairs for the given floating-point angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns `shz_sincos_t` ## Availability - **C++ equivalent:** [`shz::sincosf`](https://sh4zam.com/api/cpp/#shzsincosf) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:74`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L74) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Sin/Cos Pairs" --- # shz_sincosu16 Source: https://sh4zam.com/api/trig/shz_sincosu16/ ```c SHZ_INLINE shz_sincos_t shz_sincosu16(uint16_t radians16) SHZ_NOEXCEPT; ``` Returns sinf()/cosf() pairs for the given unsigned 16-bit angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians16` | `uint16_t` | | ## Returns `shz_sincos_t` ## Naming and requirements - `u16`: Angle is a 16-bit fixed-point value: 0..65535 maps to 0..2π, the native `FSCA` input format. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::sincosu16`](https://sh4zam.com/api/cpp/#shzsincosu16) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:71`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L71) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Sin/Cos Pairs" --- # shz_sinf_deg Source: https://sh4zam.com/api/trig/shz_sinf_deg/ ```c SHZ_INLINE float shz_sinf_deg(float degrees) SHZ_NOEXCEPT; ``` One-off routine for returning only sinf() from an angle in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `degrees` | `float` | | ## Returns `float` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::sinf_deg`](https://sh4zam.com/api/cpp/#shzsinf_deg) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:102`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L102) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_sinf Source: https://sh4zam.com/api/trig/shz_sinf/ ```c SHZ_INLINE float shz_sinf(float radians) SHZ_NOEXCEPT; ``` One-off routine for returning only sinf() from an angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::sinf`](https://sh4zam.com/api/cpp/#shzsinf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:99`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L99) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_sinhf Source: https://sh4zam.com/api/trig/shz_sinhf/ ```c SHZ_INLINE float shz_sinhf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic sine function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::sinhf`](https://sh4zam.com/api/cpp/#shzsinhf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:176`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L176) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Hyperbolic Functions" --- # shz_tanf_deg Source: https://sh4zam.com/api/trig/shz_tanf_deg/ ```c SHZ_INLINE float shz_tanf_deg(float degrees) SHZ_NOEXCEPT; ``` One-off routine for returning only tanf() from an angle in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `degrees` | `float` | | ## Returns `float` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::tanf_deg`](https://sh4zam.com/api/cpp/#shztanf_deg) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:114`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L114) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_tanf Source: https://sh4zam.com/api/trig/shz_tanf/ ```c SHZ_INLINE float shz_tanf(float radians) SHZ_NOEXCEPT; ``` One-off routine for returning only tanf() from an angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::tanf`](https://sh4zam.com/api/cpp/#shztanf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:111`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L111) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Independent Functions" --- # shz_tanhf Source: https://sh4zam.com/api/trig/shz_tanhf/ ```c SHZ_INLINE float shz_tanhf(float x) SHZ_NOEXCEPT; ``` Fast hyperbolic tangent function. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::tanhf`](https://sh4zam.com/api/cpp/#shztanhf) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_trig.h:182`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_trig.h#L182) - **Module:** [Trigonometry](https://sh4zam.com/api/trig/), section "Hyperbolic Functions" --- # Vector API Source: https://sh4zam.com/api/vector/ > API for vector math: 2D, 3D and 4D vector types and operations The Vector API provides structures representing commonly-used vector types as well as routines implementing various mathematical operations on them. Every operation exists per dimension (`shz_vec2_*`, `shz_vec3_*`, `shz_vec4_*`), and C code can call the type-generic `shz_vec_*` macros, which forward to the proper routine based on the argument type. Dot products and magnitudes are routed through the SH4 `FIPR` instruction, and normalization uses `FSRRA`. In C++, `shz::vec2`, `shz::vec3` and `shz::vec4` derive from the C structs and expose the same routines as methods and operators. - **C header:** `#include ` - **C++ header:** `#include ` - **C++ types:** [`shz::vecN`](https://sh4zam.com/api/cpp/vecn/), [`shz::vec2`](https://sh4zam.com/api/cpp/vec2/), [`shz::vec3`](https://sh4zam.com/api/cpp/vec3/), [`shz::vec4`](https://sh4zam.com/api/cpp/vec4/) - **Symbols:** 229 ## Suffixes Suffixes used in this module. The full list is in [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). - `_safe`: Guards degenerate input (zero-length vectors, zero denominators) at a small cost. - `_fsrra`: Uses `FSRRA` (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise. - `_deg`: Angle argument is in degrees. The default is radians. - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ## Adapters Macros for converting between SH4ZAM and other compatible formats. | Symbol | Description | | --- | --- | | [`shz_vec2_deref`](https://sh4zam.com/api/vector/shz_vec2_deref/) | Dereferences the given pointer to a sequence of 2 floats as a [`shz_vec2_t`](https://sh4zam.com/api/vector/shz_vec2_t/). | | [`shz_vec3_deref`](https://sh4zam.com/api/vector/shz_vec3_deref/) | Dereferences the given pointer to a sequence of 3 floats as a [`shz_vec3_t`](https://sh4zam.com/api/vector/shz_vec3_t/). | | [`shz_vec4_deref`](https://sh4zam.com/api/vector/shz_vec4_deref/) | Dereferences the given pointer to a sequence of 4 floats as a [`shz_vec4_t`](https://sh4zam.com/api/vector/shz_vec4_t/). | | [`shz_vec2_from`](https://sh4zam.com/api/vector/shz_vec2_from/) | Converts the given `value` or expression to the equivalent 2D SH4ZAM vector value. | | [`shz_vec3_from`](https://sh4zam.com/api/vector/shz_vec3_from/) | Converts the given `value` or expression to the equivalent 3D SH4ZAM vector value. | | [`shz_vec4_from`](https://sh4zam.com/api/vector/shz_vec4_from/) | Converts the given `value` or expression to the equivalent 4D SH4ZAM vector value. | | [`shz_vec2_to`](https://sh4zam.com/api/vector/shz_vec2_to/) | Converts the given 2D `vector` into a value of the given `type`. | | [`shz_vec3_to`](https://sh4zam.com/api/vector/shz_vec3_to/) | Converts the given 3D `vector` into a value of the given `type`. | | [`shz_vec4_to`](https://sh4zam.com/api/vector/shz_vec4_to/) | Converts the given 4D `vector` into a value of the given `type`. | ## Type-Generic Routines Generalized vector routines for C and C++. | Symbol | Description | | --- | --- | | [`shz_vec_abs`](https://sh4zam.com/api/vector/shz_vec_abs/) | C type-generic vector absolute value. | | [`shz_vec_neg`](https://sh4zam.com/api/vector/shz_vec_neg/) | C type-generic vector negation. | | [`shz_vec_inv`](https://sh4zam.com/api/vector/shz_vec_inv/) | C type-generic vector inversion. | | [`shz_vec_max`](https://sh4zam.com/api/vector/shz_vec_max/) | C type-generic vector maximum value. | | [`shz_vec_min`](https://sh4zam.com/api/vector/shz_vec_min/) | C type-generic vector minimum value. | | [`shz_vec_clamp`](https://sh4zam.com/api/vector/shz_vec_clamp/) | C type-generic vector minimum value. | | [`shz_vec_equal`](https://sh4zam.com/api/vector/shz_vec_equal/) | C type-generic vector equals. | | [`shz_vec_add`](https://sh4zam.com/api/vector/shz_vec_add/) | C type-generic vector addition. | | [`shz_vec_sub`](https://sh4zam.com/api/vector/shz_vec_sub/) | C type-generic vector subtraction. | | [`shz_vec_mul`](https://sh4zam.com/api/vector/shz_vec_mul/) | C type-generic vector multiplication. | | [`shz_vec_div`](https://sh4zam.com/api/vector/shz_vec_div/) | C type-generic vector division. | | [`shz_vec_scale`](https://sh4zam.com/api/vector/shz_vec_scale/) | C type-generic vector scaling. | | [`shz_vec_dot`](https://sh4zam.com/api/vector/shz_vec_dot/) | C type-generic vector dot product. | | [`shz_vec_dot2`](https://sh4zam.com/api/vector/shz_vec_dot2/) | C type-generic vector chained double dot product. | | [`shz_vec_dot3`](https://sh4zam.com/api/vector/shz_vec_dot3/) | C type-generic vector chained triple dot product. | | [`shz_vec_magnitude_sqr`](https://sh4zam.com/api/vector/shz_vec_magnitude_sqr/) | C type-generic vector squared magnitude. | | [`shz_vec_magnitude`](https://sh4zam.com/api/vector/shz_vec_magnitude/) | C type-generic vector magnitude. | | [`shz_vec_magnitude_inv`](https://sh4zam.com/api/vector/shz_vec_magnitude_inv/) | C type-generic vector inverse magnitude. | | [`shz_vec_normalize`](https://sh4zam.com/api/vector/shz_vec_normalize/) | C type-generic vector normalization. | | [`shz_vec_normalize_safe`](https://sh4zam.com/api/vector/shz_vec_normalize_safe/) | C type-generic safe vector normalization. | | [`shz_vec_distance`](https://sh4zam.com/api/vector/shz_vec_distance/) | C type-generic vector distance. | | [`shz_vec_move`](https://sh4zam.com/api/vector/shz_vec_move/) | C type-generic vector move. | | [`shz_vec_distance_sqr`](https://sh4zam.com/api/vector/shz_vec_distance_sqr/) | C type-generic vector squared distance. | | [`shz_vec_lerp`](https://sh4zam.com/api/vector/shz_vec_lerp/) | C type-generic linear interpolation between two vectors. | | [`shz_vec_reflect`](https://sh4zam.com/api/vector/shz_vec_reflect/) | C type-generic vector reflection. | | [`shz_vec_refract`](https://sh4zam.com/api/vector/shz_vec_refract/) | C type-generic vector refraction. | | [`shz_vec_cross`](https://sh4zam.com/api/vector/shz_vec_cross/) | C type-generic vector cross-product. | | [`shz_vec_project`](https://sh4zam.com/api/vector/shz_vec_project/) | C type-generic vector projection. | | [`shz_vec_project_safe`](https://sh4zam.com/api/vector/shz_vec_project_safe/) | C type-generic safe vector projection. | | [`shz_vec_angles`](https://sh4zam.com/api/vector/shz_vec_angles/) | C type-generic angle-from-vector extraction. | | [`shz_vec_angle_between`](https://sh4zam.com/api/vector/shz_vec_angle_between/) | C type-generic angle between two vectors. | | [`shz_vec_swizzle`](https://sh4zam.com/api/vector/shz_vec_swizzle/) | C type-generic vector swizzling. | | [`shz_vec_floor`](https://sh4zam.com/api/vector/shz_vec_floor/) | C type-generic component-wise floor. | | [`shz_vec_ceil`](https://sh4zam.com/api/vector/shz_vec_ceil/) | C type-generic component-wise ceil. | | [`shz_vec_round`](https://sh4zam.com/api/vector/shz_vec_round/) | C type-generic component-wise round. | | [`shz_vec_fract`](https://sh4zam.com/api/vector/shz_vec_fract/) | C type-generic component-wise fract. | | [`shz_vec_sign`](https://sh4zam.com/api/vector/shz_vec_sign/) | C type-generic component-wise sign. | | [`shz_vec_saturate`](https://sh4zam.com/api/vector/shz_vec_saturate/) | C type-generic component-wise saturate. | | [`shz_vec_minv`](https://sh4zam.com/api/vector/shz_vec_minv/) | C type-generic pairwise minimum. | | [`shz_vec_maxv`](https://sh4zam.com/api/vector/shz_vec_maxv/) | C type-generic pairwise maximum. | | [`shz_vec_inv_sqrtf`](https://sh4zam.com/api/vector/shz_vec_inv_sqrtf/) | C type-generic inv_sqrtf. | | [`shz_vec_sqrtf`](https://sh4zam.com/api/vector/shz_vec_sqrtf/) | C type-generic sqrtf. | | [`shz_vec_stepv`](https://sh4zam.com/api/vector/shz_vec_stepv/) | C type-generic component-wise step. | | [`shz_vec_step`](https://sh4zam.com/api/vector/shz_vec_step/) | C type-generic step. | | [`shz_vec_smoothstepv`](https://sh4zam.com/api/vector/shz_vec_smoothstepv/) | C type-generic component-wise smoothstep. | | [`shz_vec_smoothstep`](https://sh4zam.com/api/vector/shz_vec_smoothstep/) | C type-generic smoothstep. | | [`shz_vec_smoothstepv_safe`](https://sh4zam.com/api/vector/shz_vec_smoothstepv_safe/) | C type-generic component-wise smoothstep_safe. | | [`shz_vec_smoothstep_safe`](https://sh4zam.com/api/vector/shz_vec_smoothstep_safe/) | C type-generic smoothstep_safe. | ## Initializers Component-based initialization routines. | Symbol | Description | | --- | --- | | [`shz_vec2_init`](https://sh4zam.com/api/vector/shz_vec2_init/) | Returns a 2D vector with the given `x`, and `y` coordinates. | | [`shz_vec3_init`](https://sh4zam.com/api/vector/shz_vec3_init/) | Returns a 3D vector with the given `x`, `y`, and `z` coordinates. | | [`shz_vec4_init`](https://sh4zam.com/api/vector/shz_vec4_init/) | Returns a 4D vector with the given `x`, `y`, `z`, and `w` coordinates. | | [`shz_vec2_fill`](https://sh4zam.com/api/vector/shz_vec2_fill/) | Returns a 2D vector with the value of each component equal to `v`. | | [`shz_vec3_fill`](https://sh4zam.com/api/vector/shz_vec3_fill/) | Returns a 3D vector with the value of each compoonent equal to `v`. | | [`shz_vec4_fill`](https://sh4zam.com/api/vector/shz_vec4_fill/) | Returns a 4D vector with the value of each component equal to `v`. | ## Component-wise Operations Routines which apply to each vector component. | Symbol | Description | | --- | --- | | [`shz_vec2_abs`](https://sh4zam.com/api/vector/shz_vec2_abs/) | Returns a 2D vector whose components are the absolute values of the given vector's components. | | [`shz_vec3_abs`](https://sh4zam.com/api/vector/shz_vec3_abs/) | Returns a 3D vector whose components are the absolute values of the given vector's components. | | [`shz_vec4_abs`](https://sh4zam.com/api/vector/shz_vec4_abs/) | Returns a 4D vector whose components are the absolute values of the given vector's components. | | [`shz_vec2_neg`](https://sh4zam.com/api/vector/shz_vec2_neg/) | Returns a 2D vector whose components are the negative values of the given vector's components. | | [`shz_vec3_neg`](https://sh4zam.com/api/vector/shz_vec3_neg/) | Returns a 3D vector whose components are the negative values of the given vector's components. | | [`shz_vec4_neg`](https://sh4zam.com/api/vector/shz_vec4_neg/) | Returns a 4D vector whose components are the negative values of the given vector's components. | | [`shz_vec2_inv`](https://sh4zam.com/api/vector/shz_vec2_inv/) | Returns the 2D vector whose components have been inverted or reciprocated. | | [`shz_vec3_inv`](https://sh4zam.com/api/vector/shz_vec3_inv/) | Returns the 3D vector whose components have been inverted or reciprocated. | | [`shz_vec4_inv`](https://sh4zam.com/api/vector/shz_vec4_inv/) | Returns the 4D vector whose components have been inverted or reciprocated. | | [`shz_vec2_max`](https://sh4zam.com/api/vector/shz_vec2_max/) | Returns the maximum value of both of the given vector's components. | | [`shz_vec3_max`](https://sh4zam.com/api/vector/shz_vec3_max/) | Returns the maximum value of the given vector's 3 components. | | [`shz_vec4_max`](https://sh4zam.com/api/vector/shz_vec4_max/) | Returns the maximum value of the given vector's 4 componetns. | | [`shz_vec2_min`](https://sh4zam.com/api/vector/shz_vec2_min/) | Retuns the minimum value of both of the given vector's components. | | [`shz_vec3_min`](https://sh4zam.com/api/vector/shz_vec3_min/) | Returns the minimum value of the given vector's 3 components. | | [`shz_vec4_min`](https://sh4zam.com/api/vector/shz_vec4_min/) | Returns the minimum value of the given vector's 4 components. | | [`shz_vec2_clamp`](https://sh4zam.com/api/vector/shz_vec2_clamp/) | Clamps the values of the given 2D `vec` between `min` and `max`, returning a new vector. | | [`shz_vec3_clamp`](https://sh4zam.com/api/vector/shz_vec3_clamp/) | Clamps the values of the given 3D `vec` between `min` and `max`, returning a new vector. | | [`shz_vec4_clamp`](https://sh4zam.com/api/vector/shz_vec4_clamp/) | Clamps the values of the given 4D `vec` between `min` and `max`, returning a new vector. | | [`shz_vec2_floor`](https://sh4zam.com/api/vector/shz_vec2_floor/) | Returns a 2D vector whose components are the floor of the given vector's components. | | [`shz_vec3_floor`](https://sh4zam.com/api/vector/shz_vec3_floor/) | Returns a 3D vector whose components are the floor of the given vector's components. | | [`shz_vec4_floor`](https://sh4zam.com/api/vector/shz_vec4_floor/) | Returns a 4D vector whose components are the floor of the given vector's components. | | [`shz_vec2_ceil`](https://sh4zam.com/api/vector/shz_vec2_ceil/) | Returns a 2D vector whose components are the ceil of the given vector's components. | | [`shz_vec3_ceil`](https://sh4zam.com/api/vector/shz_vec3_ceil/) | Returns a 3D vector whose components are the ceil of the given vector's components. | | [`shz_vec4_ceil`](https://sh4zam.com/api/vector/shz_vec4_ceil/) | Returns a 4D vector whose components are the ceil of the given vector's components. | | [`shz_vec2_round`](https://sh4zam.com/api/vector/shz_vec2_round/) | Returns a 2D vector whose components are the rounded values of the given vector's components. | | [`shz_vec3_round`](https://sh4zam.com/api/vector/shz_vec3_round/) | Returns a 3D vector whose components are the rounded values of the given vector's components. | | [`shz_vec4_round`](https://sh4zam.com/api/vector/shz_vec4_round/) | Returns a 4D vector whose components are the rounded values of the given vector's components. | | [`shz_vec2_fract`](https://sh4zam.com/api/vector/shz_vec2_fract/) | Returns a 2D vector whose components are the fractional parts of the given vector's components. | | [`shz_vec3_fract`](https://sh4zam.com/api/vector/shz_vec3_fract/) | Returns a 3D vector whose components are the fractional parts of the given vector's components. | | [`shz_vec4_fract`](https://sh4zam.com/api/vector/shz_vec4_fract/) | Returns a 4D vector whose components are the fractional parts of the given vector's components. | | [`shz_vec2_sign`](https://sh4zam.com/api/vector/shz_vec2_sign/) | Returns a 2D vector whose components are the signs (-1, 0, or 1) of the given vector's components. | | [`shz_vec3_sign`](https://sh4zam.com/api/vector/shz_vec3_sign/) | Returns a 3D vector whose components are the signs (-1, 0, or 1) of the given vector's components. | | [`shz_vec4_sign`](https://sh4zam.com/api/vector/shz_vec4_sign/) | Returns a 4D vector whose components are the signs (-1, 0, or 1) of the given vector's components. | | [`shz_vec2_saturate`](https://sh4zam.com/api/vector/shz_vec2_saturate/) | Returns a 2D vector whose components are saturated (clamped to \[0, 1\]) values of the given vector's components. | | [`shz_vec3_saturate`](https://sh4zam.com/api/vector/shz_vec3_saturate/) | Returns a 3D vector whose components are saturated (clamped to \[0, 1\]) values of the given vector's components. | | [`shz_vec4_saturate`](https://sh4zam.com/api/vector/shz_vec4_saturate/) | Returns a 4D vector whose components are saturated (clamped to \[0, 1\]) values of the given vector's components. | | [`shz_vec2_minv`](https://sh4zam.com/api/vector/shz_vec2_minv/) | Returns a 2D vector whose components are the pairwise minimums of the two given vectors' components. | | [`shz_vec3_minv`](https://sh4zam.com/api/vector/shz_vec3_minv/) | Returns a 3D vector whose components are the pairwise minimums of the two given vectors' components. | | [`shz_vec4_minv`](https://sh4zam.com/api/vector/shz_vec4_minv/) | Returns a 4D vector whose components are the pairwise minimums of the two given vectors' components. | | [`shz_vec2_maxv`](https://sh4zam.com/api/vector/shz_vec2_maxv/) | Returns a 2D vector whose components are the pairwise maximums of the two given vectors' components. | | [`shz_vec3_maxv`](https://sh4zam.com/api/vector/shz_vec3_maxv/) | Returns a 3D vector whose components are the pairwise maximums of the two given vectors' components. | | [`shz_vec4_maxv`](https://sh4zam.com/api/vector/shz_vec4_maxv/) | Returns a 4D vector whose components are the pairwise maximums of the two given vectors' components. | | [`shz_vec2_equal`](https://sh4zam.com/api/vector/shz_vec2_equal/) | Returns true if the values of each element within the two 2D vectors are approximately equal based on relative or absolute tolerance. | | [`shz_vec3_equal`](https://sh4zam.com/api/vector/shz_vec3_equal/) | Returns true if the values of each element within the two 3D vectors are approximately equal based on relative or absolute tolerance. | | [`shz_vec4_equal`](https://sh4zam.com/api/vector/shz_vec4_equal/) | Returns true if the values of each element within the two 4D vectors are approximately equal based on relative or absolute tolerance. | | [`shz_vec2_stepv`](https://sh4zam.com/api/vector/shz_vec2_stepv/) | For each component: returns 0.0f if vec\[i\] \< edge\[i\], otherwise 1.0f. | | [`shz_vec3_stepv`](https://sh4zam.com/api/vector/shz_vec3_stepv/) | For each component: returns 0.0f if vec\[i\] \< edge\[i\], otherwise 1.0f. | | [`shz_vec4_stepv`](https://sh4zam.com/api/vector/shz_vec4_stepv/) | For each component: returns 0.0f if vec\[i\] \< edge\[i\], otherwise 1.0f. | | [`shz_vec2_step`](https://sh4zam.com/api/vector/shz_vec2_step/) | For each component: returns 0.0f if vec\[i\] \< edge, otherwise 1.0f. | | [`shz_vec3_step`](https://sh4zam.com/api/vector/shz_vec3_step/) | For each component: returns 0.0f if vec\[i\] \< edge, otherwise 1.0f. | | [`shz_vec4_step`](https://sh4zam.com/api/vector/shz_vec4_step/) | For each component: returns 0.0f if vec\[i\] \< edge, otherwise 1.0f. | | [`shz_vec2_smoothstep`](https://sh4zam.com/api/vector/shz_vec2_smoothstep/) | For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. | | [`shz_vec3_smoothstep`](https://sh4zam.com/api/vector/shz_vec3_smoothstep/) | For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. | | [`shz_vec4_smoothstep`](https://sh4zam.com/api/vector/shz_vec4_smoothstep/) | For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. | | [`shz_vec2_smoothstepv`](https://sh4zam.com/api/vector/shz_vec2_smoothstepv/) | For each component: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. | | [`shz_vec3_smoothstepv`](https://sh4zam.com/api/vector/shz_vec3_smoothstepv/) | For each component i: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. | | [`shz_vec4_smoothstepv`](https://sh4zam.com/api/vector/shz_vec4_smoothstepv/) | For each component i: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. | | [`shz_vec2_smoothstep_safe`](https://sh4zam.com/api/vector/shz_vec2_smoothstep_safe/) | For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. | | [`shz_vec3_smoothstep_safe`](https://sh4zam.com/api/vector/shz_vec3_smoothstep_safe/) | For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. | | [`shz_vec4_smoothstep_safe`](https://sh4zam.com/api/vector/shz_vec4_smoothstep_safe/) | For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. | | [`shz_vec2_smoothstepv_safe`](https://sh4zam.com/api/vector/shz_vec2_smoothstepv_safe/) | For each component: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. Accepts inverse edges. | | [`shz_vec3_smoothstepv_safe`](https://sh4zam.com/api/vector/shz_vec3_smoothstepv_safe/) | For each component i: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. Accepts inverse edges. | | [`shz_vec4_smoothstepv_safe`](https://sh4zam.com/api/vector/shz_vec4_smoothstepv_safe/) | For each component i: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. Accepts inverse edges. | | [`shz_vec2_inv_sqrtf`](https://sh4zam.com/api/vector/shz_vec2_inv_sqrtf/) | Returns a 2D vector whose components are the inverse square root of the given vector's components. | | [`shz_vec3_inv_sqrtf`](https://sh4zam.com/api/vector/shz_vec3_inv_sqrtf/) | Returns a 3D vector whose components are the inverse square root of the given vector's components. | | [`shz_vec4_inv_sqrtf`](https://sh4zam.com/api/vector/shz_vec4_inv_sqrtf/) | Returns a 4D vector whose components are the inverse square root of the given vector's components. | | [`shz_vec2_sqrtf`](https://sh4zam.com/api/vector/shz_vec2_sqrtf/) | Returns a 2D vector whose components are the square root of the given vector's components. | | [`shz_vec3_sqrtf`](https://sh4zam.com/api/vector/shz_vec3_sqrtf/) | Returns a 3D vector whose components are the square root of the given vector's components. | | [`shz_vec4_sqrtf`](https://sh4zam.com/api/vector/shz_vec4_sqrtf/) | Returns a 4D vector whose components are the square root of the given vector's components. | ## Arithmetic Routines for basic vector arithmetic operations. | Symbol | Description | | --- | --- | | [`shz_vec2_add`](https://sh4zam.com/api/vector/shz_vec2_add/) | Returns a 2D vector whose components are the sums of the given vectors' components. | | [`shz_vec3_add`](https://sh4zam.com/api/vector/shz_vec3_add/) | Returns a 3D vector whose components are the sums of the given vectors' components. | | [`shz_vec4_add`](https://sh4zam.com/api/vector/shz_vec4_add/) | Returns a 4D vector whose components are the sums of the given vectors' components. | | [`shz_vec2_sub`](https://sh4zam.com/api/vector/shz_vec2_sub/) | Returns a 2D vector whose components are equal to the values of `vec1` minus `vec2`. | | [`shz_vec3_sub`](https://sh4zam.com/api/vector/shz_vec3_sub/) | Returns a 3D vector whose components are equal to the values of `vec1` minus `vec2`. | | [`shz_vec4_sub`](https://sh4zam.com/api/vector/shz_vec4_sub/) | Returns a 4D vector whose components are equal to the values of `vec1` minus `vec2`. | | [`shz_vec2_mul`](https://sh4zam.com/api/vector/shz_vec2_mul/) | Returns a 2D vector whose component values are those of `vec1` times `vec2`. | | [`shz_vec3_mul`](https://sh4zam.com/api/vector/shz_vec3_mul/) | Returns a 3D vector whose component values are those of `vec1` times `vec2`. | | [`shz_vec4_mul`](https://sh4zam.com/api/vector/shz_vec4_mul/) | Returns a 4D vector whose component values are those of `vec1` times `vec2`. | | [`shz_vec2_div`](https://sh4zam.com/api/vector/shz_vec2_div/) | Returns a 2D vector whose component values are those of `vec1` divided by `vec2`. | | [`shz_vec3_div`](https://sh4zam.com/api/vector/shz_vec3_div/) | Returns a 3D vector whose component values are those of `vec1` divided by `vec2`. | | [`shz_vec4_div`](https://sh4zam.com/api/vector/shz_vec4_div/) | Returns a 4D vector whose component values are those of `vec1` divided by `vec2`. | | [`shz_vec2_scale`](https://sh4zam.com/api/vector/shz_vec2_scale/) | Returns a 2D vector whose component values are those of the given vector multiplied by a factor. | | [`shz_vec3_scale`](https://sh4zam.com/api/vector/shz_vec3_scale/) | Returns a 3D vector whose component values are those of the given vector multiplied by a factor. | | [`shz_vec4_scale`](https://sh4zam.com/api/vector/shz_vec4_scale/) | Returns a 4D vector whose component values are those of the given vector multiplied by a factor. | ## Magnitude Math routines for vector length and normalization. | Symbol | Description | | --- | --- | | [`shz_vec2_magnitude_sqr`](https://sh4zam.com/api/vector/shz_vec2_magnitude_sqr/) | Returns the squared magnitude of the given 2D vector. | | [`shz_vec4_magnitude_sqr`](https://sh4zam.com/api/vector/shz_vec4_magnitude_sqr/) | Returns the squared magnitude of the given 4D vector. | | [`shz_vec3_magnitude_sqr`](https://sh4zam.com/api/vector/shz_vec3_magnitude_sqr/) | Returns the squared magnitude of the given 3D vector. | | [`shz_vec2_magnitude`](https://sh4zam.com/api/vector/shz_vec2_magnitude/) | Returns the magnitude of the given 2D vector. | | [`shz_vec3_magnitude`](https://sh4zam.com/api/vector/shz_vec3_magnitude/) | Returns the magnitude of the given 3D vector. | | [`shz_vec4_magnitude`](https://sh4zam.com/api/vector/shz_vec4_magnitude/) | Returns the magnitude of the given 4D vector. | | [`shz_vec2_magnitude_inv`](https://sh4zam.com/api/vector/shz_vec2_magnitude_inv/) | Returns the inverse magnitude of the given 2D vector. | | [`shz_vec3_magnitude_inv`](https://sh4zam.com/api/vector/shz_vec3_magnitude_inv/) | Returns the inverse magnitude of the given 3D vector. | | [`shz_vec4_magnitude_inv`](https://sh4zam.com/api/vector/shz_vec4_magnitude_inv/) | Returns the inverse magnitude of the given 4D vector. | | [`shz_vec2_normalize`](https://sh4zam.com/api/vector/shz_vec2_normalize/) | Returns a normalized unit vector from the given 2D vector. | | [`shz_vec3_normalize`](https://sh4zam.com/api/vector/shz_vec3_normalize/) | Returns a normalized unit vector from the given 3D vector. | | [`shz_vec4_normalize`](https://sh4zam.com/api/vector/shz_vec4_normalize/) | Returns a normalized unit vector from the given 4D vector. | | [`shz_vec2_normalize_safe`](https://sh4zam.com/api/vector/shz_vec2_normalize_safe/) | SAFELY returns a normalized unit vector from the given 2D vector. | | [`shz_vec3_normalize_safe`](https://sh4zam.com/api/vector/shz_vec3_normalize_safe/) | SAFELY returns a normalized unit vector from the given 3D vector. | | [`shz_vec4_normalize_safe`](https://sh4zam.com/api/vector/shz_vec4_normalize_safe/) | SAFELY returns a normalized unit vector from the given 4D vector. | ## Binary Operations Linear algebra operations performed with multiple vectors. | Symbol | Description | | --- | --- | | [`shz_vec2_dot`](https://sh4zam.com/api/vector/shz_vec2_dot/) | Returns the dot product between the two given 2D vectors. | | [`shz_vec2_dot2`](https://sh4zam.com/api/vector/shz_vec2_dot2/) | Returns the two dot products taken between the 2D vector `l` and 2D vectors `r1` and `r2`. | | [`shz_vec2_dot3`](https://sh4zam.com/api/vector/shz_vec2_dot3/) | Returns the three dot products taken between the 2D vector `l` and 2D vectors `r1`, `r2`, and `r3`. | | [`shz_vec3_dot`](https://sh4zam.com/api/vector/shz_vec3_dot/) | Returns the dot product between the two given 3D vectors. | | [`shz_vec3_dot2`](https://sh4zam.com/api/vector/shz_vec3_dot2/) | Returns the two dot products taken between the 3D vector `l` and 3D vectors `r1` and `r2`. | | [`shz_vec3_dot3`](https://sh4zam.com/api/vector/shz_vec3_dot3/) | Returns the three dot products taken between the 3D vector `l` and 3D vectors `r1`, `r2`, and `r3`. | | [`shz_vec4_dot`](https://sh4zam.com/api/vector/shz_vec4_dot/) | Returns the dot product between the two given 4D vectors. | | [`shz_vec4_dot2`](https://sh4zam.com/api/vector/shz_vec4_dot2/) | Returns the two dot products taken between the 4D vector `l` and 4D vectors `r1` and `r2`. | | [`shz_vec4_dot3`](https://sh4zam.com/api/vector/shz_vec4_dot3/) | Returns the three dot products taken between the 4D vector `l` and 4D vectors `r1`, `r2`, and `r3`. | | [`shz_vec2_distance`](https://sh4zam.com/api/vector/shz_vec2_distance/) | Returns the distance between the two given 2D vectors. | | [`shz_vec3_distance`](https://sh4zam.com/api/vector/shz_vec3_distance/) | Returns the distance between the two given 3D vectors. | | [`shz_vec4_distance`](https://sh4zam.com/api/vector/shz_vec4_distance/) | Returns the distance between the two given 4D vectors. | | [`shz_vec2_distance_sqr`](https://sh4zam.com/api/vector/shz_vec2_distance_sqr/) | Returns the squared-distance between the two given 2D vectors. | | [`shz_vec3_distance_sqr`](https://sh4zam.com/api/vector/shz_vec3_distance_sqr/) | Returns the squared-distance between the two given 3D vectors. | | [`shz_vec4_distance_sqr`](https://sh4zam.com/api/vector/shz_vec4_distance_sqr/) | Returns the squared-distance between the two given 4D vectors. | | [`shz_vec2_move`](https://sh4zam.com/api/vector/shz_vec2_move/) | Returns the given 2D vector, translated towards the `target` by the given `max_distance`. | | [`shz_vec3_move`](https://sh4zam.com/api/vector/shz_vec3_move/) | Returns the given 3D vector, translated towards the `target` by the given `max_distance`. | | [`shz_vec4_move`](https://sh4zam.com/api/vector/shz_vec4_move/) | Returns the given 4D vector, translated towards the `target` by the given `max_distance`. | | [`shz_vec2_lerp`](https://sh4zam.com/api/vector/shz_vec2_lerp/) | Returns a 2D vector that is linearly interpolated from `a` to `b` by the given `0.0f-1.0f` factor, `t`. | | [`shz_vec3_lerp`](https://sh4zam.com/api/vector/shz_vec3_lerp/) | Returns a 3D vector that is linearly interpolated from `a` to `b` by the given `0.0f-1.0f` factor, `t`. | | [`shz_vec4_lerp`](https://sh4zam.com/api/vector/shz_vec4_lerp/) | Returns a 4D vector that is linearly interpolated from `a` to `b` by the given `0.0f-1.0f` factor, `t`. | | [`shz_vec2_reflect`](https://sh4zam.com/api/vector/shz_vec2_reflect/) | Reflects the given 2D `incidence` vector against a surface with the given `normal`, returning the result. | | [`shz_vec3_reflect`](https://sh4zam.com/api/vector/shz_vec3_reflect/) | Reflects the given 3D `incidence` vector against a surface with the given `normal`, returning the result. | | [`shz_vec4_reflect`](https://sh4zam.com/api/vector/shz_vec4_reflect/) | Reflects the given 4D `incidence` vector against a surface with the given `normal`, returning the result. | | [`shz_vec2_refract`](https://sh4zam.com/api/vector/shz_vec2_refract/) | Refracts the given 2D `incidence` vector against a surface with the given `normal` using the given refraction index ratio, `eta`. | | [`shz_vec3_refract`](https://sh4zam.com/api/vector/shz_vec3_refract/) | Refracts the given 3D `incidence` vector against a surface with the given `normal` using the given refraction index ratio, `eta`. | | [`shz_vec4_refract`](https://sh4zam.com/api/vector/shz_vec4_refract/) | Refracts the given 4D `incidence` vector against a surface with the given `normal` using the given refraction index ratio, `eta`. | | [`shz_vec2_cross`](https://sh4zam.com/api/vector/shz_vec2_cross/) | Returns the cross product, as a scalar, between two 2D vectors. | | [`shz_vec3_cross`](https://sh4zam.com/api/vector/shz_vec3_cross/) | Returns the vector produced by taking the cross-product of the two given 3D vectors. | | [`shz_vec2_project`](https://sh4zam.com/api/vector/shz_vec2_project/) | Returns the resulting vector from projecting the given 2D vector along the given (unit) axis. | | [`shz_vec3_project`](https://sh4zam.com/api/vector/shz_vec3_project/) | Returns the resulting vector from projecting the given 3D vector along the given (unit) axis. | | [`shz_vec4_project`](https://sh4zam.com/api/vector/shz_vec4_project/) | Returns the resulting vector from projecting the given 4D vector along the given (unit) axis. | | [`shz_vec2_project_safe`](https://sh4zam.com/api/vector/shz_vec2_project_safe/) | Returns the resulting vector from projecting the given 2D vector along the given (unit) axis. | | [`shz_vec3_project_safe`](https://sh4zam.com/api/vector/shz_vec3_project_safe/) | Returns the resulting vector from projecting the given 3D vector along the given (unit) axis. | | [`shz_vec4_project_safe`](https://sh4zam.com/api/vector/shz_vec4_project_safe/) | Returns the resulting vector from projecting the given 4D vector along the given (unit) axis. | | [`shz_vec3_reject`](https://sh4zam.com/api/vector/shz_vec3_reject/) | Returns the rejection of the given vector, `vec`, onto another vector, `onto`. | ## Miscellaneous Other specialized vector routines. | Symbol | Description | | --- | --- | | [`shz_vec3_triple`](https://sh4zam.com/api/vector/shz_vec3_triple/) | Returns the 3D vector "triple product" between vector's `a`, `b`, and `c`. | | [`shz_vec3_perp`](https://sh4zam.com/api/vector/shz_vec3_perp/) | Returns a vector which is perpendicular to the given vector. | | [`shz_vec3_barycenter`](https://sh4zam.com/api/vector/shz_vec3_barycenter/) | Computes barycentric coordinates `` for point p, within the plane of the triangle with vertices `a`, `b`, and `c`. | | [`shz_vec3_orthonormalize`](https://sh4zam.com/api/vector/shz_vec3_orthonormalize/) | Returns 2 3D vectors which are normalized and orthogonal to the two input vectors. | | [`shz_vec3_cubic_hermite`](https://sh4zam.com/api/vector/shz_vec3_cubic_hermite/) | Calculates the cubic hermite interpolation between two vectors and their tangents. | ## Angles Routines for working with vectors and angles. | Symbol | Description | | --- | --- | | [`shz_vec2_angle_between`](https://sh4zam.com/api/vector/shz_vec2_angle_between/) | Returns the angle formed between the given 2D vectors in radians. | | [`shz_vec3_angle_between`](https://sh4zam.com/api/vector/shz_vec3_angle_between/) | Returns the angle formed between the given 3D vectors in radians. | | [`shz_vec2_angle`](https://sh4zam.com/api/vector/shz_vec2_angle/) | Returns the angle formed between the positive X axis and the given 2D vector, in radians. | | [`shz_vec3_angles`](https://sh4zam.com/api/vector/shz_vec3_angles/) | Returns the angles formed between the positive X axis and the given 3D vector, in radians. | | [`shz_vec2_from_sincos`](https://sh4zam.com/api/vector/shz_vec2_from_sincos/) | Returns the 2D unit vector representing a rotation from the positive X axis. | | [`shz_vec3_from_sincos`](https://sh4zam.com/api/vector/shz_vec3_from_sincos/) | Returns the 3D unit vector representing the given rotation angles relative to the positive X axis. | | [`shz_vec2_from_angle`](https://sh4zam.com/api/vector/shz_vec2_from_angle/) | Returns the 2D unit vector representing a rotation from the positive X axis in radians. | | [`shz_vec3_from_angles`](https://sh4zam.com/api/vector/shz_vec3_from_angles/) | Returns the 3D unit vector representing the given rotation angles relative to the positive X axis in radians. | | [`shz_vec2_from_angle_deg`](https://sh4zam.com/api/vector/shz_vec2_from_angle_deg/) | Returns the 2D unit vector representing a rotation from the positive X axis in degrees. | | [`shz_vec3_from_angles_deg`](https://sh4zam.com/api/vector/shz_vec3_from_angles_deg/) | Returns the 3D unit vector representing the given rotation angles relative to the positive X axis in degrees. | | [`shz_vec2_rotate`](https://sh4zam.com/api/vector/shz_vec2_rotate/) | Rotates the given 2D vector about the Z axis by the given angle in radians. | | [`shz_vec3_rotate_x`](https://sh4zam.com/api/vector/shz_vec3_rotate_x/) | Rotates the given 3D vector about the X axis by the given angle in radians. | | [`shz_vec3_rotate_y`](https://sh4zam.com/api/vector/shz_vec3_rotate_y/) | Rotates the given 3D vector about the Y axis by the given angle in radians. | | [`shz_vec3_rotate_z`](https://sh4zam.com/api/vector/shz_vec3_rotate_z/) | Rotates the given 3D vector about the Z axis by the given angle in radians. | ## Extending Routines for extending vectors into other dimensions. | Symbol | Description | | --- | --- | | [`shz_vec2_vec3`](https://sh4zam.com/api/vector/shz_vec2_vec3/) | Extends a 2D vector to 3D, using `z` as the value of the Z component. | | [`shz_vec2_vec4`](https://sh4zam.com/api/vector/shz_vec2_vec4/) | Extends a 2D vector to 4D, using `z` and `w` as the values of the Z and W components. | | [`shz_vec3_vec4`](https://sh4zam.com/api/vector/shz_vec3_vec4/) | Extends a 3D vector to 4D, using `w` as the value of the W component. | ## Swizzling Routines for swizzling the order of a vector's components. | Symbol | Description | | --- | --- | | [`shz_vec2_swizzle`](https://sh4zam.com/api/vector/shz_vec2_swizzle/) | Returns a 2D vector whose elements are equal to the source vector's values at the given indices. | | [`shz_vec3_swizzle`](https://sh4zam.com/api/vector/shz_vec3_swizzle/) | Returns a 3D vector whose elements are equal to the source vector's values at the given indices. | | [`shz_vec4_swizzle`](https://sh4zam.com/api/vector/shz_vec4_swizzle/) | Returns a new 2D vector whose elements are equal to the source vector's values at the given indices. | ## Types | Symbol | Description | | --- | --- | | [`shz_vec2_t`](https://sh4zam.com/api/vector/shz_vec2_t/) | 2D Vector type | | [`shz_vec2`](https://sh4zam.com/api/vector/shz_vec2/) | Alternate typedef for the [`shz_vec2`](https://sh4zam.com/api/vector/shz_vec2/) struct for those who hate POSIX-style. | | [`shz_vec3_t`](https://sh4zam.com/api/vector/shz_vec3_t/) | 3D Vector type | | [`shz_vec3`](https://sh4zam.com/api/vector/shz_vec3/) | Alternate typedef for the [`shz_vec3`](https://sh4zam.com/api/vector/shz_vec3/) struct for those who hate POSIX-style. | | [`shz_vec4_t`](https://sh4zam.com/api/vector/shz_vec4_t/) | 4D Vector type | | [`shz_vec4`](https://sh4zam.com/api/vector/shz_vec4/) | Alternate typedef for the [`shz_vec4`](https://sh4zam.com/api/vector/shz_vec4/) struct for those who hate POSIX-style. | --- # shz_vec_abs Source: https://sh4zam.com/api/vector/shz_vec_abs/ ```c #define shz_vec_abs(vec) ``` C type-generic vector absolute value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:761`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L761) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_add Source: https://sh4zam.com/api/vector/shz_vec_add/ ```c #define shz_vec_add(vec1, vec2) ``` C type-generic vector addition. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** [`shz::operator+`](https://sh4zam.com/api/cpp/#shzoperator+) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:810`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L810) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_angle_between Source: https://sh4zam.com/api/vector/shz_vec_angle_between/ ```c #define shz_vec_angle_between(vec1, vec2) ``` C type-generic angle between two vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** [`shz::vec4::angle_between`](https://sh4zam.com/api/cpp/vec4/#angle_between) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:969`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L969) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_angles Source: https://sh4zam.com/api/vector/shz_vec_angles/ ```c #define shz_vec_angles(vec) ``` C type-generic angle-from-vector extraction. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** [`shz::vec4::angles`](https://sh4zam.com/api/cpp/vec4/#angles) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:963`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L963) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_ceil Source: https://sh4zam.com/api/vector/shz_vec_ceil/ ```c #define shz_vec_ceil(vec) ``` C type-generic component-wise ceil. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:989`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L989) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_clamp Source: https://sh4zam.com/api/vector/shz_vec_clamp/ ```c #define shz_vec_clamp(vec, min, max) ``` C type-generic vector minimum value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `min` | | | | `max` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:796`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L796) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_cross Source: https://sh4zam.com/api/vector/shz_vec_cross/ ```c #define shz_vec_cross(vec1, vec2) ``` C type-generic vector cross-product. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:943`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L943) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_distance_sqr Source: https://sh4zam.com/api/vector/shz_vec_distance_sqr/ ```c #define shz_vec_distance_sqr(vec1, vec2) ``` C type-generic vector squared distance. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:915`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L915) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_distance Source: https://sh4zam.com/api/vector/shz_vec_distance/ ```c #define shz_vec_distance(vec1, vec2) ``` C type-generic vector distance. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:901`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L901) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_div Source: https://sh4zam.com/api/vector/shz_vec_div/ ```c #define shz_vec_div(vec1, vec2) ``` C type-generic vector division. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** [`shz::operator/`](https://sh4zam.com/api/cpp/#shzoperator/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:831`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L831) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_dot Source: https://sh4zam.com/api/vector/shz_vec_dot/ ```c #define shz_vec_dot(vec1, vec2) ``` C type-generic vector dot product. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:845`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L845) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_dot2 Source: https://sh4zam.com/api/vector/shz_vec_dot2/ ```c #define shz_vec_dot2(l, r1, r2) ``` C type-generic vector chained double dot product. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | | | | `r1` | | | | `r2` | | | ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:852`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L852) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_dot3 Source: https://sh4zam.com/api/vector/shz_vec_dot3/ ```c #define shz_vec_dot3(l, r1, r2, r3) ``` C type-generic vector chained triple dot product. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | | | | `r1` | | | | `r2` | | | | `r3` | | | ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:859`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L859) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_equal Source: https://sh4zam.com/api/vector/shz_vec_equal/ ```c #define shz_vec_equal(vec1, vec2) ``` C type-generic vector equals. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:803`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L803) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_floor Source: https://sh4zam.com/api/vector/shz_vec_floor/ ```c #define shz_vec_floor(vec) ``` C type-generic component-wise floor. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:982`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L982) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_fract Source: https://sh4zam.com/api/vector/shz_vec_fract/ ```c #define shz_vec_fract(vec) ``` C type-generic component-wise fract. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1003`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1003) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_inv_sqrtf Source: https://sh4zam.com/api/vector/shz_vec_inv_sqrtf/ ```c #define shz_vec_inv_sqrtf(vec) ``` C type-generic inv_sqrtf. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1038`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1038) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_inv Source: https://sh4zam.com/api/vector/shz_vec_inv/ ```c #define shz_vec_inv(vec) ``` C type-generic vector inversion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:775`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L775) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_lerp Source: https://sh4zam.com/api/vector/shz_vec_lerp/ ```c #define shz_vec_lerp(vec1, vec2, t) ``` C type-generic linear interpolation between two vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | | `t` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:922`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L922) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_magnitude_inv Source: https://sh4zam.com/api/vector/shz_vec_magnitude_inv/ ```c #define shz_vec_magnitude_inv(vec) ``` C type-generic vector inverse magnitude. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:880`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L880) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_magnitude_sqr Source: https://sh4zam.com/api/vector/shz_vec_magnitude_sqr/ ```c #define shz_vec_magnitude_sqr(vec) ``` C type-generic vector squared magnitude. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:866`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L866) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_magnitude Source: https://sh4zam.com/api/vector/shz_vec_magnitude/ ```c #define shz_vec_magnitude(vec) ``` C type-generic vector magnitude. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:873`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L873) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_max Source: https://sh4zam.com/api/vector/shz_vec_max/ ```c #define shz_vec_max(vec) ``` C type-generic vector maximum value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:782`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L782) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_maxv Source: https://sh4zam.com/api/vector/shz_vec_maxv/ ```c #define shz_vec_maxv(a, b) ``` C type-generic pairwise maximum. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | | | | `b` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1031`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1031) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_min Source: https://sh4zam.com/api/vector/shz_vec_min/ ```c #define shz_vec_min(vec) ``` C type-generic vector minimum value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:789`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L789) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_minv Source: https://sh4zam.com/api/vector/shz_vec_minv/ ```c #define shz_vec_minv(a, b) ``` C type-generic pairwise minimum. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | | | | `b` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1024`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1024) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_move Source: https://sh4zam.com/api/vector/shz_vec_move/ ```c #define shz_vec_move(vec, target, maxdist) ``` C type-generic vector move. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `target` | | | | `maxdist` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:908`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L908) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_mul Source: https://sh4zam.com/api/vector/shz_vec_mul/ ```c #define shz_vec_mul(vec1, vec2) ``` C type-generic vector multiplication. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** [`shz::operator*`](https://sh4zam.com/api/cpp/#shzoperator*) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:824`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L824) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_neg Source: https://sh4zam.com/api/vector/shz_vec_neg/ ```c #define shz_vec_neg(vec) ``` C type-generic vector negation. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:768`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L768) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_normalize_safe Source: https://sh4zam.com/api/vector/shz_vec_normalize_safe/ ```c #define shz_vec_normalize_safe(vec) ``` C type-generic safe vector normalization. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## 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:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:894`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L894) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_normalize Source: https://sh4zam.com/api/vector/shz_vec_normalize/ ```c #define shz_vec_normalize(vec) ``` C type-generic vector normalization. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:887`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L887) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_project_safe Source: https://sh4zam.com/api/vector/shz_vec_project_safe/ ```c #define shz_vec_project_safe(vec1, vec2) ``` C type-generic safe vector projection. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## 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:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:956`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L956) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_project Source: https://sh4zam.com/api/vector/shz_vec_project/ ```c #define shz_vec_project(vec1, vec2) ``` C type-generic vector projection. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:949`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L949) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_reflect Source: https://sh4zam.com/api/vector/shz_vec_reflect/ ```c #define shz_vec_reflect(incidence, normal) ``` C type-generic vector reflection. ## Parameters | Name | Type | Description | | --- | --- | --- | | `incidence` | | | | `normal` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:929`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L929) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_refract Source: https://sh4zam.com/api/vector/shz_vec_refract/ ```c #define shz_vec_refract(incidence, normal, eta) ``` C type-generic vector refraction. ## Parameters | Name | Type | Description | | --- | --- | --- | | `incidence` | | | | `normal` | | | | `eta` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:936`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L936) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_round Source: https://sh4zam.com/api/vector/shz_vec_round/ ```c #define shz_vec_round(vec) ``` C type-generic component-wise round. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:996`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L996) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_saturate Source: https://sh4zam.com/api/vector/shz_vec_saturate/ ```c #define shz_vec_saturate(vec) ``` C type-generic component-wise saturate. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1017`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1017) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_scale Source: https://sh4zam.com/api/vector/shz_vec_scale/ ```c #define shz_vec_scale(vec, factor) ``` C type-generic vector scaling. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `factor` | | | ## Availability - **C++ equivalent:** [`shz::operator*`](https://sh4zam.com/api/cpp/#shzoperator*), [`shz::operator/`](https://sh4zam.com/api/cpp/#shzoperator/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:838`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L838) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_sign Source: https://sh4zam.com/api/vector/shz_vec_sign/ ```c #define shz_vec_sign(vec) ``` C type-generic component-wise sign. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1010`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1010) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_smoothstep_safe Source: https://sh4zam.com/api/vector/shz_vec_smoothstep_safe/ ```c #define shz_vec_smoothstep_safe(vec, edge0, edge1) ``` C type-generic smoothstep_safe. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `edge0` | | | | `edge1` | | | ## 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:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1087`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1087) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_smoothstep Source: https://sh4zam.com/api/vector/shz_vec_smoothstep/ ```c #define shz_vec_smoothstep(vec, edge0, edge1) ``` C type-generic smoothstep. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `edge0` | | | | `edge1` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1073`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1073) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_smoothstepv_safe Source: https://sh4zam.com/api/vector/shz_vec_smoothstepv_safe/ ```c #define shz_vec_smoothstepv_safe(vec, edge0, edge1) ``` C type-generic component-wise smoothstep_safe. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `edge0` | | | | `edge1` | | | ## 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:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1080`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1080) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_smoothstepv Source: https://sh4zam.com/api/vector/shz_vec_smoothstepv/ ```c #define shz_vec_smoothstepv(vec, edge0, edge1) ``` C type-generic component-wise smoothstep. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `edge0` | | | | `edge1` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1066`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1066) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_sqrtf Source: https://sh4zam.com/api/vector/shz_vec_sqrtf/ ```c #define shz_vec_sqrtf(vec) ``` C type-generic sqrtf. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1045`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1045) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_step Source: https://sh4zam.com/api/vector/shz_vec_step/ ```c #define shz_vec_step(vec, edge) ``` C type-generic step. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `edge` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1059`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1059) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_stepv Source: https://sh4zam.com/api/vector/shz_vec_stepv/ ```c #define shz_vec_stepv(vec, edge) ``` C type-generic component-wise step. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `edge` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:1052`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L1052) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_sub Source: https://sh4zam.com/api/vector/shz_vec_sub/ ```c #define shz_vec_sub(vec1, vec2) ``` C type-generic vector subtraction. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | | | | `vec2` | | | ## Availability - **C++ equivalent:** [`shz::operator-`](https://sh4zam.com/api/cpp/#shzoperator-) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:817`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L817) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec_swizzle Source: https://sh4zam.com/api/vector/shz_vec_swizzle/ ```c #define shz_vec_swizzle(vec, ...) ``` C type-generic vector swizzling. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | | | | `...` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:975`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L975) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Type-Generic Routines" --- # shz_vec2_abs Source: https://sh4zam.com/api/vector/shz_vec2_abs/ ```c SHZ_INLINE shz_vec2_t shz_vec2_abs(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the absolute values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::abs`](https://sh4zam.com/api/cpp/vec2/#abs) - **Type-generic form:** [`shz_vec_abs()`](https://sh4zam.com/api/vector/shz_vec_abs/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:138`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L138) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_add Source: https://sh4zam.com/api/vector/shz_vec2_add/ ```c SHZ_INLINE shz_vec2_t shz_vec2_add(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the sums of the given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_add()`](https://sh4zam.com/api/vector/shz_vec_add/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:353`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L353) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec2_angle_between Source: https://sh4zam.com/api/vector/shz_vec2_angle_between/ ```c SHZ_INLINE float shz_vec2_angle_between(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns the angle formed between the given 2D vectors in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::angle_between`](https://sh4zam.com/api/cpp/vec2/#angle_between) - **Type-generic form:** [`shz_vec_angle_between()`](https://sh4zam.com/api/vector/shz_vec_angle_between/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:621`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L621) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec2_angle Source: https://sh4zam.com/api/vector/shz_vec2_angle/ ```c SHZ_INLINE float shz_vec2_angle(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns the angle formed between the positive X axis and the given 2D vector, in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::angles`](https://sh4zam.com/api/cpp/vec2/#angles) - **Type-generic form:** [`shz_vec_angles()`](https://sh4zam.com/api/vector/shz_vec_angles/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:627`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L627) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec2_ceil Source: https://sh4zam.com/api/vector/shz_vec2_ceil/ ```c SHZ_INLINE shz_vec2_t shz_vec2_ceil(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the ceil of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::ceil`](https://sh4zam.com/api/cpp/vec2/#ceil) - **Type-generic form:** [`shz_vec_ceil()`](https://sh4zam.com/api/vector/shz_vec_ceil/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:201`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L201) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_clamp Source: https://sh4zam.com/api/vector/shz_vec2_clamp/ > Clamps the values of the given 2D vec between min and max, returning a new vector ```c SHZ_INLINE shz_vec2_t shz_vec2_clamp(shz_vec2_t vec, float min, float max) SHZ_NOEXCEPT; ``` Clamps the values of the given 2D `vec` between `min` and `max`, returning a new vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `min` | `float` | | | `max` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::clamp`](https://sh4zam.com/api/cpp/vec2/#clamp) - **Type-generic form:** [`shz_vec_clamp()`](https://sh4zam.com/api/vector/shz_vec_clamp/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:183`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L183) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_cross Source: https://sh4zam.com/api/vector/shz_vec2_cross/ ```c SHZ_INLINE float shz_vec2_cross(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns the cross product, as a scalar, between two 2D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `float` ## Notes - The definition of the cross-product is ambiguous in 2D space, but the geometric interpretation here is that the result is the magnitude of the orthogonal vector created from the given two along the Z-axis. ## Availability - **C++ equivalent:** [`shz::vec2::cross`](https://sh4zam.com/api/cpp/vec2/#cross) - **Type-generic form:** [`shz_vec_cross()`](https://sh4zam.com/api/vector/shz_vec_cross/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:553`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L553) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_deref Source: https://sh4zam.com/api/vector/shz_vec2_deref/ > Dereferences the given pointer to a sequence of 2 floats as a shz_vec2_t ```c #define shz_vec2_deref(ptr) (*((SHZ_ALIASING shz_vec2_t*)(ptr))) ``` Dereferences the given pointer to a sequence of 2 floats as a [`shz_vec2_t`](https://sh4zam.com/api/vector/shz_vec2_t/). ## Parameters | Name | Type | Description | | --- | --- | --- | | `ptr` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:725`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L725) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec2_distance_sqr Source: https://sh4zam.com/api/vector/shz_vec2_distance_sqr/ ```c SHZ_INLINE float shz_vec2_distance_sqr(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns the squared-distance between the two given 2D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::distance_sqr`](https://sh4zam.com/api/cpp/vec2/#distance_sqr) - **Type-generic form:** [`shz_vec_distance_sqr()`](https://sh4zam.com/api/vector/shz_vec_distance_sqr/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:502`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L502) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_distance Source: https://sh4zam.com/api/vector/shz_vec2_distance/ ```c SHZ_INLINE float shz_vec2_distance(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns the distance between the two given 2D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::distance`](https://sh4zam.com/api/cpp/vec2/#distance) - **Type-generic form:** [`shz_vec_distance()`](https://sh4zam.com/api/vector/shz_vec_distance/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:493`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L493) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_div Source: https://sh4zam.com/api/vector/shz_vec2_div/ > Returns a 2D vector whose component values are those of vec1 divided by vec2 ```c SHZ_INLINE shz_vec2_t shz_vec2_div(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns a 2D vector whose component values are those of `vec1` divided by `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_div()`](https://sh4zam.com/api/vector/shz_vec_div/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:380`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L380) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec2_dot Source: https://sh4zam.com/api/vector/shz_vec2_dot/ ```c SHZ_INLINE float shz_vec2_dot(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns the dot product between the two given 2D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot()`](https://sh4zam.com/api/vector/shz_vec_dot/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:466`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L466) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_dot2 Source: https://sh4zam.com/api/vector/shz_vec2_dot2/ > Returns the two dot products taken between the 2D vector l and 2D vectors r1 and r2 ```c SHZ_INLINE shz_vec2_t shz_vec2_dot2(shz_vec2_t l, shz_vec2_t r1, shz_vec2_t r2) SHZ_NOEXCEPT; ``` Returns the two dot products taken between the 2D vector `l` and 2D vectors `r1` and `r2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | `shz_vec2_t` | | | `r1` | `shz_vec2_t` | | | `r2` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot2()`](https://sh4zam.com/api/vector/shz_vec_dot2/) - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:469`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L469) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_dot3 Source: https://sh4zam.com/api/vector/shz_vec2_dot3/ > Returns the three dot products taken between the 2D vector l and 2D vectors r1, r2, and r3 ```c SHZ_INLINE shz_vec3_t shz_vec2_dot3(shz_vec2_t l, shz_vec2_t r1, shz_vec2_t r2, shz_vec2_t r3) SHZ_NOEXCEPT; ``` Returns the three dot products taken between the 2D vector `l` and 2D vectors `r1`, `r2`, and `r3`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | `shz_vec2_t` | | | `r1` | `shz_vec2_t` | | | `r2` | `shz_vec2_t` | | | `r3` | `shz_vec2_t` | | ## Returns `shz_vec3_t` ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot3()`](https://sh4zam.com/api/vector/shz_vec_dot3/) - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:472`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L472) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_equal Source: https://sh4zam.com/api/vector/shz_vec2_equal/ ```c SHZ_INLINE bool shz_vec2_equal(shz_vec2_t a, shz_vec2_t b) SHZ_NOEXCEPT; ``` Returns true if the values of each element within the two 2D vectors are approximately equal based on relative or absolute tolerance. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec2_t` | | | `b` | `shz_vec2_t` | | ## Returns `bool` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_equal()`](https://sh4zam.com/api/vector/shz_vec_equal/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:264`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L264) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_fill Source: https://sh4zam.com/api/vector/shz_vec2_fill/ > Returns a 2D vector with the value of each component equal to v ```c SHZ_INLINE shz_vec2_t shz_vec2_fill(float v) SHZ_NOEXCEPT; ``` Returns a 2D vector with the value of each component equal to `v`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `v` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:122`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L122) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Initializers" --- # shz_vec2_floor Source: https://sh4zam.com/api/vector/shz_vec2_floor/ ```c SHZ_INLINE shz_vec2_t shz_vec2_floor(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the floor of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::floor`](https://sh4zam.com/api/cpp/vec2/#floor) - **Type-generic form:** [`shz_vec_floor()`](https://sh4zam.com/api/vector/shz_vec_floor/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:192`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L192) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_fract Source: https://sh4zam.com/api/vector/shz_vec2_fract/ ```c SHZ_INLINE shz_vec2_t shz_vec2_fract(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the fractional parts of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::fract`](https://sh4zam.com/api/cpp/vec2/#fract) - **Type-generic form:** [`shz_vec_fract()`](https://sh4zam.com/api/vector/shz_vec_fract/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:219`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L219) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_from_angle_deg Source: https://sh4zam.com/api/vector/shz_vec2_from_angle_deg/ ```c SHZ_INLINE shz_vec2_t shz_vec2_from_angle_deg(float degrees) SHZ_NOEXCEPT; ``` Returns the 2D unit vector representing a rotation from the positive X axis in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `degrees` | `float` | | ## Returns `shz_vec2_t` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::vec2::from_angle_deg`](https://sh4zam.com/api/cpp/vec2/#from_angle_deg) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:645`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L645) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec2_from_angle Source: https://sh4zam.com/api/vector/shz_vec2_from_angle/ ```c SHZ_INLINE shz_vec2_t shz_vec2_from_angle(float radians) SHZ_NOEXCEPT; ``` Returns the 2D unit vector representing a rotation from the positive X axis in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::from_angle`](https://sh4zam.com/api/cpp/vec2/#from_angle) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:639`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L639) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec2_from_sincos Source: https://sh4zam.com/api/vector/shz_vec2_from_sincos/ ```c SHZ_INLINE shz_vec2_t shz_vec2_from_sincos(shz_sincos_t sincos) SHZ_NOEXCEPT; ``` Returns the 2D unit vector representing a rotation from the positive X axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `sincos` | `shz_sincos_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:633`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L633) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec2_from Source: https://sh4zam.com/api/vector/shz_vec2_from/ > Converts the given value or expression to the equivalent 2D SH4ZAM vector value ```c #define shz_vec2_from(value) SHZ_CONVERT(shz_vec2_t, value) ``` Converts the given `value` or expression to the equivalent 2D SH4ZAM vector value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:734`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L734) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec2_init Source: https://sh4zam.com/api/vector/shz_vec2_init/ > Returns a 2D vector with the given x, and y coordinates ```c SHZ_INLINE shz_vec2_t shz_vec2_init(float x, float y) SHZ_NOEXCEPT; ``` Returns a 2D vector with the given `x`, and `y` coordinates. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:113`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L113) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Initializers" --- # shz_vec2_inv_sqrtf Source: https://sh4zam.com/api/vector/shz_vec2_inv_sqrtf/ ```c SHZ_INLINE shz_vec2_t shz_vec2_inv_sqrtf(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the inverse square root of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::inv_sqrtf`](https://sh4zam.com/api/cpp/vec2/#inv_sqrtf) - **Type-generic form:** [`shz_vec_inv_sqrtf()`](https://sh4zam.com/api/vector/shz_vec_inv_sqrtf/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:327`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L327) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_inv Source: https://sh4zam.com/api/vector/shz_vec2_inv/ ```c SHZ_INLINE shz_vec2_t shz_vec2_inv(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns the 2D vector whose components have been inverted or reciprocated. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::inv`](https://sh4zam.com/api/cpp/vec2/#inv) - **Type-generic form:** [`shz_vec_inv()`](https://sh4zam.com/api/vector/shz_vec_inv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:156`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L156) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_lerp Source: https://sh4zam.com/api/vector/shz_vec2_lerp/ > Returns a 2D vector that is linearly interpolated from a to b by the given 0.0f-1.0f factor, t ```c SHZ_INLINE shz_vec2_t shz_vec2_lerp(shz_vec2_t a, shz_vec2_t b, float t) SHZ_NOEXCEPT; ``` Returns a 2D vector that is linearly interpolated from `a` to `b` by the given `0.0f-1.0f` factor, `t`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec2_t` | | | `b` | `shz_vec2_t` | | | `t` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::lerp`](https://sh4zam.com/api/cpp/vec2/#lerp) - **Type-generic form:** [`shz_vec_lerp()`](https://sh4zam.com/api/vector/shz_vec_lerp/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:520`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L520) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_magnitude_inv Source: https://sh4zam.com/api/vector/shz_vec2_magnitude_inv/ ```c SHZ_INLINE float shz_vec2_magnitude_inv(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns the inverse magnitude of the given 2D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::magnitude_inv`](https://sh4zam.com/api/cpp/vec2/#magnitude_inv) - **Type-generic form:** [`shz_vec_magnitude_inv()`](https://sh4zam.com/api/vector/shz_vec_magnitude_inv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:423`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L423) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec2_magnitude_sqr Source: https://sh4zam.com/api/vector/shz_vec2_magnitude_sqr/ ```c SHZ_INLINE float shz_vec2_magnitude_sqr(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns the squared magnitude of the given 2D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::magnitude_sqr`](https://sh4zam.com/api/cpp/vec2/#magnitude_sqr) - **Type-generic form:** [`shz_vec_magnitude_sqr()`](https://sh4zam.com/api/vector/shz_vec_magnitude_sqr/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:405`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L405) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec2_magnitude Source: https://sh4zam.com/api/vector/shz_vec2_magnitude/ ```c SHZ_INLINE float shz_vec2_magnitude(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns the magnitude of the given 2D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::magnitude`](https://sh4zam.com/api/cpp/vec2/#magnitude) - **Type-generic form:** [`shz_vec_magnitude()`](https://sh4zam.com/api/vector/shz_vec_magnitude/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:414`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L414) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec2_max Source: https://sh4zam.com/api/vector/shz_vec2_max/ ```c SHZ_INLINE float shz_vec2_max(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns the maximum value of both of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::max`](https://sh4zam.com/api/cpp/vec2/#max) - **Type-generic form:** [`shz_vec_max()`](https://sh4zam.com/api/vector/shz_vec_max/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:165`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L165) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_maxv Source: https://sh4zam.com/api/vector/shz_vec2_maxv/ ```c SHZ_INLINE shz_vec2_t shz_vec2_maxv(shz_vec2_t a, shz_vec2_t b) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the pairwise maximums of the two given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec2_t` | | | `b` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::maxv`](https://sh4zam.com/api/cpp/vec2/#maxv) - **Type-generic form:** [`shz_vec_maxv()`](https://sh4zam.com/api/vector/shz_vec_maxv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:255`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L255) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_min Source: https://sh4zam.com/api/vector/shz_vec2_min/ ```c SHZ_INLINE float shz_vec2_min(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Retuns the minimum value of both of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec2::min`](https://sh4zam.com/api/cpp/vec2/#min) - **Type-generic form:** [`shz_vec_min()`](https://sh4zam.com/api/vector/shz_vec_min/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:174`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L174) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_minv Source: https://sh4zam.com/api/vector/shz_vec2_minv/ ```c SHZ_INLINE shz_vec2_t shz_vec2_minv(shz_vec2_t a, shz_vec2_t b) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the pairwise minimums of the two given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec2_t` | | | `b` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::minv`](https://sh4zam.com/api/cpp/vec2/#minv) - **Type-generic form:** [`shz_vec_minv()`](https://sh4zam.com/api/vector/shz_vec_minv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:246`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L246) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_move Source: https://sh4zam.com/api/vector/shz_vec2_move/ > Returns the given 2D vector, translated towards the target by the given max_distance ```c SHZ_INLINE shz_vec2_t shz_vec2_move(shz_vec2_t vec, shz_vec2_t target, float max_distance) SHZ_NOEXCEPT; ``` Returns the given 2D vector, translated towards the `target` by the given `max_distance`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `target` | `shz_vec2_t` | | | `max_distance` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::move`](https://sh4zam.com/api/cpp/vec2/#move) - **Type-generic form:** [`shz_vec_move()`](https://sh4zam.com/api/vector/shz_vec_move/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:511`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L511) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_mul Source: https://sh4zam.com/api/vector/shz_vec2_mul/ > Returns a 2D vector whose component values are those of vec1 times vec2 ```c SHZ_INLINE shz_vec2_t shz_vec2_mul(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns a 2D vector whose component values are those of `vec1` times `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_mul()`](https://sh4zam.com/api/vector/shz_vec_mul/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:371`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L371) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec2_neg Source: https://sh4zam.com/api/vector/shz_vec2_neg/ ```c SHZ_INLINE shz_vec2_t shz_vec2_neg(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the negative values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::neg`](https://sh4zam.com/api/cpp/vec2/#neg) - **Type-generic form:** [`shz_vec_neg()`](https://sh4zam.com/api/vector/shz_vec_neg/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:147`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L147) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # 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" --- # shz_vec2_normalize Source: https://sh4zam.com/api/vector/shz_vec2_normalize/ ```c SHZ_INLINE shz_vec2_t shz_vec2_normalize(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a normalized unit vector from the given 2D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::direction`](https://sh4zam.com/api/cpp/vec2/#direction), [`shz::vec2::normalize`](https://sh4zam.com/api/cpp/vec2/#normalize), [`shz::vec2::normalized`](https://sh4zam.com/api/cpp/vec2/#normalized) - **Type-generic form:** [`shz_vec_normalize()`](https://sh4zam.com/api/vector/shz_vec_normalize/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:432`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L432) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # 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" --- # shz_vec2_project Source: https://sh4zam.com/api/vector/shz_vec2_project/ ```c SHZ_INLINE shz_vec2_t shz_vec2_project(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` ## Availability - **C++ equivalent:** [`shz::vec2::project`](https://sh4zam.com/api/cpp/vec2/#project) - **Type-generic form:** [`shz_vec_project()`](https://sh4zam.com/api/vector/shz_vec_project/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:559`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L559) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_reflect Source: https://sh4zam.com/api/vector/shz_vec2_reflect/ > Reflects the given 2D incidence vector against a surface with the given normal, returning the result ```c SHZ_INLINE shz_vec2_t shz_vec2_reflect(shz_vec2_t incidence, shz_vec2_t normal) SHZ_NOEXCEPT; ``` Reflects the given 2D `incidence` vector against a surface with the given `normal`, returning the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `incidence` | `shz_vec2_t` | | | `normal` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::reflect`](https://sh4zam.com/api/cpp/vec2/#reflect) - **Type-generic form:** [`shz_vec_reflect()`](https://sh4zam.com/api/vector/shz_vec_reflect/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:529`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L529) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_refract Source: https://sh4zam.com/api/vector/shz_vec2_refract/ > Refracts the given 2D incidence vector against a surface with the given normal using the given refraction index ratio, eta ```c SHZ_INLINE shz_vec2_t shz_vec2_refract(shz_vec2_t incidence, shz_vec2_t normal, float eta) SHZ_NOEXCEPT; ``` Refracts the given 2D `incidence` vector against a surface with the given `normal` using the given refraction index ratio, `eta`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `incidence` | `shz_vec2_t` | | | `normal` | `shz_vec2_t` | | | `eta` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::refract`](https://sh4zam.com/api/cpp/vec2/#refract) - **Type-generic form:** [`shz_vec_refract()`](https://sh4zam.com/api/vector/shz_vec_refract/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:538`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L538) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec2_rotate Source: https://sh4zam.com/api/vector/shz_vec2_rotate/ ```c SHZ_INLINE shz_vec2_t shz_vec2_rotate(shz_vec2_t vec, float radians) SHZ_NOEXCEPT; ``` Rotates the given 2D vector about the Z axis by the given angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `radians` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::rotate`](https://sh4zam.com/api/cpp/vec2/#rotate) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:651`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L651) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec2_round Source: https://sh4zam.com/api/vector/shz_vec2_round/ ```c SHZ_INLINE shz_vec2_t shz_vec2_round(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the rounded values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::round`](https://sh4zam.com/api/cpp/vec2/#round) - **Type-generic form:** [`shz_vec_round()`](https://sh4zam.com/api/vector/shz_vec_round/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:210`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L210) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_saturate Source: https://sh4zam.com/api/vector/shz_vec2_saturate/ > Returns a 2D vector whose components are saturated (clamped to [0, 1]) values of the given vector's components ```c SHZ_INLINE shz_vec2_t shz_vec2_saturate(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are saturated (clamped to \[0, 1\]) values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::saturate`](https://sh4zam.com/api/cpp/vec2/#saturate) - **Type-generic form:** [`shz_vec_saturate()`](https://sh4zam.com/api/vector/shz_vec_saturate/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:237`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L237) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_scale Source: https://sh4zam.com/api/vector/shz_vec2_scale/ ```c SHZ_INLINE shz_vec2_t shz_vec2_scale(shz_vec2_t vec, float factor) SHZ_NOEXCEPT; ``` Returns a 2D vector whose component values are those of the given vector multiplied by a factor. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `factor` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_scale()`](https://sh4zam.com/api/vector/shz_vec_scale/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:389`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L389) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec2_sign Source: https://sh4zam.com/api/vector/shz_vec2_sign/ ```c SHZ_INLINE shz_vec2_t shz_vec2_sign(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the signs (-1, 0, or 1) of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::sign`](https://sh4zam.com/api/cpp/vec2/#sign) - **Type-generic form:** [`shz_vec_sign()`](https://sh4zam.com/api/vector/shz_vec_sign/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:228`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L228) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_smoothstep_safe Source: https://sh4zam.com/api/vector/shz_vec2_smoothstep_safe/ ```c SHZ_INLINE shz_vec2_t shz_vec2_smoothstep_safe(shz_vec2_t vec, float edge0, float edge1) SHZ_NOEXCEPT; ``` For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `edge0` | `float` | | | `edge1` | `float` | | ## Returns `shz_vec2_t` ## 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::smoothstep_safe`](https://sh4zam.com/api/cpp/vec2/#smoothstep_safe) - **Type-generic form:** [`shz_vec_smoothstep_safe()`](https://sh4zam.com/api/vector/shz_vec_smoothstep_safe/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:309`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L309) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_smoothstep Source: https://sh4zam.com/api/vector/shz_vec2_smoothstep/ ```c SHZ_INLINE shz_vec2_t shz_vec2_smoothstep(shz_vec2_t vec, float edge0, float edge1) SHZ_NOEXCEPT; ``` For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `edge0` | `float` | | | `edge1` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::smoothstep`](https://sh4zam.com/api/cpp/vec2/#smoothstep) - **Type-generic form:** [`shz_vec_smoothstep()`](https://sh4zam.com/api/vector/shz_vec_smoothstep/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:291`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L291) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_smoothstepv_safe Source: https://sh4zam.com/api/vector/shz_vec2_smoothstepv_safe/ > For each component: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between. Accepts inverse edges ```c SHZ_INLINE shz_vec2_t shz_vec2_smoothstepv_safe(shz_vec2_t vec, shz_vec2_t edge0, shz_vec2_t edge1) SHZ_NOEXCEPT; ``` For each component: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. Accepts inverse edges. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `edge0` | `shz_vec2_t` | | | `edge1` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## 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:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_smoothstepv_safe()`](https://sh4zam.com/api/vector/shz_vec_smoothstepv_safe/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:318`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L318) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_smoothstepv Source: https://sh4zam.com/api/vector/shz_vec2_smoothstepv/ > For each component: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between ```c SHZ_INLINE shz_vec2_t shz_vec2_smoothstepv(shz_vec2_t vec, shz_vec2_t edge0, shz_vec2_t edge1) SHZ_NOEXCEPT; ``` For each component: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `edge0` | `shz_vec2_t` | | | `edge1` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_smoothstepv()`](https://sh4zam.com/api/vector/shz_vec_smoothstepv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:300`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L300) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_sqrtf Source: https://sh4zam.com/api/vector/shz_vec2_sqrtf/ ```c SHZ_INLINE shz_vec2_t shz_vec2_sqrtf(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are the square root of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::sqrtf`](https://sh4zam.com/api/cpp/vec2/#sqrtf) - **Type-generic form:** [`shz_vec_sqrtf()`](https://sh4zam.com/api/vector/shz_vec_sqrtf/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:336`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L336) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_step Source: https://sh4zam.com/api/vector/shz_vec2_step/ > For each component: returns 0.0f if vec[i] < edge, otherwise 1.0f ```c SHZ_INLINE shz_vec2_t shz_vec2_step(shz_vec2_t vec, float edge) SHZ_NOEXCEPT; ``` For each component: returns 0.0f if vec\[i\] \< edge, otherwise 1.0f. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `edge` | `float` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::step`](https://sh4zam.com/api/cpp/vec2/#step) - **Type-generic form:** [`shz_vec_step()`](https://sh4zam.com/api/vector/shz_vec_step/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:282`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L282) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_stepv Source: https://sh4zam.com/api/vector/shz_vec2_stepv/ > For each component: returns 0.0f if vec[i] < edge[i], otherwise 1.0f ```c SHZ_INLINE shz_vec2_t shz_vec2_stepv( shz_vec2_t vec, shz_vec2_t edge) SHZ_NOEXCEPT; ``` For each component: returns 0.0f if vec\[i\] \< edge\[i\], otherwise 1.0f. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `edge` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_stepv()`](https://sh4zam.com/api/vector/shz_vec_stepv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:273`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L273) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec2_sub Source: https://sh4zam.com/api/vector/shz_vec2_sub/ > Returns a 2D vector whose components are equal to the values of vec1 minus vec2 ```c SHZ_INLINE shz_vec2_t shz_vec2_sub(shz_vec2_t vec1, shz_vec2_t vec2) SHZ_NOEXCEPT; ``` Returns a 2D vector whose components are equal to the values of `vec1` minus `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec2_t` | | | `vec2` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_sub()`](https://sh4zam.com/api/vector/shz_vec_sub/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:362`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L362) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec2_swizzle Source: https://sh4zam.com/api/vector/shz_vec2_swizzle/ ```c SHZ_INLINE shz_vec2_t shz_vec2_swizzle(shz_vec2_t vec, unsigned x_idx, unsigned y_idx) SHZ_NOEXCEPT; ``` Returns a 2D vector whose elements are equal to the source vector's values at the given indices. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `x_idx` | `unsigned` | | | `y_idx` | `unsigned` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** [`shz::vec2::swizzle`](https://sh4zam.com/api/cpp/vec2/#swizzle) - **Type-generic form:** [`shz_vec_swizzle()`](https://sh4zam.com/api/vector/shz_vec_swizzle/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:707`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L707) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Swizzling" --- # shz_vec2_t Source: https://sh4zam.com/api/vector/shz_vec2_t/ ```c typedef struct shz_vec2 { union { float e[2]; //!< coordinates as an array struct { float x; //!< X coordinate float y; //!< Y coordinate }; }; } shz_vec2_t; ``` 2D Vector type ## Fields | Field | Type | Description | | --- | --- | --- | | `e` | `float[2]` | \ coordinates as an array | | `x` | `float` | X coordinate. | | `y` | `float` | Y coordinate. | ## Details Structure for holding coordinates of a 2-dimensional vector. ## Availability - **C++ equivalent:** [`shz::vec2`](https://sh4zam.com/api/cpp/vec2/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:38`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L38) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Types" ## See also [`shz_vec3_t`](https://sh4zam.com/api/vector/shz_vec3_t/), [`shz_vec4_t`](https://sh4zam.com/api/vector/shz_vec4_t/) --- # shz_vec2_to Source: https://sh4zam.com/api/vector/shz_vec2_to/ > Converts the given 2D vector into a value of the given type ```c #define shz_vec2_to(type, vector) SHZ_CONVERT(type, vector) ``` Converts the given 2D `vector` into a value of the given `type`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `type` | | | | `vector` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:743`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L743) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec2_vec3 Source: https://sh4zam.com/api/vector/shz_vec2_vec3/ > Extends a 2D vector to 3D, using z as the value of the Z component ```c SHZ_INLINE shz_vec3_t shz_vec2_vec3(shz_vec2_t vec, float z) SHZ_NOEXCEPT; ``` Extends a 2D vector to 3D, using `z` as the value of the Z component. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `z` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:691`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L691) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Extending" --- # shz_vec2_vec4 Source: https://sh4zam.com/api/vector/shz_vec2_vec4/ > Extends a 2D vector to 4D, using z and w as the values of the Z and W components ```c SHZ_INLINE shz_vec4_t shz_vec2_vec4(shz_vec2_t vec, float z, float w) SHZ_NOEXCEPT; ``` Extends a 2D vector to 4D, using `z` and `w` as the values of the Z and W components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | | `z` | `float` | | | `w` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:694`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L694) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Extending" --- # shz_vec2 Source: https://sh4zam.com/api/vector/shz_vec2/ > Alternate typedef for the shz_vec2 struct for those who hate POSIX-style ```c typedef shz_vec2_t shz_vec2; ``` Alternate typedef for the [`shz_vec2`](https://sh4zam.com/api/vector/shz_vec2/) struct for those who hate POSIX-style. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:49`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L49) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Types" --- # shz_vec3_abs Source: https://sh4zam.com/api/vector/shz_vec3_abs/ ```c SHZ_INLINE shz_vec3_t shz_vec3_abs(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the absolute values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::abs`](https://sh4zam.com/api/cpp/vec3/#abs) - **Type-generic form:** [`shz_vec_abs()`](https://sh4zam.com/api/vector/shz_vec_abs/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:141`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L141) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_add Source: https://sh4zam.com/api/vector/shz_vec3_add/ ```c SHZ_INLINE shz_vec3_t shz_vec3_add(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the sums of the given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_add()`](https://sh4zam.com/api/vector/shz_vec_add/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:356`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L356) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec3_angle_between Source: https://sh4zam.com/api/vector/shz_vec3_angle_between/ ```c SHZ_INLINE float shz_vec3_angle_between(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns the angle formed between the given 3D vectors in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::angle_between`](https://sh4zam.com/api/cpp/vec3/#angle_between) - **Type-generic form:** [`shz_vec_angle_between()`](https://sh4zam.com/api/vector/shz_vec_angle_between/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:624`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L624) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec3_angles Source: https://sh4zam.com/api/vector/shz_vec3_angles/ ```c SHZ_INLINE shz_vec3_t shz_vec3_angles(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns the angles formed between the positive X axis and the given 3D vector, in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::angles`](https://sh4zam.com/api/cpp/vec3/#angles) - **Type-generic form:** [`shz_vec_angles()`](https://sh4zam.com/api/vector/shz_vec_angles/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:630`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L630) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec3_barycenter Source: https://sh4zam.com/api/vector/shz_vec3_barycenter/ > Computes barycentric coordinates for point p, within the plane of the triangle with vertices a, b, and c ```c SHZ_INLINE shz_vec3_t shz_vec3_barycenter(shz_vec3_t p, shz_vec3_t a, shz_vec3_t b, shz_vec3_t c) SHZ_NOEXCEPT; ``` Computes barycentric coordinates `` for point p, within the plane of the triangle with vertices `a`, `b`, and `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `p` | `shz_vec3_t` | | | `a` | `shz_vec3_t` | | | `b` | `shz_vec3_t` | | | `c` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::barycenter`](https://sh4zam.com/api/cpp/vec3/#barycenter) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:605`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L605) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Miscellaneous" --- # shz_vec3_ceil Source: https://sh4zam.com/api/vector/shz_vec3_ceil/ ```c SHZ_INLINE shz_vec3_t shz_vec3_ceil(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the ceil of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::ceil`](https://sh4zam.com/api/cpp/vec3/#ceil) - **Type-generic form:** [`shz_vec_ceil()`](https://sh4zam.com/api/vector/shz_vec_ceil/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:204`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L204) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_clamp Source: https://sh4zam.com/api/vector/shz_vec3_clamp/ > Clamps the values of the given 3D vec between min and max, returning a new vector ```c SHZ_INLINE shz_vec3_t shz_vec3_clamp(shz_vec3_t vec, float min, float max) SHZ_NOEXCEPT; ``` Clamps the values of the given 3D `vec` between `min` and `max`, returning a new vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `min` | `float` | | | `max` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::clamp`](https://sh4zam.com/api/cpp/vec3/#clamp) - **Type-generic form:** [`shz_vec_clamp()`](https://sh4zam.com/api/vector/shz_vec_clamp/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:186`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L186) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_cross Source: https://sh4zam.com/api/vector/shz_vec3_cross/ ```c SHZ_INLINE shz_vec3_t shz_vec3_cross(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns the vector produced by taking the cross-product of the two given 3D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::cross`](https://sh4zam.com/api/cpp/vec3/#cross) - **Type-generic form:** [`shz_vec_cross()`](https://sh4zam.com/api/vector/shz_vec_cross/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:556`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L556) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_cubic_hermite Source: https://sh4zam.com/api/vector/shz_vec3_cubic_hermite/ ```c SHZ_INLINE shz_vec3_t shz_vec3_cubic_hermite(shz_vec3_t vec, shz_vec3_t tangent1, shz_vec3_t vec2, shz_vec3_t tangent2, float amounht) SHZ_NOEXCEPT; ``` Calculates the cubic hermite interpolation between two vectors and their tangents. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `tangent1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | | `tangent2` | `shz_vec3_t` | | | `amounht` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::cubic_hermite`](https://sh4zam.com/api/cpp/vec3/#cubic_hermite) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:611`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L611) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Miscellaneous" --- # shz_vec3_deref Source: https://sh4zam.com/api/vector/shz_vec3_deref/ > Dereferences the given pointer to a sequence of 3 floats as a shz_vec3_t ```c #define shz_vec3_deref(ptr) (*((SHZ_ALIASING shz_vec3_t*)(ptr))) ``` Dereferences the given pointer to a sequence of 3 floats as a [`shz_vec3_t`](https://sh4zam.com/api/vector/shz_vec3_t/). ## Parameters | Name | Type | Description | | --- | --- | --- | | `ptr` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:728`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L728) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec3_distance_sqr Source: https://sh4zam.com/api/vector/shz_vec3_distance_sqr/ ```c SHZ_INLINE float shz_vec3_distance_sqr(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns the squared-distance between the two given 3D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::distance_sqr`](https://sh4zam.com/api/cpp/vec3/#distance_sqr) - **Type-generic form:** [`shz_vec_distance_sqr()`](https://sh4zam.com/api/vector/shz_vec_distance_sqr/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:505`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L505) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_distance Source: https://sh4zam.com/api/vector/shz_vec3_distance/ ```c SHZ_INLINE float shz_vec3_distance(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns the distance between the two given 3D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::distance`](https://sh4zam.com/api/cpp/vec3/#distance) - **Type-generic form:** [`shz_vec_distance()`](https://sh4zam.com/api/vector/shz_vec_distance/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:496`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L496) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_div Source: https://sh4zam.com/api/vector/shz_vec3_div/ > Returns a 3D vector whose component values are those of vec1 divided by vec2 ```c SHZ_INLINE shz_vec3_t shz_vec3_div(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns a 3D vector whose component values are those of `vec1` divided by `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_div()`](https://sh4zam.com/api/vector/shz_vec_div/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:383`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L383) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec3_dot Source: https://sh4zam.com/api/vector/shz_vec3_dot/ ```c SHZ_INLINE float shz_vec3_dot(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns the dot product between the two given 3D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot()`](https://sh4zam.com/api/vector/shz_vec_dot/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:475`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L475) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_dot2 Source: https://sh4zam.com/api/vector/shz_vec3_dot2/ > Returns the two dot products taken between the 3D vector l and 3D vectors r1 and r2 ```c SHZ_INLINE shz_vec2_t shz_vec3_dot2(shz_vec3_t l, shz_vec3_t r1, shz_vec3_t r2) SHZ_NOEXCEPT; ``` Returns the two dot products taken between the 3D vector `l` and 3D vectors `r1` and `r2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | `shz_vec3_t` | | | `r1` | `shz_vec3_t` | | | `r2` | `shz_vec3_t` | | ## Returns `shz_vec2_t` ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot2()`](https://sh4zam.com/api/vector/shz_vec_dot2/) - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:478`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L478) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_dot3 Source: https://sh4zam.com/api/vector/shz_vec3_dot3/ > Returns the three dot products taken between the 3D vector l and 3D vectors r1, r2, and r3 ```c SHZ_INLINE shz_vec3_t shz_vec3_dot3(shz_vec3_t l, shz_vec3_t r1, shz_vec3_t r2, shz_vec3_t r3) SHZ_NOEXCEPT; ``` Returns the three dot products taken between the 3D vector `l` and 3D vectors `r1`, `r2`, and `r3`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | `shz_vec3_t` | | | `r1` | `shz_vec3_t` | | | `r2` | `shz_vec3_t` | | | `r3` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot3()`](https://sh4zam.com/api/vector/shz_vec_dot3/) - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:481`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L481) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_equal Source: https://sh4zam.com/api/vector/shz_vec3_equal/ ```c SHZ_INLINE bool shz_vec3_equal(shz_vec3_t a, shz_vec3_t b) SHZ_NOEXCEPT; ``` Returns true if the values of each element within the two 3D vectors are approximately equal based on relative or absolute tolerance. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec3_t` | | | `b` | `shz_vec3_t` | | ## Returns `bool` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_equal()`](https://sh4zam.com/api/vector/shz_vec_equal/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:267`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L267) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_fill Source: https://sh4zam.com/api/vector/shz_vec3_fill/ > Returns a 3D vector with the value of each compoonent equal to v ```c SHZ_INLINE shz_vec3_t shz_vec3_fill(float v) SHZ_NOEXCEPT; ``` Returns a 3D vector with the value of each compoonent equal to `v`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `v` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:125`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L125) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Initializers" --- # shz_vec3_floor Source: https://sh4zam.com/api/vector/shz_vec3_floor/ ```c SHZ_INLINE shz_vec3_t shz_vec3_floor(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the floor of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::floor`](https://sh4zam.com/api/cpp/vec3/#floor) - **Type-generic form:** [`shz_vec_floor()`](https://sh4zam.com/api/vector/shz_vec_floor/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:195`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L195) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_fract Source: https://sh4zam.com/api/vector/shz_vec3_fract/ ```c SHZ_INLINE shz_vec3_t shz_vec3_fract(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the fractional parts of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::fract`](https://sh4zam.com/api/cpp/vec3/#fract) - **Type-generic form:** [`shz_vec_fract()`](https://sh4zam.com/api/vector/shz_vec_fract/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:222`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L222) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_from_angles_deg Source: https://sh4zam.com/api/vector/shz_vec3_from_angles_deg/ ```c SHZ_INLINE shz_vec3_t shz_vec3_from_angles_deg(float azimuth, float elevation) SHZ_NOEXCEPT; ``` Returns the 3D unit vector representing the given rotation angles relative to the positive X axis in degrees. ## Parameters | Name | Type | Description | | --- | --- | --- | | `azimuth` | `float` | | | `elevation` | `float` | | ## Returns `shz_vec3_t` ## Naming and requirements - `_deg`: Angle argument is in degrees. The default is radians. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::vec3::from_angles_deg`](https://sh4zam.com/api/cpp/vec3/#from_angles_deg) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:648`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L648) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec3_from_angles Source: https://sh4zam.com/api/vector/shz_vec3_from_angles/ ```c SHZ_INLINE shz_vec3_t shz_vec3_from_angles(float azimuth, float elevation) SHZ_NOEXCEPT; ``` Returns the 3D unit vector representing the given rotation angles relative to the positive X axis in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `azimuth` | `float` | | | `elevation` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::from_angles`](https://sh4zam.com/api/cpp/vec3/#from_angles) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:642`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L642) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec3_from_sincos Source: https://sh4zam.com/api/vector/shz_vec3_from_sincos/ ```c SHZ_INLINE shz_vec3_t shz_vec3_from_sincos(shz_sincos_t azimuth, shz_sincos_t elevation) SHZ_NOEXCEPT; ``` Returns the 3D unit vector representing the given rotation angles relative to the positive X axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `azimuth` | `shz_sincos_t` | | | `elevation` | `shz_sincos_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:636`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L636) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" --- # shz_vec3_from Source: https://sh4zam.com/api/vector/shz_vec3_from/ > Converts the given value or expression to the equivalent 3D SH4ZAM vector value ```c #define shz_vec3_from(value) SHZ_CONVERT(shz_vec3_t, value) ``` Converts the given `value` or expression to the equivalent 3D SH4ZAM vector value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:737`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L737) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec3_init Source: https://sh4zam.com/api/vector/shz_vec3_init/ > Returns a 3D vector with the given x, y, and z coordinates ```c SHZ_INLINE shz_vec3_t shz_vec3_init(float x, float y, float z) SHZ_NOEXCEPT; ``` Returns a 3D vector with the given `x`, `y`, and `z` coordinates. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:116`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L116) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Initializers" --- # shz_vec3_inv_sqrtf Source: https://sh4zam.com/api/vector/shz_vec3_inv_sqrtf/ ```c SHZ_INLINE shz_vec3_t shz_vec3_inv_sqrtf(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the inverse square root of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::inv_sqrtf`](https://sh4zam.com/api/cpp/vec3/#inv_sqrtf) - **Type-generic form:** [`shz_vec_inv_sqrtf()`](https://sh4zam.com/api/vector/shz_vec_inv_sqrtf/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:330`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L330) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_inv Source: https://sh4zam.com/api/vector/shz_vec3_inv/ ```c SHZ_INLINE shz_vec3_t shz_vec3_inv(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns the 3D vector whose components have been inverted or reciprocated. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::inv`](https://sh4zam.com/api/cpp/vec3/#inv) - **Type-generic form:** [`shz_vec_inv()`](https://sh4zam.com/api/vector/shz_vec_inv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:159`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L159) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_lerp Source: https://sh4zam.com/api/vector/shz_vec3_lerp/ > Returns a 3D vector that is linearly interpolated from a to b by the given 0.0f-1.0f factor, t ```c SHZ_INLINE shz_vec3_t shz_vec3_lerp(shz_vec3_t a, shz_vec3_t b, float t) SHZ_NOEXCEPT; ``` Returns a 3D vector that is linearly interpolated from `a` to `b` by the given `0.0f-1.0f` factor, `t`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec3_t` | | | `b` | `shz_vec3_t` | | | `t` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::lerp`](https://sh4zam.com/api/cpp/vec3/#lerp) - **Type-generic form:** [`shz_vec_lerp()`](https://sh4zam.com/api/vector/shz_vec_lerp/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:523`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L523) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_magnitude_inv Source: https://sh4zam.com/api/vector/shz_vec3_magnitude_inv/ ```c SHZ_INLINE float shz_vec3_magnitude_inv(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns the inverse magnitude of the given 3D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::magnitude_inv`](https://sh4zam.com/api/cpp/vec3/#magnitude_inv) - **Type-generic form:** [`shz_vec_magnitude_inv()`](https://sh4zam.com/api/vector/shz_vec_magnitude_inv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:426`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L426) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec3_magnitude_sqr Source: https://sh4zam.com/api/vector/shz_vec3_magnitude_sqr/ ```c SHZ_INLINE float shz_vec3_magnitude_sqr(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns the squared magnitude of the given 3D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::magnitude_sqr`](https://sh4zam.com/api/cpp/vec3/#magnitude_sqr) - **Type-generic form:** [`shz_vec_magnitude_sqr()`](https://sh4zam.com/api/vector/shz_vec_magnitude_sqr/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:411`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L411) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec3_magnitude Source: https://sh4zam.com/api/vector/shz_vec3_magnitude/ ```c SHZ_INLINE float shz_vec3_magnitude(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns the magnitude of the given 3D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::magnitude`](https://sh4zam.com/api/cpp/vec3/#magnitude) - **Type-generic form:** [`shz_vec_magnitude()`](https://sh4zam.com/api/vector/shz_vec_magnitude/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:417`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L417) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec3_max Source: https://sh4zam.com/api/vector/shz_vec3_max/ ```c SHZ_INLINE float shz_vec3_max(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns the maximum value of the given vector's 3 components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::max`](https://sh4zam.com/api/cpp/vec3/#max) - **Type-generic form:** [`shz_vec_max()`](https://sh4zam.com/api/vector/shz_vec_max/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:168`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L168) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_maxv Source: https://sh4zam.com/api/vector/shz_vec3_maxv/ ```c SHZ_INLINE shz_vec3_t shz_vec3_maxv(shz_vec3_t a, shz_vec3_t b) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the pairwise maximums of the two given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec3_t` | | | `b` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::maxv`](https://sh4zam.com/api/cpp/vec3/#maxv) - **Type-generic form:** [`shz_vec_maxv()`](https://sh4zam.com/api/vector/shz_vec_maxv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:258`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L258) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_min Source: https://sh4zam.com/api/vector/shz_vec3_min/ ```c SHZ_INLINE float shz_vec3_min(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns the minimum value of the given vector's 3 components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::min`](https://sh4zam.com/api/cpp/vec3/#min) - **Type-generic form:** [`shz_vec_min()`](https://sh4zam.com/api/vector/shz_vec_min/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:177`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L177) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_minv Source: https://sh4zam.com/api/vector/shz_vec3_minv/ ```c SHZ_INLINE shz_vec3_t shz_vec3_minv(shz_vec3_t a, shz_vec3_t b) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the pairwise minimums of the two given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec3_t` | | | `b` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::minv`](https://sh4zam.com/api/cpp/vec3/#minv) - **Type-generic form:** [`shz_vec_minv()`](https://sh4zam.com/api/vector/shz_vec_minv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:249`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L249) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_move Source: https://sh4zam.com/api/vector/shz_vec3_move/ > Returns the given 3D vector, translated towards the target by the given max_distance ```c SHZ_INLINE shz_vec3_t shz_vec3_move(shz_vec3_t vec, shz_vec3_t target, float max_distance) SHZ_NOEXCEPT; ``` Returns the given 3D vector, translated towards the `target` by the given `max_distance`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `target` | `shz_vec3_t` | | | `max_distance` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::move`](https://sh4zam.com/api/cpp/vec3/#move) - **Type-generic form:** [`shz_vec_move()`](https://sh4zam.com/api/vector/shz_vec_move/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:514`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L514) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_mul Source: https://sh4zam.com/api/vector/shz_vec3_mul/ > Returns a 3D vector whose component values are those of vec1 times vec2 ```c SHZ_INLINE shz_vec3_t shz_vec3_mul(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns a 3D vector whose component values are those of `vec1` times `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_mul()`](https://sh4zam.com/api/vector/shz_vec_mul/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:374`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L374) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec3_neg Source: https://sh4zam.com/api/vector/shz_vec3_neg/ ```c SHZ_INLINE shz_vec3_t shz_vec3_neg(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the negative values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::neg`](https://sh4zam.com/api/cpp/vec3/#neg) - **Type-generic form:** [`shz_vec_neg()`](https://sh4zam.com/api/vector/shz_vec_neg/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:150`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L150) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_normalize_safe Source: https://sh4zam.com/api/vector/shz_vec3_normalize_safe/ ```c SHZ_INLINE shz_vec3_t shz_vec3_normalize_safe(shz_vec3_t vec) SHZ_NOEXCEPT; ``` SAFELY returns a normalized unit vector from the given 3D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_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::vec3::direction_safe`](https://sh4zam.com/api/cpp/vec3/#direction_safe), [`shz::vec3::normalize_safe`](https://sh4zam.com/api/cpp/vec3/#normalize_safe), [`shz::vec3::normalized_safe`](https://sh4zam.com/api/cpp/vec3/#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:450`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L450) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec3_normalize Source: https://sh4zam.com/api/vector/shz_vec3_normalize/ ```c SHZ_INLINE shz_vec3_t shz_vec3_normalize(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a normalized unit vector from the given 3D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::direction`](https://sh4zam.com/api/cpp/vec3/#direction), [`shz::vec3::normalize`](https://sh4zam.com/api/cpp/vec3/#normalize), [`shz::vec3::normalized`](https://sh4zam.com/api/cpp/vec3/#normalized) - **Type-generic form:** [`shz_vec_normalize()`](https://sh4zam.com/api/vector/shz_vec_normalize/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:435`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L435) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec3_orthonormalize Source: https://sh4zam.com/api/vector/shz_vec3_orthonormalize/ ```c SHZ_INLINE void shz_vec3_orthonormalize(shz_vec3_t in1, shz_vec3_t in2, shz_vec3_t* out1, shz_vec3_t* out2) SHZ_NOEXCEPT; ``` Returns 2 3D vectors which are normalized and orthogonal to the two input vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `in1` | `shz_vec3_t` | | | `in2` | `shz_vec3_t` | | | `out1` | `shz_vec3_t *` | | | `out2` | `shz_vec3_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::vec3::orthonormalize`](https://sh4zam.com/api/cpp/vec3/#orthonormalize) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:608`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L608) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Miscellaneous" --- # shz_vec3_perp Source: https://sh4zam.com/api/vector/shz_vec3_perp/ ```c SHZ_INLINE shz_vec3_t shz_vec3_perp(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a vector which is perpendicular to the given vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::perp`](https://sh4zam.com/api/cpp/vec3/#perp) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:602`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L602) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Miscellaneous" --- # shz_vec3_project_safe Source: https://sh4zam.com/api/vector/shz_vec3_project_safe/ ```c SHZ_INLINE shz_vec3_t shz_vec3_project_safe(shz_vec3_t vec, shz_vec3_t onto) SHZ_NOEXCEPT; ``` Returns the resulting vector from projecting the given 3D vector along the given (unit) axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `onto` | `shz_vec3_t` | | ## Returns `shz_vec3_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::vec3::project_safe`](https://sh4zam.com/api/cpp/vec3/#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:579`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L579) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_project Source: https://sh4zam.com/api/vector/shz_vec3_project/ ```c SHZ_INLINE shz_vec3_t shz_vec3_project(shz_vec3_t vec, shz_vec3_t onto) SHZ_NOEXCEPT; ``` Returns the resulting vector from projecting the given 3D vector along the given (unit) axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `onto` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::project`](https://sh4zam.com/api/cpp/vec3/#project) - **Type-generic form:** [`shz_vec_project()`](https://sh4zam.com/api/vector/shz_vec_project/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:562`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L562) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_reflect Source: https://sh4zam.com/api/vector/shz_vec3_reflect/ > Reflects the given 3D incidence vector against a surface with the given normal, returning the result ```c SHZ_INLINE shz_vec3_t shz_vec3_reflect(shz_vec3_t incidence, shz_vec3_t normal) SHZ_NOEXCEPT; ``` Reflects the given 3D `incidence` vector against a surface with the given `normal`, returning the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `incidence` | `shz_vec3_t` | | | `normal` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::reflect`](https://sh4zam.com/api/cpp/vec3/#reflect) - **Type-generic form:** [`shz_vec_reflect()`](https://sh4zam.com/api/vector/shz_vec_reflect/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:532`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L532) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_refract Source: https://sh4zam.com/api/vector/shz_vec3_refract/ > Refracts the given 3D incidence vector against a surface with the given normal using the given refraction index ratio, eta ```c SHZ_INLINE shz_vec3_t shz_vec3_refract(shz_vec3_t incidence, shz_vec3_t normal, float eta) SHZ_NOEXCEPT; ``` Refracts the given 3D `incidence` vector against a surface with the given `normal` using the given refraction index ratio, `eta`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `incidence` | `shz_vec3_t` | | | `normal` | `shz_vec3_t` | | | `eta` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::refract`](https://sh4zam.com/api/cpp/vec3/#refract) - **Type-generic form:** [`shz_vec_refract()`](https://sh4zam.com/api/vector/shz_vec_refract/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:541`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L541) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_reject Source: https://sh4zam.com/api/vector/shz_vec3_reject/ > Returns the rejection of the given vector, vec, onto another vector, onto ```c SHZ_INLINE shz_vec3_t shz_vec3_reject(shz_vec3_t vec, shz_vec3_t onto) SHZ_NOEXCEPT; ``` Returns the rejection of the given vector, `vec`, onto another vector, `onto`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `onto` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::reject`](https://sh4zam.com/api/cpp/vec3/#reject) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:589`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L589) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec3_rotate_x Source: https://sh4zam.com/api/vector/shz_vec3_rotate_x/ ```c SHZ_INLINE shz_vec3_t shz_vec3_rotate_x(shz_vec3_t vec, float radians) SHZ_NOEXCEPT; ``` Rotates the given 3D vector about the X axis by the given angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `radians` | `float` | | ## Returns `shz_vec3_t` ## Warnings - This routine should only be used for one-off rotations of a single vector. To rotate multiple vectors in a batch, use the XMTRX API. ## Availability - **C++ equivalent:** [`shz::vec3::rotate_x`](https://sh4zam.com/api/cpp/vec3/#rotate_x) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:661`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L661) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" ## See also [`shz_xmtrx_apply_rotation_x`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_x/) --- # shz_vec3_rotate_y Source: https://sh4zam.com/api/vector/shz_vec3_rotate_y/ ```c SHZ_INLINE shz_vec3_t shz_vec3_rotate_y(shz_vec3_t vec, float radians) SHZ_NOEXCEPT; ``` Rotates the given 3D vector about the Y axis by the given angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `radians` | `float` | | ## Returns `shz_vec3_t` ## Warnings - This routine should only be used for one-off rotations of a single vector. To rotate multiple vectors in a batch, use the XMTRX API. ## Availability - **C++ equivalent:** [`shz::vec3::rotate_y`](https://sh4zam.com/api/cpp/vec3/#rotate_y) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:671`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L671) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" ## See also [`shz_xmtrx_apply_rotation_y`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_y/) --- # shz_vec3_rotate_z Source: https://sh4zam.com/api/vector/shz_vec3_rotate_z/ ```c SHZ_INLINE shz_vec3_t shz_vec3_rotate_z(shz_vec3_t vec, float radians) SHZ_NOEXCEPT; ``` Rotates the given 3D vector about the Z axis by the given angle in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `radians` | `float` | | ## Returns `shz_vec3_t` ## Warnings - This routine should only be used for one-off rotations of a single vector. To rotate multiple vectors in a batch, use the XMTRX API. ## Availability - **C++ equivalent:** [`shz::vec3::rotate_z`](https://sh4zam.com/api/cpp/vec3/#rotate_z) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:681`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L681) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Angles" ## See also [`shz_xmtrx_apply_rotation_z`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_z/) --- # shz_vec3_round Source: https://sh4zam.com/api/vector/shz_vec3_round/ ```c SHZ_INLINE shz_vec3_t shz_vec3_round(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the rounded values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::round`](https://sh4zam.com/api/cpp/vec3/#round) - **Type-generic form:** [`shz_vec_round()`](https://sh4zam.com/api/vector/shz_vec_round/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:213`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L213) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_saturate Source: https://sh4zam.com/api/vector/shz_vec3_saturate/ > Returns a 3D vector whose components are saturated (clamped to [0, 1]) values of the given vector's components ```c SHZ_INLINE shz_vec3_t shz_vec3_saturate(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are saturated (clamped to \[0, 1\]) values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::saturate`](https://sh4zam.com/api/cpp/vec3/#saturate) - **Type-generic form:** [`shz_vec_saturate()`](https://sh4zam.com/api/vector/shz_vec_saturate/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:240`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L240) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_scale Source: https://sh4zam.com/api/vector/shz_vec3_scale/ ```c SHZ_INLINE shz_vec3_t shz_vec3_scale(shz_vec3_t vec, float factor) SHZ_NOEXCEPT; ``` Returns a 3D vector whose component values are those of the given vector multiplied by a factor. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `factor` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_scale()`](https://sh4zam.com/api/vector/shz_vec_scale/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:392`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L392) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec3_sign Source: https://sh4zam.com/api/vector/shz_vec3_sign/ ```c SHZ_INLINE shz_vec3_t shz_vec3_sign(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the signs (-1, 0, or 1) of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::sign`](https://sh4zam.com/api/cpp/vec3/#sign) - **Type-generic form:** [`shz_vec_sign()`](https://sh4zam.com/api/vector/shz_vec_sign/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:231`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L231) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_smoothstep_safe Source: https://sh4zam.com/api/vector/shz_vec3_smoothstep_safe/ ```c SHZ_INLINE shz_vec3_t shz_vec3_smoothstep_safe(shz_vec3_t vec, float edge0, float edge1) SHZ_NOEXCEPT; ``` For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `edge0` | `float` | | | `edge1` | `float` | | ## Returns `shz_vec3_t` ## 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::vec3::smoothstep_safe`](https://sh4zam.com/api/cpp/vec3/#smoothstep_safe) - **Type-generic form:** [`shz_vec_smoothstep_safe()`](https://sh4zam.com/api/vector/shz_vec_smoothstep_safe/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:312`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L312) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_smoothstep Source: https://sh4zam.com/api/vector/shz_vec3_smoothstep/ ```c SHZ_INLINE shz_vec3_t shz_vec3_smoothstep(shz_vec3_t vec, float edge0, float edge1) SHZ_NOEXCEPT; ``` For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `edge0` | `float` | | | `edge1` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::smoothstep`](https://sh4zam.com/api/cpp/vec3/#smoothstep) - **Type-generic form:** [`shz_vec_smoothstep()`](https://sh4zam.com/api/vector/shz_vec_smoothstep/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:294`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L294) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_smoothstepv_safe Source: https://sh4zam.com/api/vector/shz_vec3_smoothstepv_safe/ > For each component i: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between. Accepts inverse edges ```c SHZ_INLINE shz_vec3_t shz_vec3_smoothstepv_safe(shz_vec3_t vec, shz_vec3_t edge0, shz_vec3_t edge1) SHZ_NOEXCEPT; ``` For each component i: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. Accepts inverse edges. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `edge0` | `shz_vec3_t` | | | `edge1` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## 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:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_smoothstepv_safe()`](https://sh4zam.com/api/vector/shz_vec_smoothstepv_safe/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:321`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L321) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_smoothstepv Source: https://sh4zam.com/api/vector/shz_vec3_smoothstepv/ > For each component i: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between ```c SHZ_INLINE shz_vec3_t shz_vec3_smoothstepv(shz_vec3_t vec, shz_vec3_t edge0, shz_vec3_t edge1) SHZ_NOEXCEPT; ``` For each component i: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `edge0` | `shz_vec3_t` | | | `edge1` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_smoothstepv()`](https://sh4zam.com/api/vector/shz_vec_smoothstepv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:303`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L303) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_sqrtf Source: https://sh4zam.com/api/vector/shz_vec3_sqrtf/ ```c SHZ_INLINE shz_vec3_t shz_vec3_sqrtf(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are the square root of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::sqrtf`](https://sh4zam.com/api/cpp/vec3/#sqrtf) - **Type-generic form:** [`shz_vec_sqrtf()`](https://sh4zam.com/api/vector/shz_vec_sqrtf/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:339`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L339) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_step Source: https://sh4zam.com/api/vector/shz_vec3_step/ > For each component: returns 0.0f if vec[i] < edge, otherwise 1.0f ```c SHZ_INLINE shz_vec3_t shz_vec3_step(shz_vec3_t vec, float edge) SHZ_NOEXCEPT; ``` For each component: returns 0.0f if vec\[i\] \< edge, otherwise 1.0f. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `edge` | `float` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::step`](https://sh4zam.com/api/cpp/vec3/#step) - **Type-generic form:** [`shz_vec_step()`](https://sh4zam.com/api/vector/shz_vec_step/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:285`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L285) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_stepv Source: https://sh4zam.com/api/vector/shz_vec3_stepv/ > For each component: returns 0.0f if vec[i] < edge[i], otherwise 1.0f ```c SHZ_INLINE shz_vec3_t shz_vec3_stepv(shz_vec3_t vec, shz_vec3_t edge) SHZ_NOEXCEPT; ``` For each component: returns 0.0f if vec\[i\] \< edge\[i\], otherwise 1.0f. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `edge` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_stepv()`](https://sh4zam.com/api/vector/shz_vec_stepv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:276`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L276) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec3_sub Source: https://sh4zam.com/api/vector/shz_vec3_sub/ > Returns a 3D vector whose components are equal to the values of vec1 minus vec2 ```c SHZ_INLINE shz_vec3_t shz_vec3_sub(shz_vec3_t vec1, shz_vec3_t vec2) SHZ_NOEXCEPT; ``` Returns a 3D vector whose components are equal to the values of `vec1` minus `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec3_t` | | | `vec2` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_sub()`](https://sh4zam.com/api/vector/shz_vec_sub/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:365`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L365) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec3_swizzle Source: https://sh4zam.com/api/vector/shz_vec3_swizzle/ ```c SHZ_INLINE shz_vec3_t shz_vec3_swizzle(shz_vec3_t vec, unsigned x_idx, unsigned y_idx, unsigned z_idx) SHZ_NOEXCEPT; ``` Returns a 3D vector whose elements are equal to the source vector's values at the given indices. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `x_idx` | `unsigned` | | | `y_idx` | `unsigned` | | | `z_idx` | `unsigned` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::vec3::swizzle`](https://sh4zam.com/api/cpp/vec3/#swizzle) - **Type-generic form:** [`shz_vec_swizzle()`](https://sh4zam.com/api/vector/shz_vec_swizzle/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:710`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L710) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Swizzling" --- # shz_vec3_t Source: https://sh4zam.com/api/vector/shz_vec3_t/ ```c typedef struct shz_vec3 { union { float e[3]; //!< coordinates as an array struct { union { struct { float x; //!< X coordinate float y; //!< Y coordinate }; shz_vec2_t xy; //!< Inner 2D vector containing coords }; float z; //!< Z coordinate }; }; } shz_vec3_t; ``` 3D Vector type ## Fields | Field | Type | Description | | --- | --- | --- | | `e` | `float[3]` | \ coordinates as an array | | `z` | `float` | Z coordinate. | | `xy` | `shz_vec2_t` | Inner 2D vector containing \ coords. | | `x` | `float` | X coordinate. | | `y` | `float` | Y coordinate. | ## Details Structure for holding coordinates of a 3-dimensional vector. ## Availability - **C++ equivalent:** [`shz::vec3`](https://sh4zam.com/api/cpp/vec3/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:57`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L57) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Types" ## See also [`shz_vec2_t`](https://sh4zam.com/api/vector/shz_vec2_t/), [`shz_vec4_t`](https://sh4zam.com/api/vector/shz_vec4_t/) --- # shz_vec3_to Source: https://sh4zam.com/api/vector/shz_vec3_to/ > Converts the given 3D vector into a value of the given type ```c #define shz_vec3_to(type, vector) SHZ_CONVERT(type, vector) ``` Converts the given 3D `vector` into a value of the given `type`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `type` | | | | `vector` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:746`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L746) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec3_triple Source: https://sh4zam.com/api/vector/shz_vec3_triple/ > Returns the 3D vector "triple product" between vector's a, b, and c ```c SHZ_INLINE float shz_vec3_triple(shz_vec3_t a, shz_vec3_t b, shz_vec3_t c) SHZ_NOEXCEPT; ``` Returns the 3D vector "triple product" between vector's `a`, `b`, and `c`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec3_t` | | | `b` | `shz_vec3_t` | | | `c` | `shz_vec3_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec3::triple`](https://sh4zam.com/api/cpp/vec3/#triple) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:599`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L599) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Miscellaneous" --- # shz_vec3_vec4 Source: https://sh4zam.com/api/vector/shz_vec3_vec4/ > Extends a 3D vector to 4D, using w as the value of the W component ```c SHZ_INLINE shz_vec4_t shz_vec3_vec4(shz_vec3_t vec, float w) SHZ_NOEXCEPT; ``` Extends a 3D vector to 4D, using `w` as the value of the W component. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | | `w` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:697`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L697) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Extending" --- # shz_vec3 Source: https://sh4zam.com/api/vector/shz_vec3/ > Alternate typedef for the shz_vec3 struct for those who hate POSIX-style ```c typedef shz_vec3_t shz_vec3; ``` Alternate typedef for the [`shz_vec3`](https://sh4zam.com/api/vector/shz_vec3/) struct for those who hate POSIX-style. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:74`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L74) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Types" --- # shz_vec4_abs Source: https://sh4zam.com/api/vector/shz_vec4_abs/ ```c SHZ_INLINE shz_vec4_t shz_vec4_abs(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the absolute values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::abs`](https://sh4zam.com/api/cpp/vec4/#abs) - **Type-generic form:** [`shz_vec_abs()`](https://sh4zam.com/api/vector/shz_vec_abs/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:144`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L144) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_add Source: https://sh4zam.com/api/vector/shz_vec4_add/ ```c SHZ_INLINE shz_vec4_t shz_vec4_add(shz_vec4_t vec1, shz_vec4_t vec2) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the sums of the given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec4_t` | | | `vec2` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_add()`](https://sh4zam.com/api/vector/shz_vec_add/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: dedicated SPU implementation - **Defined in:** [`sh4zam/shz_vector.h:359`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L359) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec4_ceil Source: https://sh4zam.com/api/vector/shz_vec4_ceil/ ```c SHZ_INLINE shz_vec4_t shz_vec4_ceil(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the ceil of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::ceil`](https://sh4zam.com/api/cpp/vec4/#ceil) - **Type-generic form:** [`shz_vec_ceil()`](https://sh4zam.com/api/vector/shz_vec_ceil/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:207`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L207) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_clamp Source: https://sh4zam.com/api/vector/shz_vec4_clamp/ > Clamps the values of the given 4D vec between min and max, returning a new vector ```c SHZ_INLINE shz_vec4_t shz_vec4_clamp(shz_vec4_t vec, float min, float max) SHZ_NOEXCEPT; ``` Clamps the values of the given 4D `vec` between `min` and `max`, returning a new vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `min` | `float` | | | `max` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::clamp`](https://sh4zam.com/api/cpp/vec4/#clamp) - **Type-generic form:** [`shz_vec_clamp()`](https://sh4zam.com/api/vector/shz_vec_clamp/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:189`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L189) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_deref Source: https://sh4zam.com/api/vector/shz_vec4_deref/ > Dereferences the given pointer to a sequence of 4 floats as a shz_vec4_t ```c #define shz_vec4_deref(ptr) (*((SHZ_ALIASING shz_vec4_t*)(ptr))) ``` Dereferences the given pointer to a sequence of 4 floats as a [`shz_vec4_t`](https://sh4zam.com/api/vector/shz_vec4_t/). ## Parameters | Name | Type | Description | | --- | --- | --- | | `ptr` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:731`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L731) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec4_distance_sqr Source: https://sh4zam.com/api/vector/shz_vec4_distance_sqr/ ```c SHZ_INLINE float shz_vec4_distance_sqr(shz_vec4_t vec1, shz_vec4_t vec2) SHZ_NOEXCEPT; ``` Returns the squared-distance between the two given 4D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec4_t` | | | `vec2` | `shz_vec4_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec4::distance_sqr`](https://sh4zam.com/api/cpp/vec4/#distance_sqr) - **Type-generic form:** [`shz_vec_distance_sqr()`](https://sh4zam.com/api/vector/shz_vec_distance_sqr/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:508`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L508) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_distance Source: https://sh4zam.com/api/vector/shz_vec4_distance/ ```c SHZ_INLINE float shz_vec4_distance(shz_vec4_t vec1, shz_vec4_t vec2) SHZ_NOEXCEPT; ``` Returns the distance between the two given 4D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec4_t` | | | `vec2` | `shz_vec4_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec4::distance`](https://sh4zam.com/api/cpp/vec4/#distance) - **Type-generic form:** [`shz_vec_distance()`](https://sh4zam.com/api/vector/shz_vec_distance/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:499`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L499) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_div Source: https://sh4zam.com/api/vector/shz_vec4_div/ > Returns a 4D vector whose component values are those of vec1 divided by vec2 ```c SHZ_INLINE shz_vec4_t shz_vec4_div(shz_vec4_t vec1, shz_vec4_t vec2) SHZ_NOEXCEPT; ``` Returns a 4D vector whose component values are those of `vec1` divided by `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec4_t` | | | `vec2` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_div()`](https://sh4zam.com/api/vector/shz_vec_div/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: dedicated SPU implementation - **Defined in:** [`sh4zam/shz_vector.h:386`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L386) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec4_dot Source: https://sh4zam.com/api/vector/shz_vec4_dot/ ```c SHZ_INLINE float shz_vec4_dot(shz_vec4_t vec1, shz_vec4_t vec2) SHZ_NOEXCEPT; ``` Returns the dot product between the two given 4D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec4_t` | | | `vec2` | `shz_vec4_t` | | ## Returns `float` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot()`](https://sh4zam.com/api/vector/shz_vec_dot/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:484`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L484) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_dot2 Source: https://sh4zam.com/api/vector/shz_vec4_dot2/ > Returns the two dot products taken between the 4D vector l and 4D vectors r1 and r2 ```c SHZ_INLINE shz_vec2_t shz_vec4_dot2(shz_vec4_t l, shz_vec4_t r1, shz_vec4_t r2) SHZ_NOEXCEPT; ``` Returns the two dot products taken between the 4D vector `l` and 4D vectors `r1` and `r2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | `shz_vec4_t` | | | `r1` | `shz_vec4_t` | | | `r2` | `shz_vec4_t` | | ## Returns `shz_vec2_t` ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot2()`](https://sh4zam.com/api/vector/shz_vec_dot2/) - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:487`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L487) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_dot3 Source: https://sh4zam.com/api/vector/shz_vec4_dot3/ > Returns the three dot products taken between the 4D vector l and 4D vectors r1, r2, and r3 ```c SHZ_INLINE shz_vec3_t shz_vec4_dot3(shz_vec4_t l, shz_vec4_t r1, shz_vec4_t r2, shz_vec4_t r3) SHZ_NOEXCEPT; ``` Returns the three dot products taken between the 4D vector `l` and 4D vectors `r1`, `r2`, and `r3`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `l` | `shz_vec4_t` | | | `r1` | `shz_vec4_t` | | | `r2` | `shz_vec4_t` | | | `r3` | `shz_vec4_t` | | ## Returns `shz_vec3_t` ## Naming and requirements - `dot2/dot3`: Computes 2 or 3 dot products of one left-hand side against several right-hand sides in one pipelined `FIPR` sequence. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_dot3()`](https://sh4zam.com/api/vector/shz_vec_dot3/) - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:490`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L490) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_equal Source: https://sh4zam.com/api/vector/shz_vec4_equal/ ```c SHZ_INLINE bool shz_vec4_equal(shz_vec4_t a, shz_vec4_t b) SHZ_NOEXCEPT; ``` Returns true if the values of each element within the two 4D vectors are approximately equal based on relative or absolute tolerance. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec4_t` | | | `b` | `shz_vec4_t` | | ## Returns `bool` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_equal()`](https://sh4zam.com/api/vector/shz_vec_equal/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:270`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L270) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_fill Source: https://sh4zam.com/api/vector/shz_vec4_fill/ > Returns a 4D vector with the value of each component equal to v ```c SHZ_INLINE shz_vec4_t shz_vec4_fill(float v) SHZ_NOEXCEPT; ``` Returns a 4D vector with the value of each component equal to `v`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `v` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: dedicated SPU implementation - **Defined in:** [`sh4zam/shz_vector.h:128`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L128) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Initializers" --- # shz_vec4_floor Source: https://sh4zam.com/api/vector/shz_vec4_floor/ ```c SHZ_INLINE shz_vec4_t shz_vec4_floor(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the floor of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::floor`](https://sh4zam.com/api/cpp/vec4/#floor) - **Type-generic form:** [`shz_vec_floor()`](https://sh4zam.com/api/vector/shz_vec_floor/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:198`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L198) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_fract Source: https://sh4zam.com/api/vector/shz_vec4_fract/ ```c SHZ_INLINE shz_vec4_t shz_vec4_fract(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the fractional parts of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::fract`](https://sh4zam.com/api/cpp/vec4/#fract) - **Type-generic form:** [`shz_vec_fract()`](https://sh4zam.com/api/vector/shz_vec_fract/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:225`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L225) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_from Source: https://sh4zam.com/api/vector/shz_vec4_from/ > Converts the given value or expression to the equivalent 4D SH4ZAM vector value ```c #define shz_vec4_from(value) SHZ_CONVERT(shz_vec4_t, value) ``` Converts the given `value` or expression to the equivalent 4D SH4ZAM vector value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:740`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L740) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec4_init Source: https://sh4zam.com/api/vector/shz_vec4_init/ > Returns a 4D vector with the given x, y, z, and w coordinates ```c SHZ_INLINE shz_vec4_t shz_vec4_init(float x, float y, float z, float w) SHZ_NOEXCEPT; ``` Returns a 4D vector with the given `x`, `y`, `z`, and `w` coordinates. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | | `w` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:119`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L119) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Initializers" --- # shz_vec4_inv_sqrtf Source: https://sh4zam.com/api/vector/shz_vec4_inv_sqrtf/ ```c SHZ_INLINE shz_vec4_t shz_vec4_inv_sqrtf(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the inverse square root of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::inv_sqrtf`](https://sh4zam.com/api/cpp/vec4/#inv_sqrtf) - **Type-generic form:** [`shz_vec_inv_sqrtf()`](https://sh4zam.com/api/vector/shz_vec_inv_sqrtf/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: dedicated SPU implementation - **Defined in:** [`sh4zam/shz_vector.h:333`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L333) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_inv Source: https://sh4zam.com/api/vector/shz_vec4_inv/ ```c SHZ_INLINE shz_vec4_t shz_vec4_inv(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns the 4D vector whose components have been inverted or reciprocated. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::inv`](https://sh4zam.com/api/cpp/vec4/#inv) - **Type-generic form:** [`shz_vec_inv()`](https://sh4zam.com/api/vector/shz_vec_inv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:162`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L162) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_lerp Source: https://sh4zam.com/api/vector/shz_vec4_lerp/ > Returns a 4D vector that is linearly interpolated from a to b by the given 0.0f-1.0f factor, t ```c SHZ_INLINE shz_vec4_t shz_vec4_lerp(shz_vec4_t a, shz_vec4_t b, float t) SHZ_NOEXCEPT; ``` Returns a 4D vector that is linearly interpolated from `a` to `b` by the given `0.0f-1.0f` factor, `t`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec4_t` | | | `b` | `shz_vec4_t` | | | `t` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::lerp`](https://sh4zam.com/api/cpp/vec4/#lerp) - **Type-generic form:** [`shz_vec_lerp()`](https://sh4zam.com/api/vector/shz_vec_lerp/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:526`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L526) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_magnitude_inv Source: https://sh4zam.com/api/vector/shz_vec4_magnitude_inv/ ```c SHZ_INLINE float shz_vec4_magnitude_inv(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns the inverse magnitude of the given 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec4::magnitude_inv`](https://sh4zam.com/api/cpp/vec4/#magnitude_inv) - **Type-generic form:** [`shz_vec_magnitude_inv()`](https://sh4zam.com/api/vector/shz_vec_magnitude_inv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:429`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L429) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec4_magnitude_sqr Source: https://sh4zam.com/api/vector/shz_vec4_magnitude_sqr/ ```c SHZ_INLINE float shz_vec4_magnitude_sqr(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns the squared magnitude of the given 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec4::magnitude_sqr`](https://sh4zam.com/api/cpp/vec4/#magnitude_sqr) - **Type-generic form:** [`shz_vec_magnitude_sqr()`](https://sh4zam.com/api/vector/shz_vec_magnitude_sqr/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:408`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L408) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec4_magnitude Source: https://sh4zam.com/api/vector/shz_vec4_magnitude/ ```c SHZ_INLINE float shz_vec4_magnitude(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns the magnitude of the given 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec4::magnitude`](https://sh4zam.com/api/cpp/vec4/#magnitude) - **Type-generic form:** [`shz_vec_magnitude()`](https://sh4zam.com/api/vector/shz_vec_magnitude/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:420`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L420) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec4_max Source: https://sh4zam.com/api/vector/shz_vec4_max/ ```c SHZ_INLINE float shz_vec4_max(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns the maximum value of the given vector's 4 componetns. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec4::max`](https://sh4zam.com/api/cpp/vec4/#max) - **Type-generic form:** [`shz_vec_max()`](https://sh4zam.com/api/vector/shz_vec_max/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:171`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L171) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_maxv Source: https://sh4zam.com/api/vector/shz_vec4_maxv/ ```c SHZ_INLINE shz_vec4_t shz_vec4_maxv(shz_vec4_t a, shz_vec4_t b) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the pairwise maximums of the two given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec4_t` | | | `b` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::maxv`](https://sh4zam.com/api/cpp/vec4/#maxv) - **Type-generic form:** [`shz_vec_maxv()`](https://sh4zam.com/api/vector/shz_vec_maxv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:261`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L261) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_min Source: https://sh4zam.com/api/vector/shz_vec4_min/ ```c SHZ_INLINE float shz_vec4_min(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns the minimum value of the given vector's 4 components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::vec4::min`](https://sh4zam.com/api/cpp/vec4/#min) - **Type-generic form:** [`shz_vec_min()`](https://sh4zam.com/api/vector/shz_vec_min/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:180`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L180) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_minv Source: https://sh4zam.com/api/vector/shz_vec4_minv/ ```c SHZ_INLINE shz_vec4_t shz_vec4_minv(shz_vec4_t a, shz_vec4_t b) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the pairwise minimums of the two given vectors' components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `a` | `shz_vec4_t` | | | `b` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::minv`](https://sh4zam.com/api/cpp/vec4/#minv) - **Type-generic form:** [`shz_vec_minv()`](https://sh4zam.com/api/vector/shz_vec_minv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:252`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L252) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_move Source: https://sh4zam.com/api/vector/shz_vec4_move/ > Returns the given 4D vector, translated towards the target by the given max_distance ```c SHZ_INLINE shz_vec4_t shz_vec4_move(shz_vec4_t vec, shz_vec4_t target, float max_distance) SHZ_NOEXCEPT; ``` Returns the given 4D vector, translated towards the `target` by the given `max_distance`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `target` | `shz_vec4_t` | | | `max_distance` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::move`](https://sh4zam.com/api/cpp/vec4/#move) - **Type-generic form:** [`shz_vec_move()`](https://sh4zam.com/api/vector/shz_vec_move/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:517`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L517) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_mul Source: https://sh4zam.com/api/vector/shz_vec4_mul/ > Returns a 4D vector whose component values are those of vec1 times vec2 ```c SHZ_INLINE shz_vec4_t shz_vec4_mul(shz_vec4_t vec1, shz_vec4_t vec2) SHZ_NOEXCEPT; ``` Returns a 4D vector whose component values are those of `vec1` times `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec4_t` | | | `vec2` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_mul()`](https://sh4zam.com/api/vector/shz_vec_mul/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: dedicated SPU implementation - **Defined in:** [`sh4zam/shz_vector.h:377`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L377) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec4_neg Source: https://sh4zam.com/api/vector/shz_vec4_neg/ ```c SHZ_INLINE shz_vec4_t shz_vec4_neg(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the negative values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::neg`](https://sh4zam.com/api/cpp/vec4/#neg) - **Type-generic form:** [`shz_vec_neg()`](https://sh4zam.com/api/vector/shz_vec_neg/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:153`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L153) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_normalize_safe Source: https://sh4zam.com/api/vector/shz_vec4_normalize_safe/ ```c SHZ_INLINE shz_vec4_t shz_vec4_normalize_safe(shz_vec4_t vec) SHZ_NOEXCEPT; ``` SAFELY returns a normalized unit vector from the given 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_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::vec4::direction_safe`](https://sh4zam.com/api/cpp/vec4/#direction_safe), [`shz::vec4::normalize_safe`](https://sh4zam.com/api/cpp/vec4/#normalize_safe), [`shz::vec4::normalized_safe`](https://sh4zam.com/api/cpp/vec4/#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:456`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L456) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec4_normalize Source: https://sh4zam.com/api/vector/shz_vec4_normalize/ ```c SHZ_INLINE shz_vec4_t shz_vec4_normalize(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a normalized unit vector from the given 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::direction`](https://sh4zam.com/api/cpp/vec4/#direction), [`shz::vec4::normalize`](https://sh4zam.com/api/cpp/vec4/#normalize), [`shz::vec4::normalized`](https://sh4zam.com/api/cpp/vec4/#normalized) - **Type-generic form:** [`shz_vec_normalize()`](https://sh4zam.com/api/vector/shz_vec_normalize/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:438`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L438) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Magnitude" --- # shz_vec4_project_safe Source: https://sh4zam.com/api/vector/shz_vec4_project_safe/ ```c SHZ_INLINE shz_vec4_t shz_vec4_project_safe(shz_vec4_t vec, shz_vec4_t onto) SHZ_NOEXCEPT; ``` Returns the resulting vector from projecting the given 4D vector along the given (unit) axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `onto` | `shz_vec4_t` | | ## Returns `shz_vec4_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::vec4::project_safe`](https://sh4zam.com/api/cpp/vec4/#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:586`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L586) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_project Source: https://sh4zam.com/api/vector/shz_vec4_project/ ```c SHZ_INLINE shz_vec4_t shz_vec4_project(shz_vec4_t vec, shz_vec4_t onto) SHZ_NOEXCEPT; ``` Returns the resulting vector from projecting the given 4D vector along the given (unit) axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `onto` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::project`](https://sh4zam.com/api/cpp/vec4/#project) - **Type-generic form:** [`shz_vec_project()`](https://sh4zam.com/api/vector/shz_vec_project/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:565`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L565) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_reflect Source: https://sh4zam.com/api/vector/shz_vec4_reflect/ > Reflects the given 4D incidence vector against a surface with the given normal, returning the result ```c SHZ_INLINE shz_vec4_t shz_vec4_reflect(shz_vec4_t incidence, shz_vec4_t normal) SHZ_NOEXCEPT; ``` Reflects the given 4D `incidence` vector against a surface with the given `normal`, returning the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `incidence` | `shz_vec4_t` | | | `normal` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::reflect`](https://sh4zam.com/api/cpp/vec4/#reflect) - **Type-generic form:** [`shz_vec_reflect()`](https://sh4zam.com/api/vector/shz_vec_reflect/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:535`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L535) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_refract Source: https://sh4zam.com/api/vector/shz_vec4_refract/ > Refracts the given 4D incidence vector against a surface with the given normal using the given refraction index ratio, eta ```c SHZ_INLINE shz_vec4_t shz_vec4_refract(shz_vec4_t incidence, shz_vec4_t normal, float eta) SHZ_NOEXCEPT; ``` Refracts the given 4D `incidence` vector against a surface with the given `normal` using the given refraction index ratio, `eta`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `incidence` | `shz_vec4_t` | | | `normal` | `shz_vec4_t` | | | `eta` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::refract`](https://sh4zam.com/api/cpp/vec4/#refract) - **Type-generic form:** [`shz_vec_refract()`](https://sh4zam.com/api/vector/shz_vec_refract/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:544`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L544) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Binary Operations" --- # shz_vec4_round Source: https://sh4zam.com/api/vector/shz_vec4_round/ ```c SHZ_INLINE shz_vec4_t shz_vec4_round(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the rounded values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::round`](https://sh4zam.com/api/cpp/vec4/#round) - **Type-generic form:** [`shz_vec_round()`](https://sh4zam.com/api/vector/shz_vec_round/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:216`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L216) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_saturate Source: https://sh4zam.com/api/vector/shz_vec4_saturate/ > Returns a 4D vector whose components are saturated (clamped to [0, 1]) values of the given vector's components ```c SHZ_INLINE shz_vec4_t shz_vec4_saturate(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are saturated (clamped to \[0, 1\]) values of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::saturate`](https://sh4zam.com/api/cpp/vec4/#saturate) - **Type-generic form:** [`shz_vec_saturate()`](https://sh4zam.com/api/vector/shz_vec_saturate/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:243`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L243) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_scale Source: https://sh4zam.com/api/vector/shz_vec4_scale/ ```c SHZ_INLINE shz_vec4_t shz_vec4_scale(shz_vec4_t vec, float factor) SHZ_NOEXCEPT; ``` Returns a 4D vector whose component values are those of the given vector multiplied by a factor. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `factor` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_scale()`](https://sh4zam.com/api/vector/shz_vec_scale/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:395`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L395) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec4_sign Source: https://sh4zam.com/api/vector/shz_vec4_sign/ ```c SHZ_INLINE shz_vec4_t shz_vec4_sign(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the signs (-1, 0, or 1) of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::sign`](https://sh4zam.com/api/cpp/vec4/#sign) - **Type-generic form:** [`shz_vec_sign()`](https://sh4zam.com/api/vector/shz_vec_sign/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:234`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L234) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_smoothstep_safe Source: https://sh4zam.com/api/vector/shz_vec4_smoothstep_safe/ ```c SHZ_INLINE shz_vec4_t shz_vec4_smoothstep_safe(shz_vec4_t vec, float edge0, float edge1) SHZ_NOEXCEPT; ``` For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `edge0` | `float` | | | `edge1` | `float` | | ## Returns `shz_vec4_t` ## 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::vec4::smoothstep_safe`](https://sh4zam.com/api/cpp/vec4/#smoothstep_safe) - **Type-generic form:** [`shz_vec_smoothstep_safe()`](https://sh4zam.com/api/vector/shz_vec_smoothstep_safe/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:315`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L315) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_smoothstep Source: https://sh4zam.com/api/vector/shz_vec4_smoothstep/ ```c SHZ_INLINE shz_vec4_t shz_vec4_smoothstep(shz_vec4_t vec, float edge0, float edge1) SHZ_NOEXCEPT; ``` For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `edge0` | `float` | | | `edge1` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::smoothstep`](https://sh4zam.com/api/cpp/vec4/#smoothstep) - **Type-generic form:** [`shz_vec_smoothstep()`](https://sh4zam.com/api/vector/shz_vec_smoothstep/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:297`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L297) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_smoothstepv_safe Source: https://sh4zam.com/api/vector/shz_vec4_smoothstepv_safe/ > For each component i: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between. Accepts inverse edges ```c SHZ_INLINE shz_vec4_t shz_vec4_smoothstepv_safe(shz_vec4_t vec, shz_vec4_t edge0, shz_vec4_t edge1) SHZ_NOEXCEPT; ``` For each component i: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. Accepts inverse edges. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `edge0` | `shz_vec4_t` | | | `edge1` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## 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:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_smoothstepv_safe()`](https://sh4zam.com/api/vector/shz_vec_smoothstepv_safe/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:324`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L324) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_smoothstepv Source: https://sh4zam.com/api/vector/shz_vec4_smoothstepv/ > For each component i: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between ```c SHZ_INLINE shz_vec4_t shz_vec4_smoothstepv(shz_vec4_t vec, shz_vec4_t edge0, shz_vec4_t edge1) SHZ_NOEXCEPT; ``` For each component i: returns 0.0f at/below edge0\[i\], 1.0f at/above edge1\[i\], smoothly varying in-between. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `edge0` | `shz_vec4_t` | | | `edge1` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_smoothstepv()`](https://sh4zam.com/api/vector/shz_vec_smoothstepv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:306`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L306) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_sqrtf Source: https://sh4zam.com/api/vector/shz_vec4_sqrtf/ ```c SHZ_INLINE shz_vec4_t shz_vec4_sqrtf(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are the square root of the given vector's components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::sqrtf`](https://sh4zam.com/api/cpp/vec4/#sqrtf) - **Type-generic form:** [`shz_vec_sqrtf()`](https://sh4zam.com/api/vector/shz_vec_sqrtf/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:342`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L342) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_step Source: https://sh4zam.com/api/vector/shz_vec4_step/ > For each component: returns 0.0f if vec[i] < edge, otherwise 1.0f ```c SHZ_INLINE shz_vec4_t shz_vec4_step(shz_vec4_t vec, float edge) SHZ_NOEXCEPT; ``` For each component: returns 0.0f if vec\[i\] \< edge, otherwise 1.0f. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `edge` | `float` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::step`](https://sh4zam.com/api/cpp/vec4/#step) - **Type-generic form:** [`shz_vec_step()`](https://sh4zam.com/api/vector/shz_vec_step/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:288`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L288) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_stepv Source: https://sh4zam.com/api/vector/shz_vec4_stepv/ > For each component: returns 0.0f if vec[i] < edge[i], otherwise 1.0f ```c SHZ_INLINE shz_vec4_t shz_vec4_stepv(shz_vec4_t vec, shz_vec4_t edge) SHZ_NOEXCEPT; ``` For each component: returns 0.0f if vec\[i\] \< edge\[i\], otherwise 1.0f. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `edge` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_stepv()`](https://sh4zam.com/api/vector/shz_vec_stepv/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:279`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L279) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Component-wise Operations" --- # shz_vec4_sub Source: https://sh4zam.com/api/vector/shz_vec4_sub/ > Returns a 4D vector whose components are equal to the values of vec1 minus vec2 ```c SHZ_INLINE shz_vec4_t shz_vec4_sub(shz_vec4_t vec1, shz_vec4_t vec2) SHZ_NOEXCEPT; ``` Returns a 4D vector whose components are equal to the values of `vec1` minus `vec2`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec1` | `shz_vec4_t` | | | `vec2` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** [`shz_vec_sub()`](https://sh4zam.com/api/vector/shz_vec_sub/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: dedicated SPU implementation - **Defined in:** [`sh4zam/shz_vector.h:368`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L368) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Arithmetic" --- # shz_vec4_swizzle Source: https://sh4zam.com/api/vector/shz_vec4_swizzle/ ```c SHZ_INLINE shz_vec4_t shz_vec4_swizzle(shz_vec4_t vec, unsigned x_idx, unsigned y_idx, unsigned z_idx, unsigned w_idx) SHZ_NOEXCEPT; ``` Returns a new 2D vector whose elements are equal to the source vector's values at the given indices. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | | `x_idx` | `unsigned` | | | `y_idx` | `unsigned` | | | `z_idx` | `unsigned` | | | `w_idx` | `unsigned` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::vec4::swizzle`](https://sh4zam.com/api/cpp/vec4/#swizzle) - **Type-generic form:** [`shz_vec_swizzle()`](https://sh4zam.com/api/vector/shz_vec_swizzle/) - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_vector.h:713`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L713) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Swizzling" --- # shz_vec4_t Source: https://sh4zam.com/api/vector/shz_vec4_t/ ```c typedef struct shz_vec4 { union { float e SHZ_SIMD(16); //!< coordinates as an array. struct { union { struct { float x; //!< X coordinate float y; //!< Y coordinate float z; //!< Z coordinate }; shz_vec3_t xyz; //!< coordinates as a 3D vector }; float w; //!< W coordinate }; struct { shz_vec2_t xy; //!< coordinates as a 2D vector shz_vec2_t zw; //!< coordinates as a 2D vector }; }; } shz_vec4_t; ``` 4D Vector type ## Fields | Field | Type | Description | | --- | --- | --- | | `w` | `float` | W coordinate. | | `xyz` | `shz_vec3_t` | \ coordinates as a 3D vector | | `x` | `float` | X coordinate. | | `y` | `float` | Y coordinate. | | `z` | `float` | Z coordinate. | | `xy` | `shz_vec2_t` | \ coordinates as a 2D vector | | `zw` | `shz_vec2_t` | \ coordinates as a 2D vector | ## Details Structure for holding coordinates of a 4-dimensional vector. ## Availability - **C++ equivalent:** [`shz::vec4`](https://sh4zam.com/api/cpp/vec4/) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:82`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L82) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Types" ## See also [`shz_vec2_t`](https://sh4zam.com/api/vector/shz_vec2_t/), [`shz_vec3_t`](https://sh4zam.com/api/vector/shz_vec3_t/) --- # shz_vec4_to Source: https://sh4zam.com/api/vector/shz_vec4_to/ > Converts the given 4D vector into a value of the given type ```c #define shz_vec4_to(type, vector) SHZ_CONVERT(type, vector) ``` Converts the given 4D `vector` into a value of the given `type`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `type` | | | | `vector` | | | ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:749`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L749) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Adapters" --- # shz_vec4 Source: https://sh4zam.com/api/vector/shz_vec4/ > Alternate typedef for the shz_vec4 struct for those who hate POSIX-style ```c typedef shz_vec4_t shz_vec4; ``` Alternate typedef for the [`shz_vec4`](https://sh4zam.com/api/vector/shz_vec4/) struct for those who hate POSIX-style. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_vector.h:105`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_vector.h#L105) - **Module:** [Vector](https://sh4zam.com/api/vector/), section "Types" --- # Version API Source: https://sh4zam.com/api/version/ > Compile-time and link-time version checking of the SH4ZAM library This file provides the utility macros and constants needed for implementing compile/link-time version checking of the SH4ZAM library. `SHZ_VERSION_INIT()` packs major, minor and patch fields into a single unsigned 32-bit value that can be compared for equality or inequality. `shz_version_linked()` returns the version of the library you actually linked against, so it can be checked against the headers you compiled with. - **C header:** `#include ` - **C++ header:** `#include ` - **C++ types:** [`shz::version`](https://sh4zam.com/api/cpp/version/) - **Symbols:** 9 ## Compile-Time Utilities Constants and methods for checking the compile-time SH4ZAM version. | Symbol | Description | | --- | --- | | [`SHZ_VERSION_MAJOR`](https://sh4zam.com/api/version/SHZ_VERSION_MAJOR/) | Compile-time SH4ZAM major version. | | [`SHZ_VERSION_MINOR`](https://sh4zam.com/api/version/SHZ_VERSION_MINOR/) | Compile-time SH4ZAM minor version. | | [`SHZ_VERSION_PATCH`](https://sh4zam.com/api/version/SHZ_VERSION_PATCH/) | Compile-time Sh4ZAM patch version. | | [`SHZ_VERSION`](https://sh4zam.com/api/version/SHZ_VERSION/) | Current SH4ZAM full compile-time version identifier, integer-compatible. | | [`SHZ_VERSION_INIT`](https://sh4zam.com/api/version/SHZ_VERSION_INIT/) | Packs values of individual version components into a SH4ZAM full version value. | ## Link-Time Utilities Methods for checking the link-time SH4ZAM version. | Symbol | Description | | --- | --- | | [`shz_version_t`](https://sh4zam.com/api/version/shz_version_t/) | Integer-compatible value type containing a full SH4ZAM version. | | [`shz_version`](https://sh4zam.com/api/version/shz_version-typedef/) | Version typedef for those who hate POSIX-style. | | [`shz_version_linked`](https://sh4zam.com/api/version/shz_version_linked/) | Returns the full version of SH4ZAM that was linked against. | | [`shz_version_fields`](https://sh4zam.com/api/version/shz_version_fields/) | Extracts the individual version component values from a full version. | --- # shz_version_fields Source: https://sh4zam.com/api/version/shz_version_fields/ ```c void shz_version_fields(shz_version_t version, uint8_t* major, uint16_t* minor, uint8_t* patch); ``` Extracts the individual version component values from a full version. ## Parameters | Name | Type | Description | | --- | --- | --- | | `version` | `shz_version_t` | | | `major` | `uint8_t *` | | | `minor` | `uint16_t *` | | | `patch` | `uint8_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_version.h:64`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L64) - **Module:** [Version](https://sh4zam.com/api/version/), section "Link-Time Utilities" --- # SHZ_VERSION_INIT Source: https://sh4zam.com/api/version/SHZ_VERSION_INIT/ ```c #define SHZ_VERSION_INIT(major, minor, patch) ``` Packs values of individual version components into a SH4ZAM full version value. ## Parameters | Name | Type | Description | | --- | --- | --- | | `major` | | Unsigned 8-bit field representing major version value. | | `minor` | | Unsigned 16-bit field representing minor version value. | | `patch` | | Unsigned 8-bit field representing patch version value. | ## Details Combines values from individual version components into a single unsigned 32-bit integer which can be compared to other version values for equality or inequality. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_version.h:44`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L44) - **Module:** [Version](https://sh4zam.com/api/version/), section "Compile-Time Utilities" --- # shz_version_linked Source: https://sh4zam.com/api/version/shz_version_linked/ ```c shz_version_t shz_version_linked(void); ``` Returns the full version of SH4ZAM that was linked against. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns `shz_version_t` ## Availability - **C++ equivalent:** [`shz::version::linked`](https://sh4zam.com/api/cpp/version/#linked) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_version.h:61`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L61) - **Module:** [Version](https://sh4zam.com/api/version/), section "Link-Time Utilities" --- # SHZ_VERSION_MAJOR Source: https://sh4zam.com/api/version/SHZ_VERSION_MAJOR/ ```c #define SHZ_VERSION_MAJOR 0 ``` Compile-time SH4ZAM major version. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_version.h:25`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L25) - **Module:** [Version](https://sh4zam.com/api/version/), section "Compile-Time Utilities" --- # SHZ_VERSION_MINOR Source: https://sh4zam.com/api/version/SHZ_VERSION_MINOR/ ```c #define SHZ_VERSION_MINOR 9 ``` Compile-time SH4ZAM minor version. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_version.h:26`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L26) - **Module:** [Version](https://sh4zam.com/api/version/), section "Compile-Time Utilities" --- # SHZ_VERSION_PATCH Source: https://sh4zam.com/api/version/SHZ_VERSION_PATCH/ ```c #define SHZ_VERSION_PATCH 1 ``` Compile-time Sh4ZAM patch version. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_version.h:27`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L27) - **Module:** [Version](https://sh4zam.com/api/version/), section "Compile-Time Utilities" --- # shz_version_t Source: https://sh4zam.com/api/version/shz_version_t/ ```c typedef uint32_t shz_version_t; ``` Integer-compatible value type containing a full SH4ZAM version. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_version.h:55`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L55) - **Module:** [Version](https://sh4zam.com/api/version/), section "Link-Time Utilities" --- # shz_version Source: https://sh4zam.com/api/version/shz_version-typedef/ ```c typedef shz_version_t shz_version; ``` Version typedef for those who hate POSIX-style. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_version.h:58`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L58) - **Module:** [Version](https://sh4zam.com/api/version/), section "Link-Time Utilities" --- # SHZ_VERSION Source: https://sh4zam.com/api/version/SHZ_VERSION/ ```c #define SHZ_VERSION ``` Current SH4ZAM full compile-time version identifier, integer-compatible. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_version.h:30`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_version.h#L30) - **Module:** [Version](https://sh4zam.com/api/version/), section "Compile-Time Utilities" --- # XMTRX API Source: https://sh4zam.com/api/xmtrx/ > API for managing the SH4's "active matrix", the 16 back-bank FP registers `XMTRX` is the name given to identify the 16 FP registers contained within the back-bank of the SH4's FPU. These 16 registers combine to represent the SH4's 4x4 "active matrix", which can be subsequently transformed against using the `FTRV` instruction (`shz_xmtrx_transform_vec4()`). For maximum FP performance on the SH4, strategic usage of `XMTRX` to batch transform operations together without having to reload FP registers is key. Typically, for one-off operations, the in-memory Matrix API is what should be used; however, when operations can be batched, using `XMTRX` to hold your matrix within registers is going to give the best performance. Unless TLS has been disabled, the XMTRX API is thread-safe, with each thread getting its own unique copy of XMTRX. - **C header:** `#include ` - **C++ header:** `#include ` - **C++ types:** [`shz::xmtrx`](https://sh4zam.com/api/cpp/xmtrx/) - **Symbols:** 140 ## Verb model For most transform types this API offers several versions of the same operation. Using translation as the example: | Verb | Meaning | | --- | --- | | `init_*` | **Initializes** the whole matrix to the given transform, setting the other components to identity. | | `set_*` | **Sets** only the values corresponding to the given transform, leaving the others alone. | | `apply_*` | **Applies** the transform, updating only the affected values based on their current values (additively for translation, multiplicatively for scaling and rotation). | | `translate / scale / rotate_*` | **GL-style**: multiplies and accumulates the matrix by a matrix initialized to the given transform. The most general form. | | `load_* / store_*` | Moves a matrix between memory and XMTRX. `load_apply_*` and `load_apply_store_*` are fused combinations. | | `transform_*` | Transforms vectors or points. For `vec3` variants, `transform_point*` implies w = 1 and `transform_vec*` implies w = 0. | ## Suffixes Suffixes used in this module. The full list is in [Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/). - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). - `_safe`: Guards degenerate input (zero-length vectors, zero denominators) at a small cost. ## Accessors Setting and retrieving individual XMTRX register values. | Symbol | Description | | --- | --- | | [`shz_xmtrx_read`](https://sh4zam.com/api/xmtrx/shz_xmtrx_read/) | Returns the floating-point value held within the given XMTRX register. | | [`shz_xmtrx_write`](https://sh4zam.com/api/xmtrx/shz_xmtrx_write/) | Sets the floating-point value held within the given XMTRX register to `value`. | | [`shz_xmtrx_read_row`](https://sh4zam.com/api/xmtrx/shz_xmtrx_read_row/) | Returns the values at the the given row `index`, as a 4D vector. | | [`shz_xmtrx_read_col`](https://sh4zam.com/api/xmtrx/shz_xmtrx_read_col/) | Returns the values at the given column `index`, as a 4D vector. | | [`shz_xmtrx_write_row`](https://sh4zam.com/api/xmtrx/shz_xmtrx_write_row/) | Sets the values at the given row `index` to the given 4D vector. | | [`shz_xmtrx_write_col`](https://sh4zam.com/api/xmtrx/shz_xmtrx_write_col/) | Sets the values at the given column `index` to the given 4D vector. | | [`shz_xmtrx_swap_rows`](https://sh4zam.com/api/xmtrx/shz_xmtrx_swap_rows/) | Swaps the values of the rows with the given indices. | | [`shz_xmtrx_swap_cols`](https://sh4zam.com/api/xmtrx/shz_xmtrx_swap_cols/) | Swaps the values of the columns with the given indices. | ## Loading Routines for loading XMTRX contents from memory. | Symbol | Description | | --- | --- | | [`shz_xmtrx_load_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_4x4/) | Loads the given 4x4 matrix as XMTRX. | | [`shz_xmtrx_load_wxyz_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_wxyz_4x4/) | Loads the given 4x4 matrix as XMTRX, with the 4th column for translation being loaded as the first column. | | [`shz_xmtrx_load_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_unaligned_4x4/) | Loads the given array of unaligned 16 float values as the 4x4 XMTRX matrix. | | [`shz_xmtrx_load_cols_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_4x4/) | Sets XMTRX equal to the 4x4 matrix created from the 4 given 4D column vectors. | | [`shz_xmtrx_load_rows_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_rows_4x4/) | Sets XMTRX equal to the 4x4 matrix created from the 4 given 4D row vectors. | | [`shz_xmtrx_load_transpose_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_4x4/) | Loads XMTRX with the transpose of the given 4x4 matrix. | | [`shz_xmtrx_load_transpose_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_unaligned_4x4/) | Loads XMTRX with the transpose of the 4x4 matrix created from the given unaligned array of 16 floats. | | [`shz_xmtrx_load_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x4/) | Loads the given 3x4 matrix into XMTRX, initializing its remaining elements to identity. | | [`shz_xmtrx_load_transpose_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_3x4/) | Loads XMTRX with the transpose of the given 3x4 matrix, initializing the bottom row to identity. | | [`shz_xmtrx_load_cols_4x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_4x3/) | Loads the 3x4 matrix formed from the given 3 4D column vectors into XMTRX. | | [`shz_xmtrx_load_rows_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_rows_3x4/) | Loads the 3x4 matrix formed from the given 3 4D row vectors into XMTRX. | | [`shz_xmtrx_load_cols_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_3x4/) | Loads the 3x4 matrix formed from the given 4 3D column vectors into XMTRX. | | [`shz_xmtrx_load_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x3/) | Loads the given 3x3 matrix into XMTRX, initalizing its remaining elements to identity. | | [`shz_xmtrx_load_transpose_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_3x3/) | Loads the transpose of the given 3x3 matrix into XMTRX, initializing its remaining elements to identity. | | [`shz_xmtrx_load_2x2`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_2x2/) | Loads the given 2x2 matrix into XMTRX, initializing its remaining elements to identity. | ## Storing Routines for saving XMTRX contents to memory. | Symbol | Description | | --- | --- | | [`shz_xmtrx_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_4x4/) | Stores the current values held within XMTRX into the given 4x4 matrix. | | [`shz_xmtrx_store_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_unaligned_4x4/) | Stores the current values held within XMTRX into the given unaligned 16-float array. | | [`shz_xmtrx_store_transpose_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_4x4/) | Stores the transpose of the current values held within XMTRX into the given 4x4 matrix. | | [`shz_xmtrx_store_transpose_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_unaligned_4x4/) | Stores the transpose of the the current values held within XMTRX into the given 16-element float array. | | [`shz_xmtrx_store_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x4/) | Stores the top-left 3x4 values currently held within XMTRX into the given matrix. | | [`shz_xmtrx_store_transpose_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_3x4/) | Stores the transpose of the top-left 3x4 values currently held within XMTRX into the given matrix. | | [`shz_xmtrx_store_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x3/) | Stores the top-left 3x3 values currently held within XMTRX into the given matrix. | | [`shz_xmtrx_store_transpose_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_3x3/) | Stores the transpose of the top-left 3x3 values currently held within XMTRX into the given matrix. | | [`shz_xmtrx_store_2x2`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_2x2/) | Stores the top-left 2x2 values currently held within XMTRX into the given matrix. | ## Initialization Routines used to initialize the entirety of XMTRX. | Symbol | Description | | --- | --- | | [`shz_xmtrx_init_identity`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_identity/) | Initializes XMTRX to the 4x4 identity matrix. | | [`shz_xmtrx_init_identity_safe`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_identity_safe/) | Safely initializes XMTRX to be a 4D identity matrix. | | [`shz_xmtrx_init_zero`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_zero/) | Initializes XMTRX to contain the value of 0.0f for each element. | | [`shz_xmtrx_init_one`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_one/) | Initializes XMTRX to contain the value of 1.0f for each element. | | [`shz_xmtrx_init_fill`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_fill/) | Initializes XMTRX to contain the given `value` for each element. | | [`shz_xmtrx_init_translation`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_translation/) | Initializes XMTRX to be a 3D translation matrix to the given coordinates. | | [`shz_xmtrx_init_scale`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_scale/) | Initializes XMTRX to be a 3D scale matrix with the given dimensions. | | [`shz_xmtrx_init_rotation_x`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_x/) | Initializes XMTRX to be a 3D rotation matrix by `x` radians about the X axis. | | [`shz_xmtrx_init_rotation_y`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_y/) | Initializes XMTRX to be a 3D rotation matrix by `y` radians about the Y axis. | | [`shz_xmtrx_init_rotation_z`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_z/) | Initializes XMTRX to be a 3D rotation matrix by `z` radians about the Z axis. | | [`shz_xmtrx_init_rotation_xyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_xyz/) | Initializes XMTRX to be a 3D X-Y-Z rotation matrix, with the corresponding angles given in radians. | | [`shz_xmtrx_init_rotation_zyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_zyx/) | Initializes XMTRX to be a 3D Z-Y-X rotation matrix, with the corresponding angles given in radians. | | [`shz_xmtrx_init_rotation_zxy`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_zxy/) | Initializes XMTRX to be a 3D Z-X-Y rotation matrix, with the corresponding angles given in radians. | | [`shz_xmtrx_init_rotation_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_yxz/) | Initializes XMTRX to be a 3D Y-X-Z rotation matrix, with the corresponding angles given in radians. | | [`shz_xmtrx_init_rotation`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation/) | Initializes XMTRX to a 3D rotation matrix of `angle` radians about the vector with the given components. | | [`shz_xmtrx_init_rotation_dir`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_dir/) | Initializes XMTRX to contain a 3D rotation matrix of `angle` radians about the given `axis`. | | [`shz_xmtrx_init_diagonal`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_diagonal/) | Initializes XMTRX to be a diagonal matrix with the given diagonal values. | | [`shz_xmtrx_init_upper_triangular`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_upper_triangular/) | Initializes XMTRX to be an upper triangular matrix with the given column values. | | [`shz_xmtrx_init_lower_triangular`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_lower_triangular/) | Initializes XMTRX to be a lower triangular matrix with the given column values. | | [`shz_xmtrx_init_symmetric_skew`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_symmetric_skew/) | Initializes XMTRX to be the 3D symmetric skew matrix formed from the given vector components. | | [`shz_xmtrx_init_outer_product`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_outer_product/) | Initializes XMTRX to the 4D matrix resulting from taking the outer product of the two 4D vectors. | | [`shz_xmtrx_init_permutation_wxyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_wxyz/) | Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order. | | [`shz_xmtrx_init_permutation_yzwx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_yzwx/) | Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be in YZWX order. | | [`shz_xmtrx_init_permutation_wzyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_wzyx/) | Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be in WZYX order. | | [`shz_xmtrx_init_screen`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_screen/) | Initializes XMTRX to the viewport matrix with the given dimensions. | | [`shz_xmtrx_init_lookat`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_lookat/) | Initializes XMTRX to a "lookAt" view matrix, equivalent to gluLookAt(). | | [`shz_xmtrx_init_ortho`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_ortho/) | Initializes XMTRX to an orthographic projection matrix, equivalent to glOrtho(). | | [`shz_xmtrx_init_frustum`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_frustum/) | Initializes XMTRX to a frustum projection matrix, equivalent to glFrustum(). | | [`shz_xmtrx_init_perspective`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_perspective/) | Initializes XMTRX to a perspective projection matrix. | | [`shz_xmtrx_init_rotation_quat`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_quat/) | Initializes XMTRX to a 3D rotation matrix with its orientation given by a quaternion. | ## Apply Operation Updates only relevant values of XMTRX based on the given transform. | Symbol | Description | | --- | --- | | [`shz_xmtrx_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_4x4/) | Multiplies and accumulates the given 4x4 matrix onto XMTRX. | | [`shz_xmtrx_apply_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_unaligned_4x4/) | Multiplies and accumulates the given 16-entry float array as a 4x4 matrix onto XMTRX. | | [`shz_xmtrx_apply_transpose_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_4x4/) | Multiplies and accumulates the transpose of the given 4x4 matrix onto XMTRX. | | [`shz_xmtrx_apply_transpose_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_unaligned_4x4/) | Multiplies and accumulates the transpose of the given 16-entry float array as a 4x4 matrix onto XMTRX. | | [`shz_xmtrx_apply_reverse_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_4x4/) | Multiplies and accumulates XMTRX onto `matrix`, storing the result as XMTRX. | | [`shz_xmtrx_apply_reverse_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_unaligned_4x4/) | Multiplies and accumulates XMTRX onto the given float array as a 4x4 matrix, storing the result as XMTRX. | | [`shz_xmtrx_apply_reverse_transpose_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_4x4/) | Multiplies and accumulates XMTRX onto the transpose of `matrix`, storing the result as XMTRX. | | [`shz_xmtrx_apply_reverse_transpose_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_unaligned_4x4/) | Multiplies and accumulates XMTRX onto the transpose of the given float array as a 4x4 matrix, storing the result as XMTRX. | | [`shz_xmtrx_apply_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x4/) | Multiplies and accumulates the given 3x4 matrix onto XMTRX, not modifying other elements. | | [`shz_xmtrx_apply_transpose_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_3x4/) | Multiplies and accumulates the transpose of the given 3x4 matrix onto XMTRX, not modifying other elements. | | [`shz_xmtrx_apply_reverse_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_3x4/) | Multiplies and accumulates XMTRX onto `matrix`, storing the result as XMTRX. | | [`shz_xmtrx_apply_reverse_transpose_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_3x4/) | Multiplies and accumulates XMTRX onto the transpose of `matrix`, storing the result as XMTRX. | | [`shz_xmtrx_apply_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x3/) | Multiplies and accumulates the given 3x3 matrix onto XMTRX, not modifying other elements. | | [`shz_xmtrx_apply_transpose_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_3x3/) | Multiplies and accumulates the transpose of the given 3x3 matrix onto XMTRX, not modifying other elements. | | [`shz_xmtrx_apply_2x2`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_2x2/) | Multiplies and accumulates the given 2x2 matrix onto XMTRX, not modifying other elements. | | [`shz_xmtrx_apply_translation`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_translation/) | Adds the values of the given 3 components to the 3D translation components of XMTRX. | | [`shz_xmtrx_apply_scale`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_scale/) | Multiplies the values of the inner 3x3 matrix by the given 3D scaling terms. | | [`shz_xmtrx_apply_rotation_x`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_x/) | Transforms the values of the inner 3x3 matrix by a rotation matrix of `x` radians about the X axis. | | [`shz_xmtrx_apply_rotation_y`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_y/) | Transforms the values of the inner 3x3 matrix by a rotation matrix of `y` radians about the Y axis. | | [`shz_xmtrx_apply_rotation_z`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_z/) | Transforms the values of the inner 3x3 matrix by a rotation matrix of `z` radians about the Z axis. | | [`shz_xmtrx_apply_rotation_xyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_xyz/) | Multiplies and accumulates XMTRX by a 3D X-Y-Z rotation matrix, with the corresponding angles given in radians. | | [`shz_xmtrx_apply_rotation_zyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zyx/) | Multiplies and accumulates XMTRX by a 3D Z-Y-X rotation matrix, with the corresponding angles given in radians. | | [`shz_xmtrx_apply_rotation_zxy`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zxy/) | Multiplies and accumulates XMTRX by a 3D Z-X-Y rotation matrix, with the corresponding angles given in radians. | | [`shz_xmtrx_apply_rotation_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_yxz/) | Multiplies and accumulates XMTRX by a 3D Y-X-Z rotation matrix, with the corresponding angles given in radians. | | [`shz_xmtrx_apply_rotation`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation/) | Transforms the values of the inner 3x3 matrix by a rotation matrix of `angle` radians about the axis with the given components. | | [`shz_xmtrx_apply_rotation_quat`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_quat/) | Transforms the values of the inner 3x3 matrix by the rotation matrix represented by the given quaternion. | | [`shz_xmtrx_apply_lookat`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_lookat/) | Applies the 3D "lookAt" matrix constructed with the given vector components onto XMTRX. Equivalent to gluLookAt(). | | [`shz_xmtrx_apply_ortho`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_ortho/) | Applies a 2D orthographic projection matrix onto XMTRX, equivalent to glOrtho(). | | [`shz_xmtrx_apply_frustum`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_frustum/) | Applies a frustum projection matrix onto XMTRX, equivalent to glFrustum(). | | [`shz_xmtrx_apply_perspective`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_perspective/) | Multiplies and accumulates the perspective matrix constructed from the given values onto XMTRX. | | [`shz_xmtrx_apply_screen`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_screen/) | Multiplies and accumulates the viewport matrix created with the given components. | | [`shz_xmtrx_apply_symmetric_skew`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_symmetric_skew/) | Multiplies and accumulates the 3D symmetric skew matrix with the given components onto XMTRX. | | [`shz_xmtrx_apply_permutation_wxyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_wxyz/) | Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order. | | [`shz_xmtrx_apply_permutation_yzwx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_yzwx/) | Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in YZWX order. | | [`shz_xmtrx_apply_permutation_wzyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_wzyx/) | Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in WZYX order. | | [`shz_xmtrx_apply_self`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_self/) | Multiplies and accumulatse the XMTRX matrix by itself, squaring it. | ## GL Transformations OpenGL-style 4x4 matrix transforms. | Symbol | Description | | --- | --- | | [`shz_xmtrx_translate`](https://sh4zam.com/api/xmtrx/shz_xmtrx_translate/) | Multiplies and accumulates XMTRX by a 3D translation matrix with the given components (glTranslatef() equivalent). | | [`shz_xmtrx_scale`](https://sh4zam.com/api/xmtrx/shz_xmtrx_scale/) | Multiplies and accumulates XMTRX by a 3D scaling matrix with the given components (glScalef() equivalent). | | [`shz_xmtrx_rotate_x`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_x/) | Multiplies and accumulates XMTRX by a 3D rotation matrix about the X axis. | | [`shz_xmtrx_rotate_y`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_y/) | Multiplies and accumulates XMTRX by a 3D rotation matrix about the Y axis. | | [`shz_xmtrx_rotate_z`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_z/) | Multiplies and accumulates XMTRX by a 3D rotation matrix about the Z axis. | | [`shz_xmtrx_rotate_xyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_xyz/) | Multiplies and accumulates XMTRX by 3D rotation matrices about the X then Y then Z axes. | | [`shz_xmtrx_rotate_zyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_zyx/) | Multiplies and accumulates XMTRX by 3D rotation matrices about the Z then Y then X axes. | | [`shz_xmtrx_rotate_zxy`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_zxy/) | Multiplies and accumulates XMTRX by 3D rotation matrices about the Z then X then Y axes. | | [`shz_xmtrx_rotate_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_yxz/) | Multiplies and accumulates XMTRX by 3D rotation matrices about the Y then X then Z axes. | | [`shz_xmtrx_rotate`](https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate/) | Multiplies and accumulates XMTRX by the 3D rotation matrix formed by the given axis and angle (glRotatef equivalent). | ## Reverse GL Transformations Pre-multiplication variants of OpenGL-style 4x4 matrix transforms. | Symbol | Description | | --- | --- | | [`shz_xmtrx_translate_reverse`](https://sh4zam.com/api/xmtrx/shz_xmtrx_translate_reverse/) | Pre-multiplies and accumulates XMTRX onto the 3D translation matrix with the given components. | | [`shz_xmtrx_scale_reverse`](https://sh4zam.com/api/xmtrx/shz_xmtrx_scale_reverse/) | Pre-multiplies and accumulates XMTRX onto the 3D scaling matrix with the given components. | ## Compound Operations Multiple operations combined into one pipelined transaction. | Symbol | Description | | --- | --- | | [`shz_xmtrx_load_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_4x4/) | Loads XMTRX with the result of applying `matrix2` onto `matrix1`. | | [`shz_xmtrx_load_apply_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_unaligned_4x4/) | Loads XMTRX with the result of applying unaligned `matrix2` onto `matrix1`. | | [`shz_xmtrx_apply_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_store_4x4/) | Multiplies XMTRX by the matrix, `in`, storing the result within the matrix, `out`. | | [`shz_xmtrx_apply_store_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_store_unaligned_4x4/) | Multiplies XMTRX by the unaligned matrix, `in`, storing the result within the unaligned matrix, `out`. | | [`shz_xmtrx_load_apply_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_4x4/) | Loads XMTRX with the 4x4 result of applying `matrix2` onto `matrix1`, storing the result. | | [`shz_xmtrx_load_apply_store_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_unaligned_4x4/) | Loads XMTRX with the result of applying unaligned `matrix2` onto unaligned `matrix1`, storing the result. | | [`shz_xmtrx_load_apply_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_3x4/) | Loads XMTRX with the result of applying `matrix2` onto `matrix1`. | | [`shz_xmtrx_load_apply_store_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_3x4/) | Loads XMTRX with the 3x4 result of applying `matrix2` onto `matrix1`, storing the result. | | [`shz_xmtrx_load_apply_store_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_3x3/) | Loads XMTRX with the 3x3 result of applying `matrix2` onto `matrix1`, storing the result. | ## Transformations Transforming vectors and points against XMTRX. | Symbol | Description | | --- | --- | | [`shz_xmtrx_transform_vec4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec4/) | Returns the 4D vector that is the result of transforming `vec` by XMTRX. | | [`shz_xmtrx_transform_vec3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec3/) | Returns the 3D vector that is the result of transforming `vec` by XMTRX. | | [`shz_xmtrx_transform_vec2`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec2/) | Returns the 2D vector that is the result of transforming `vec` by XMTRX. | | [`shz_xmtrx_transform_point2`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point2/) | Returns the 2D point that is the result of transforming `pt` by XMTRX. | | [`shz_xmtrx_transform_point3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point3/) | Returns the 3D point that is the result of transforming `pt` by XMTRX. | ## Setters Sets the values of related XMTRX components. | Symbol | Description | | --- | --- | | [`shz_xmtrx_set_translation`](https://sh4zam.com/api/xmtrx/shz_xmtrx_set_translation/) | Sets only the translational components of XMTRX to the given values. | | [`shz_xmtrx_set_scale`](https://sh4zam.com/api/xmtrx/shz_xmtrx_set_scale/) | Sets only the inner 3x3 submatrix of XMTRX to be a scaling matrix. | ## Getters Gets the values of related XMTRX components. | Symbol | Description | | --- | --- | | [`shz_xmtrx_get_translation`](https://sh4zam.com/api/xmtrx/shz_xmtrx_get_translation/) | Returns the translational components from the last column of XMTRX, as a 3D vector. | | [`shz_xmtrx_get_scale`](https://sh4zam.com/api/xmtrx/shz_xmtrx_get_scale/) | Returns the scaling components from the inner 3x3 matrix of XMTRX, as a 3D vector. | ## Component-Wise Matrix Operations Operations applying each component of a matrix onto XMTRX. | Symbol | Description | | --- | --- | | [`shz_xmtrx_add_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_add_4x4/) | Adds each element within `mat` to each element within XMTRX, storing the result in XMTRX. | | [`shz_xmtrx_sub_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_sub_4x4/) | Subtracts each element within `mat` from each element within XMTRX, storing the result in XMTRX. | ## Miscellaneous Random operations and conversions on XMTRX. | Symbol | Description | | --- | --- | | [`shz_xmtrx_transpose`](https://sh4zam.com/api/xmtrx/shz_xmtrx_transpose/) | Transposes the elements within XMTRX, in-place. | | [`shz_xmtrx_negate`](https://sh4zam.com/api/xmtrx/shz_xmtrx_negate/) | Negates each element held within XMTRX. | | [`shz_xmtrx_abs`](https://sh4zam.com/api/xmtrx/shz_xmtrx_abs/) | Takes the absolute value of each element held within XMTRX. | | [`shz_xmtrx_to_quat`](https://sh4zam.com/api/xmtrx/shz_xmtrx_to_quat/) | Constructs a quaternion from the 3D rotation matrix within XMTRX. | | [`shz_xmtrx_determinant`](https://sh4zam.com/api/xmtrx/shz_xmtrx_determinant/) | Returns the determinant of XMTRX. | | [`shz_xmtrx_invert`](https://sh4zam.com/api/xmtrx/shz_xmtrx_invert/) | Inverts XMTRX in-place. | | [`shz_xmtrx_blend`](https://sh4zam.com/api/xmtrx/shz_xmtrx_blend/) | Deprecated way to add and accumulate a scaled 4x4 matrix onto XMTRX. | | [`shz_xmtrx_blend_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_4x4/) | Adds and accumulates a scaled 4x4 matrix onto XMTRX. | | [`shz_xmtrx_blend_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_3x4/) | Adds and accumulates a scaled 3x4 matrix onto XMTRX. | ## Enumerations | Symbol | Description | | --- | --- | | [`shz_xmtrx_reg`](https://sh4zam.com/api/xmtrx/shz_xmtrx_reg/) | Registers comprising XMTRX, in the FPU back-bank. | --- # shz_xmtrx_abs Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_abs/ ```c SHZ_INLINE void shz_xmtrx_abs(void) SHZ_NOEXCEPT; ``` Takes the absolute value of each element held within XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::abs`](https://sh4zam.com/api/cpp/xmtrx/#abs) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:839`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L839) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" --- # shz_xmtrx_add_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_add_4x4/ > Adds each element within mat to each element within XMTRX, storing the result in XMTRX ```c SHZ_INLINE void shz_xmtrx_add_4x4(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Adds each element within `mat` to each element within XMTRX, storing the result in XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::xmtrx::add`](https://sh4zam.com/api/cpp/xmtrx/#add) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:820`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L820) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Component-Wise Matrix Operations" --- # shz_xmtrx_apply_2x2 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_2x2/ ```c SHZ_INLINE void shz_xmtrx_apply_2x2(const shz_mat2x2_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates the given 2x2 matrix onto XMTRX, not modifying other elements. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat2x2_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:447`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L447) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_3x3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x3/ ```c SHZ_INLINE void shz_xmtrx_apply_3x3(const shz_mat3x3_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates the given 3x3 matrix onto XMTRX, not modifying other elements. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:441`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L441) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x4/ ```c SHZ_INLINE void shz_xmtrx_apply_3x4(const shz_mat3x4_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates the given 3x4 matrix onto XMTRX, not modifying other elements. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:429`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L429) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_4x4/ ```c SHZ_INLINE void shz_xmtrx_apply_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates the given 4x4 matrix onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:405`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L405) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_frustum Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_frustum/ ```c SHZ_INLINE void shz_xmtrx_apply_frustum(float left, float right, float bottom, float top, float znear, float zfar) SHZ_NOEXCEPT; ``` Applies a frustum projection matrix onto XMTRX, equivalent to glFrustum(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `left` | `float` | | | `right` | `float` | | | `bottom` | `float` | | | `top` | `float` | | | `znear` | `float` | | | `zfar` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_frustum`](https://sh4zam.com/api/cpp/xmtrx/#apply_frustum) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:521`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L521) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_lookat Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_lookat/ ```c SHZ_INLINE void shz_xmtrx_apply_lookat(shz_vec3_t eye, shz_vec3_t center, shz_vec3_t up) SHZ_NOEXCEPT; ``` Applies the 3D "lookAt" matrix constructed with the given vector components onto XMTRX. Equivalent to gluLookAt(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `eye` | `shz_vec3_t` | | | `center` | `shz_vec3_t` | | | `up` | `shz_vec3_t` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_lookat`](https://sh4zam.com/api/cpp/xmtrx/#apply_lookat) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:515`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L515) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_ortho Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_ortho/ ```c SHZ_INLINE void shz_xmtrx_apply_ortho(float left, float right, float bottom, float top, float znear, float zfar) SHZ_NOEXCEPT; ``` Applies a 2D orthographic projection matrix onto XMTRX, equivalent to glOrtho(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `left` | `float` | | | `right` | `float` | | | `bottom` | `float` | | | `top` | `float` | | | `znear` | `float` | | | `zfar` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_ortho`](https://sh4zam.com/api/cpp/xmtrx/#apply_ortho) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:518`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L518) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_permutation_wxyz Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_wxyz/ ```c SHZ_INLINE void shz_xmtrx_apply_permutation_wxyz(void) SHZ_NOEXCEPT; ``` Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_permutation_wxyz`](https://sh4zam.com/api/cpp/xmtrx/#apply_permutation_wxyz) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:549`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L549) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_permutation_wzyx Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_wzyx/ ```c SHZ_INLINE void shz_xmtrx_apply_permutation_wzyx(void) SHZ_NOEXCEPT; ``` Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in WZYX order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_permutation_wzyx`](https://sh4zam.com/api/cpp/xmtrx/#apply_permutation_wzyx) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:555`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L555) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_permutation_yzwx Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_permutation_yzwx/ ```c SHZ_INLINE void shz_xmtrx_apply_permutation_yzwx(void) SHZ_NOEXCEPT; ``` Multiplies and accumulates a permutation matrix, which reorders the components of transformed vectors to be in YZWX order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_permutation_yzwx`](https://sh4zam.com/api/cpp/xmtrx/#apply_permutation_yzwx) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:552`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L552) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_perspective Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_perspective/ ```c SHZ_INLINE void shz_xmtrx_apply_perspective(float fov, float aspect, float znear) SHZ_NOEXCEPT; ``` Multiplies and accumulates the perspective matrix constructed from the given values onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `fov` | `float` | | | `aspect` | `float` | | | `znear` | `float` | | ## Returns Nothing (`void`). ## Details | fr\[n + 0\] | fr\[n + 4\] | fr\[n + 8\] | fr\[n + 12\] | | --- | --- | --- | --- | | cot(f)/a | 0.0f | 0.0f | 0.0f | | 0.0f | cot(f) | 0.0f | 0.0f | | 0.0f | 0.0f | 0.0f | nz | | 0.0f | 0.0f | -1.0f | 0.0f | ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_perspective`](https://sh4zam.com/api/cpp/xmtrx/#apply_perspective) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:532`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L532) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_reverse_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_3x4/ > Multiplies and accumulates XMTRX onto matrix, storing the result as XMTRX ```c SHZ_INLINE void shz_xmtrx_apply_reverse_3x4(const shz_mat3x4_t* mat) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX onto `matrix`, storing the result as XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:435`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L435) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_reverse_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_4x4/ > Multiplies and accumulates XMTRX onto matrix, storing the result as XMTRX ```c SHZ_INLINE void shz_xmtrx_apply_reverse_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX onto `matrix`, storing the result as XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:417`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L417) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_reverse_transpose_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_3x4/ > Multiplies and accumulates XMTRX onto the transpose of matrix, storing the result as XMTRX ```c SHZ_INLINE void shz_xmtrx_apply_reverse_transpose_3x4(const shz_mat3x4_t* mat) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX onto the transpose of `matrix`, storing the result as XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:438`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L438) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_reverse_transpose_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_4x4/ > Multiplies and accumulates XMTRX onto the transpose of matrix, storing the result as XMTRX ```c SHZ_INLINE void shz_xmtrx_apply_reverse_transpose_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX onto the transpose of `matrix`, storing the result as XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:423`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L423) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_reverse_transpose_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_transpose_unaligned_4x4/ ```c SHZ_INLINE void shz_xmtrx_apply_reverse_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX onto the transpose of the given float array as a 4x4 matrix, storing the result as XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const float [16]` | | ## Returns Nothing (`void`). ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:426`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L426) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_reverse_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_reverse_unaligned_4x4/ ```c SHZ_INLINE void shz_xmtrx_apply_reverse_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX onto the given float array as a 4x4 matrix, storing the result as XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const float [16]` | | ## Returns Nothing (`void`). ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:420`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L420) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_rotation_quat Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_quat/ ```c SHZ_INLINE void shz_xmtrx_apply_rotation_quat(shz_quat_t quat) SHZ_NOEXCEPT; ``` Transforms the values of the inner 3x3 matrix by the rotation matrix represented by the given quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `quat` | `shz_quat_t` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation_quat`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation_quat) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:512`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L512) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_rotation_x Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_x/ > Transforms the values of the inner 3x3 matrix by a rotation matrix of x radians about the X axis ```c SHZ_INLINE void shz_xmtrx_apply_rotation_x(float x) SHZ_NOEXCEPT; ``` Transforms the values of the inner 3x3 matrix by a rotation matrix of `x` radians about the X axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation_x`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation_x) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:456`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L456) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_rotation_xyz Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_xyz/ ```c SHZ_INLINE void shz_xmtrx_apply_rotation_xyz(float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D X-Y-Z rotation matrix, with the corresponding angles given in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `xAngle` | `float` | | | `yAngle` | `float` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Details The transform is applied to the inner 3x3 values within XMTRX, preserving the translational components. ## Notes - The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation. ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation_xyz`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:473`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L473) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" ## See also [`shz_xmtrx_apply_rotation_zyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zyx/), [`shz_xmtrx_apply_rotation_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_yxz/) --- # shz_xmtrx_apply_rotation_y Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_y/ > Transforms the values of the inner 3x3 matrix by a rotation matrix of y radians about the Y axis ```c SHZ_INLINE void shz_xmtrx_apply_rotation_y(float y) SHZ_NOEXCEPT; ``` Transforms the values of the inner 3x3 matrix by a rotation matrix of `y` radians about the Y axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `y` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation_y`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation_y) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:459`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L459) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_rotation_yxz Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_yxz/ ```c SHZ_INLINE void shz_xmtrx_apply_rotation_yxz(float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D Y-X-Z rotation matrix, with the corresponding angles given in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `yAngle` | `float` | | | `xAngle` | `float` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Details The transform is applied to the inner 3x3 values within XMTRX, preserving the translational components. ## Notes - The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation. ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation_yxz`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation_yxz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:506`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L506) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" ## See also [`shz_xmtrx_apply_rotation_xyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_xyz/), [`shz_xmtrx_apply_rotation_zyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zyx/) --- # shz_xmtrx_apply_rotation_z Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_z/ > Transforms the values of the inner 3x3 matrix by a rotation matrix of z radians about the Z axis ```c SHZ_INLINE void shz_xmtrx_apply_rotation_z(float z) SHZ_NOEXCEPT; ``` Transforms the values of the inner 3x3 matrix by a rotation matrix of `z` radians about the Z axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation_z`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation_z) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:462`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L462) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_rotation_zxy Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zxy/ ```c SHZ_INLINE void shz_xmtrx_apply_rotation_zxy(float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D Z-X-Y rotation matrix, with the corresponding angles given in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zAngle` | `float` | | | `xAngle` | `float` | | | `yAngle` | `float` | | ## Returns Nothing (`void`). ## Details The transform is applied to the inner 3x3 values within XMTRX, preserving the translational components. ## Notes - The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation. ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation_zxy`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation_zxy) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:495`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L495) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" ## See also [`shz_xmtrx_apply_rotation_zyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zyx/), [`shz_xmtrx_apply_rotation_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_yxz/) --- # shz_xmtrx_apply_rotation_zyx Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_zyx/ ```c SHZ_INLINE void shz_xmtrx_apply_rotation_zyx(float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D Z-Y-X rotation matrix, with the corresponding angles given in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zAngle` | `float` | | | `yAngle` | `float` | | | `xAngle` | `float` | | ## Returns Nothing (`void`). ## Details The transform is applied to the inner 3x3 values within XMTRX, preserving the translational components. ## Notes - The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation. ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation_zyx`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation_zyx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:484`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L484) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" ## See also [`shz_xmtrx_apply_rotation_xyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_xyz/), [`shz_xmtrx_apply_rotation_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation_yxz/) --- # shz_xmtrx_apply_rotation Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_rotation/ > Transforms the values of the inner 3x3 matrix by a rotation matrix of angle radians about the axis with the given components ```c SHZ_INLINE void shz_xmtrx_apply_rotation(float angle, float x, float y, float z) SHZ_NOEXCEPT; ``` Transforms the values of the inner 3x3 matrix by a rotation matrix of `angle` radians about the axis with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `angle` | `float` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_rotation`](https://sh4zam.com/api/cpp/xmtrx/#apply_rotation) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:509`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L509) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_scale Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_scale/ ```c SHZ_INLINE void shz_xmtrx_apply_scale(float x, float y, float z) SHZ_NOEXCEPT; ``` Multiplies the values of the inner 3x3 matrix by the given 3D scaling terms. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_scale`](https://sh4zam.com/api/cpp/xmtrx/#apply_scale) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:453`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L453) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_screen Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_screen/ ```c SHZ_INLINE void shz_xmtrx_apply_screen(float width, float height) SHZ_NOEXCEPT; ``` Multiplies and accumulates the viewport matrix created with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `width` | `float` | | | `height` | `float` | | ## Returns Nothing (`void`). ## Details | fr\[n + 0\] | fr\[n + 4\] | fr\[n + 8\] | fr\[n + 12\] | | --- | --- | --- | --- | | w\*0.5f | 0.0f | 0.0f | w\*0.5f | | 0.0f | -h\*0.5f | 0.0f | h\*0.5f | | 0.0f | 0.0f | 1.0f | 0.0f | | 0.0f | 0.0f | 0.0f | 1.0f | ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_screen`](https://sh4zam.com/api/cpp/xmtrx/#apply_screen) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:543`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L543) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_self Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_self/ ```c SHZ_INLINE void shz_xmtrx_apply_self(void) SHZ_NOEXCEPT; ``` Multiplies and accumulatse the XMTRX matrix by itself, squaring it. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_self`](https://sh4zam.com/api/cpp/xmtrx/#apply_self) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:558`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L558) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_store_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_store_4x4/ > Multiplies XMTRX by the matrix, in, storing the result within the matrix, out ```c SHZ_INLINE void shz_xmtrx_apply_store_4x4(shz_mat4x4_t* out, const shz_mat4x4_t* in) SHZ_NOEXCEPT; ``` Multiplies XMTRX by the matrix, `in`, storing the result within the matrix, `out`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `out` | `shz_mat4x4_t *` | | | `in` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Details This routine is roughly equivalent to: [`shz_xmtrx_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_4x4/)(in); [`shz_xmtrx_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_4x4/)(out); However, it has been optimized and pipelined for performing the multiply and store in parallel. ## Notes - This is useful for when you want to multiply a batch of matrices by the same matrix, held within XMTRX. ## Warnings - The result of the multiplication is not stored within XMTRX, despite it getting clobbered. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:658`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L658) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_4x4/), [`shz_xmtrx_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_4x4/), [`shz_xmtrx_apply_store_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_store_unaligned_4x4/) --- # shz_xmtrx_apply_store_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_store_unaligned_4x4/ > Multiplies XMTRX by the unaligned matrix, in, storing the result within the unaligned matrix, out ```c SHZ_INLINE void shz_xmtrx_apply_store_unaligned_4x4(float out[16], const float in[16]) SHZ_NOEXCEPT; ``` Multiplies XMTRX by the unaligned matrix, `in`, storing the result within the unaligned matrix, `out`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `out` | `float [16]` | | | `in` | `const float [16]` | | ## Returns Nothing (`void`). ## Details This routine is roughly equivalent to: [`shz_xmtrx_apply_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_unaligned_4x4/)(in); [`shz_xmtrx_store_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_unaligned_4x4/)(out); However, it has been optimized and pipelined for performing the multiply and store in parallel. ## Notes - This is useful for when you want to multiply a batch of matrices by the same matrix, held within XMTRX. ## Warnings - The result of the multiplication is not stored within XMTRX, despite it getting clobbered. ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:677`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L677) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_apply_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_unaligned_4x4/), [`shz_xmtrx_store_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_unaligned_4x4/), [`shz_xmtrx_apply_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_store_4x4/) --- # shz_xmtrx_apply_symmetric_skew Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_symmetric_skew/ ```c SHZ_INLINE void shz_xmtrx_apply_symmetric_skew(float x, float y, float z) SHZ_NOEXCEPT; ``` Multiplies and accumulates the 3D symmetric skew matrix with the given components onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_symmetric_skew`](https://sh4zam.com/api/cpp/xmtrx/#apply_symmetric_skew) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:546`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L546) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_translation Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_translation/ ```c SHZ_INLINE void shz_xmtrx_apply_translation(float x, float y, float z) SHZ_NOEXCEPT; ``` Adds the values of the given 3 components to the 3D translation components of XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::apply_translation`](https://sh4zam.com/api/cpp/xmtrx/#apply_translation) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:450`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L450) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_transpose_3x3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_3x3/ ```c SHZ_INLINE void shz_xmtrx_apply_transpose_3x3(const shz_mat3x3_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates the transpose of the given 3x3 matrix onto XMTRX, not modifying other elements. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:444`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L444) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_transpose_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_3x4/ ```c SHZ_INLINE void shz_xmtrx_apply_transpose_3x4(const shz_mat3x4_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates the transpose of the given 3x4 matrix onto XMTRX, not modifying other elements. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:432`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L432) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_transpose_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_4x4/ ```c SHZ_INLINE void shz_xmtrx_apply_transpose_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Multiplies and accumulates the transpose of the given 4x4 matrix onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:411`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L411) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_transpose_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_transpose_unaligned_4x4/ ```c SHZ_INLINE void shz_xmtrx_apply_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT; ``` Multiplies and accumulates the transpose of the given 16-entry float array as a 4x4 matrix onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const float [16]` | | ## Returns Nothing (`void`). ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:414`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L414) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_apply_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_unaligned_4x4/ ```c SHZ_INLINE void shz_xmtrx_apply_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT; ``` Multiplies and accumulates the given 16-entry float array as a 4x4 matrix onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const float [16]` | | ## Returns Nothing (`void`). ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:408`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L408) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Apply Operation" --- # shz_xmtrx_blend_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_3x4/ ```c SHZ_INLINE void shz_xmtrx_blend_3x4(const shz_mat3x4_t* matrix, float weight) SHZ_NOEXCEPT; ``` Adds and accumulates a scaled 3x4 matrix onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x4_t *` | 3x4 matrix to multiply and accumulate onto XMTRX. | | `weight` | `float` | Factor each element in `matrix` gets scaled by. | ## Returns Nothing (`void`). ## Details Each component of `joint_matrix` will be multiplied by `weight`, with the result being added to the existing value of that component of XMTRX. This is useful for accumulating weighted joint matrices onto an initially zeroed-out XMTRX. This allows for in-place construction of a skin matrix, which can then be directly used to transform the vertices of a mesh against for animation. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:897`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L897) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" ## See also [`shz_xmtrx_init_zero`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_zero/), [`shz_xmtrx_blend_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_4x4/) --- # shz_xmtrx_blend_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_4x4/ ```c SHZ_INLINE void shz_xmtrx_blend_4x4(const shz_mat4x4_t* matrix, float weight) SHZ_NOEXCEPT; ``` Adds and accumulates a scaled 4x4 matrix onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | 4x4 matrix to multiply and accumulate onto XMTRX. | | `weight` | `float` | Factor each element in `matrix` gets scaled by. | ## Returns Nothing (`void`). ## Details Each component of `joint_matrix` will be multiplied by `weight`, with the result being added to the existing value of that component of XMTRX. This is useful for accumulating weighted joint matrices onto an initially zeroed-out XMTRX. This allows for in-place construction of a skin matrix, which can then be directly used to transform the vertices of a mesh against for animation. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:881`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L881) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" ## See also [`shz_xmtrx_init_zero`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_zero/), [`shz_xmtrx_blend_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_3x4/) --- # shz_xmtrx_blend Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_blend/ ```c SHZ_INLINE void shz_xmtrx_blend(const shz_mat4x4_t* matrix, float weight) SHZ_NOEXCEPT; ``` Deprecated way to add and accumulate a scaled 4x4 matrix onto XMTRX. **Deprecated:** This routine has been renamed to `shz_xmtrx_blend_4x4()`, as support is being added to blend matrices of different dimensions onto XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | | | `weight` | `float` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:865`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L865) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" ## See also [`shz_xmtrx_blend_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_blend_4x4/) --- # shz_xmtrx_determinant Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_determinant/ ```c float shz_xmtrx_determinant(void) SHZ_NOEXCEPT; ``` Returns the determinant of XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns `float` ## Availability - **C++ equivalent:** [`shz::xmtrx::determinant`](https://sh4zam.com/api/cpp/xmtrx/#determinant) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:845`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L845) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" --- # shz_xmtrx_get_scale Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_get_scale/ ```c SHZ_INLINE shz_vec3_t shz_xmtrx_get_scale(void) SHZ_NOEXCEPT; ``` Returns the scaling components from the inner 3x3 matrix of XMTRX, as a 3D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns `shz_vec3_t` ## Warnings - This routine assumes XMTRX is a standard TRS-style transform matrix, without shearing or reflection. ## Availability - **C++ equivalent:** [`shz::xmtrx::get_scale`](https://sh4zam.com/api/cpp/xmtrx/#get_scale) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:810`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L810) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Getters" --- # shz_xmtrx_get_translation Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_get_translation/ ```c SHZ_INLINE shz_vec3_t shz_xmtrx_get_translation(void) SHZ_NOEXCEPT; ``` Returns the translational components from the last column of XMTRX, as a 3D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** [`shz::xmtrx::get_translation`](https://sh4zam.com/api/cpp/xmtrx/#get_translation) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:803`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L803) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Getters" --- # shz_xmtrx_init_diagonal Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_diagonal/ ```c SHZ_INLINE void shz_xmtrx_init_diagonal(float x, float y, float z, float w) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a diagonal matrix with the given diagonal values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | | `w` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_diagonal`](https://sh4zam.com/api/cpp/xmtrx/#init_diagonal) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:332`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L332) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_fill Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_fill/ > Initializes XMTRX to contain the given value for each element ```c SHZ_INLINE void shz_xmtrx_init_fill(float value) SHZ_NOEXCEPT; ``` Initializes XMTRX to contain the given `value` for each element. ## Parameters | Name | Type | Description | | --- | --- | --- | | `value` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_fill`](https://sh4zam.com/api/cpp/xmtrx/#init_fill) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:258`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L258) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_frustum Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_frustum/ ```c SHZ_INLINE void shz_xmtrx_init_frustum(float left, float right, float bottom, float top, float znear, float zfar) SHZ_NOEXCEPT; ``` Initializes XMTRX to a frustum projection matrix, equivalent to glFrustum(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `left` | `float` | | | `right` | `float` | | | `bottom` | `float` | | | `top` | `float` | | | `znear` | `float` | | | `zfar` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers any previous XMTRX contents. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_frustum`](https://sh4zam.com/api/cpp/xmtrx/#init_frustum) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:382`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L382) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_identity_safe Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_identity_safe/ ```c SHZ_INLINE void shz_xmtrx_init_identity_safe(void) SHZ_NOEXCEPT; ``` Safely initializes XMTRX to be a 4D identity matrix. **Deprecated:** `shz_xmtrx_init_identity()` is already safe now by default. This routine simply calls directly into it and should not be used. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:249`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L249) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" ## See also [`shz_xmtrx_init_identity`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_identity/) --- # shz_xmtrx_init_identity Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_identity/ ```c SHZ_INLINE void shz_xmtrx_init_identity(void) SHZ_NOEXCEPT; ``` Initializes XMTRX to the 4x4 identity matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_identity`](https://sh4zam.com/api/cpp/xmtrx/#init_identity), [`shz::xmtrx::init_identity_safe`](https://sh4zam.com/api/cpp/xmtrx/#init_identity_safe) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:238`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L238) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_lookat Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_lookat/ ```c SHZ_INLINE void shz_xmtrx_init_lookat(shz_vec3_t eye, shz_vec3_t center, shz_vec3_t up) SHZ_NOEXCEPT; ``` Initializes XMTRX to a "lookAt" view matrix, equivalent to gluLookAt(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `eye` | `shz_vec3_t` | | | `center` | `shz_vec3_t` | | | `up` | `shz_vec3_t` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers any previous XMTRX contents. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_lookat`](https://sh4zam.com/api/cpp/xmtrx/#init_lookat) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:370`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L370) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_lower_triangular Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_lower_triangular/ ```c SHZ_INLINE void shz_xmtrx_init_lower_triangular(shz_vec4_t col1, shz_vec3_t col2, shz_vec2_t col3, float col4) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a lower triangular matrix with the given column values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `col1` | `shz_vec4_t` | | | `col2` | `shz_vec3_t` | | | `col3` | `shz_vec2_t` | | | `col4` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_lower_triangular`](https://sh4zam.com/api/cpp/xmtrx/#init_lower_triangular) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:338`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L338) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_one Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_one/ ```c SHZ_INLINE void shz_xmtrx_init_one(void) SHZ_NOEXCEPT; ``` Initializes XMTRX to contain the value of 1.0f for each element. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_one`](https://sh4zam.com/api/cpp/xmtrx/#init_one) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:255`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L255) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_ortho Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_ortho/ ```c SHZ_INLINE void shz_xmtrx_init_ortho(float left, float right, float bottom, float top, float znear, float zfar) SHZ_NOEXCEPT; ``` Initializes XMTRX to an orthographic projection matrix, equivalent to glOrtho(). ## Parameters | Name | Type | Description | | --- | --- | --- | | `left` | `float` | | | `right` | `float` | | | `bottom` | `float` | | | `top` | `float` | | | `znear` | `float` | | | `zfar` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers any previous XMTRX contents. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_ortho`](https://sh4zam.com/api/cpp/xmtrx/#init_ortho) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:376`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L376) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_outer_product Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_outer_product/ ```c SHZ_INLINE void shz_xmtrx_init_outer_product(shz_vec4_t x, shz_vec4_t y) SHZ_NOEXCEPT; ``` Initializes XMTRX to the 4D matrix resulting from taking the outer product of the two 4D vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `shz_vec4_t` | | | `y` | `shz_vec4_t` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_outer_product`](https://sh4zam.com/api/cpp/xmtrx/#init_outer_product) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:344`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L344) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_permutation_wxyz Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_wxyz/ ```c SHZ_INLINE void shz_xmtrx_init_permutation_wxyz(void) SHZ_NOEXCEPT; ``` Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be in WXYZ order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::init_permutation_wxyz`](https://sh4zam.com/api/cpp/xmtrx/#init_permutation_wxyz) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:347`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L347) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_permutation_wzyx Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_wzyx/ ```c SHZ_INLINE void shz_xmtrx_init_permutation_wzyx(void) SHZ_NOEXCEPT; ``` Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be in WZYX order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::init_permutation_wzyx`](https://sh4zam.com/api/cpp/xmtrx/#init_permutation_wzyx) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:353`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L353) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_permutation_yzwx Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_permutation_yzwx/ ```c SHZ_INLINE void shz_xmtrx_init_permutation_yzwx(void) SHZ_NOEXCEPT; ``` Initializes XMTRX to a permutation matrix, which reorders the components of transformed vectors to be in YZWX order. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::init_permutation_yzwx`](https://sh4zam.com/api/cpp/xmtrx/#init_permutation_yzwx) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:350`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L350) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_perspective Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_perspective/ ```c SHZ_INLINE void shz_xmtrx_init_perspective(float fov, float aspect, float znear) SHZ_NOEXCEPT; ``` Initializes XMTRX to a perspective projection matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `fov` | `float` | | | `aspect` | `float` | | | `znear` | `float` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers any previous XMTRX contents. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_perspective`](https://sh4zam.com/api/cpp/xmtrx/#init_perspective) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:388`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L388) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_rotation_dir Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_dir/ > Initializes XMTRX to contain a 3D rotation matrix of angle radians about the given axis ```c SHZ_INLINE void shz_xmtrx_init_rotation_dir(float angle, float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes XMTRX to contain a 3D rotation matrix of `angle` radians about the given `axis`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `angle` | `float` | | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Details This is a faster version of `shz_xmtrx_init_rotation()` or glRotatef() which requires being passed a unit vector for the rotation axis. ## Warnings - The vector components representing the axis of rotation must be prenormalized! ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_dir`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_dir) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:329`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L329) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" ## See also [`shz_xmtrx_init_rotation`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation/) --- # shz_xmtrx_init_rotation_quat Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_quat/ ```c void shz_xmtrx_init_rotation_quat(shz_quat_t q) SHZ_NOEXCEPT; ``` Initializes XMTRX to a 3D rotation matrix with its orientation given by a quaternion. ## Parameters | Name | Type | Description | | --- | --- | --- | | `q` | `shz_quat_t` | | ## Returns Nothing (`void`). ## Warnings - This routine clobbers any previous XMTRX contents. - This routine is out-of-line. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_quat`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_quat) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:395`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L395) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_rotation_x Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_x/ > Initializes XMTRX to be a 3D rotation matrix by x radians about the X axis ```c SHZ_INLINE void shz_xmtrx_init_rotation_x(float x) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D rotation matrix by `x` radians about the X axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_x`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_x) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:267`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L267) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_rotation_xyz Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_xyz/ ```c SHZ_INLINE void shz_xmtrx_init_rotation_xyz(float xAngle, float yAngle, float zAngle) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D X-Y-Z rotation matrix, with the corresponding angles given in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `xAngle` | `float` | | | `yAngle` | `float` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Notes - The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_xyz`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:282`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L282) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" ## See also [`shz_xmtrx_init_rotation_zyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_zyx/), [`shz_xmtrx_init_rotation_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_yxz/) --- # shz_xmtrx_init_rotation_y Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_y/ > Initializes XMTRX to be a 3D rotation matrix by y radians about the Y axis ```c SHZ_INLINE void shz_xmtrx_init_rotation_y(float y) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D rotation matrix by `y` radians about the Y axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `y` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_y`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_y) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:270`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L270) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_rotation_yxz Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_yxz/ ```c SHZ_INLINE void shz_xmtrx_init_rotation_yxz(float yAngle, float xAngle, float zAngle) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D Y-X-Z rotation matrix, with the corresponding angles given in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `yAngle` | `float` | | | `xAngle` | `float` | | | `zAngle` | `float` | | ## Returns Nothing (`void`). ## Notes - The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_yxz`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_yxz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:309`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L309) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" ## See also [`shz_xmtrx_init_rotation_xyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_xyz/) --- # shz_xmtrx_init_rotation_z Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_z/ > Initializes XMTRX to be a 3D rotation matrix by z radians about the Z axis ```c SHZ_INLINE void shz_xmtrx_init_rotation_z(float z) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D rotation matrix by `z` radians about the Z axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_z`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_z) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:273`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L273) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_rotation_zxy Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_zxy/ ```c SHZ_INLINE void shz_xmtrx_init_rotation_zxy(float zAngle, float xAngle, float yAngle) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D Z-X-Y rotation matrix, with the corresponding angles given in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zAngle` | `float` | | | `xAngle` | `float` | | | `yAngle` | `float` | | ## Returns Nothing (`void`). ## Notes - The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_zxy`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_zxy) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:300`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L300) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" ## See also [`shz_xmtrx_init_rotation_zyx`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_zyx/), [`shz_xmtrx_init_rotation_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_yxz/) --- # shz_xmtrx_init_rotation_zyx Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_zyx/ ```c SHZ_INLINE void shz_xmtrx_init_rotation_zyx(float zAngle, float yAngle, float xAngle) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D Z-Y-X rotation matrix, with the corresponding angles given in radians. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zAngle` | `float` | | | `yAngle` | `float` | | | `xAngle` | `float` | | ## Returns Nothing (`void`). ## Notes - The given angles are represented as Tait-Bryan angles, representing an extrinsic rotation. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation_zyx`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation_zyx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:291`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L291) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" ## See also [`shz_xmtrx_init_rotation_xyz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_xyz/), [`shz_xmtrx_init_rotation_yxz`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_yxz/) --- # shz_xmtrx_init_rotation Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation/ > Initializes XMTRX to a 3D rotation matrix of angle radians about the vector with the given components ```c SHZ_INLINE void shz_xmtrx_init_rotation(float angle, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT; ``` Initializes XMTRX to a 3D rotation matrix of `angle` radians about the vector with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `angle` | `float` | | | `xAxis` | `float` | | | `yAxis` | `float` | | | `zAxis` | `float` | | ## Returns Nothing (`void`). ## Notes - This routine works similarly to glRotatef() applied to an identitiy matrix. The given axis will automatically be normalized internally. ## Availability - **C++ equivalent:** [`shz::xmtrx::init_rotation`](https://sh4zam.com/api/cpp/xmtrx/#init_rotation) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:318`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L318) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" ## See also [`shz_xmtrx_init_rotation_dir`](https://sh4zam.com/api/xmtrx/shz_xmtrx_init_rotation_dir/) --- # shz_xmtrx_init_scale Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_scale/ ```c SHZ_INLINE void shz_xmtrx_init_scale(float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D scale matrix with the given dimensions. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_scale`](https://sh4zam.com/api/cpp/xmtrx/#init_scale) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:264`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L264) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_screen Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_screen/ ```c SHZ_INLINE void shz_xmtrx_init_screen(float width, float height) SHZ_NOEXCEPT; ``` Initializes XMTRX to the viewport matrix with the given dimensions. ## Parameters | Name | Type | Description | | --- | --- | --- | | `width` | `float` | | | `height` | `float` | | ## Returns Nothing (`void`). ## Details | fr\[n + 0\] | fr\[n + 4\] | fr\[n + 8\] | fr\[n + 12\] | | --- | --- | --- | --- | | w\*0.5f | 0.0f | 0.0f | w\*0.5f | | 0.0f | -h\*0.5f | 0.0f | h\*0.5f | | 0.0f | 0.0f | 1.0f | 0.0f | | 0.0f | 0.0f | 0.0f | 1.0f | ## Availability - **C++ equivalent:** [`shz::xmtrx::init_screen`](https://sh4zam.com/api/cpp/xmtrx/#init_screen) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:364`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L364) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_symmetric_skew Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_symmetric_skew/ ```c SHZ_INLINE void shz_xmtrx_init_symmetric_skew(float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes XMTRX to be the 3D symmetric skew matrix formed from the given vector components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_symmetric_skew`](https://sh4zam.com/api/cpp/xmtrx/#init_symmetric_skew) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:341`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L341) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_translation Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_translation/ ```c SHZ_INLINE void shz_xmtrx_init_translation(float x, float y, float z) SHZ_NOEXCEPT; ``` Initializes XMTRX to be a 3D translation matrix to the given coordinates. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_translation`](https://sh4zam.com/api/cpp/xmtrx/#init_translation) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:261`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L261) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_upper_triangular Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_upper_triangular/ ```c SHZ_INLINE void shz_xmtrx_init_upper_triangular(float col1, shz_vec2_t col2, shz_vec3_t col3, shz_vec4_t col4) SHZ_NOEXCEPT; ``` Initializes XMTRX to be an upper triangular matrix with the given column values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `col1` | `float` | | | `col2` | `shz_vec2_t` | | | `col3` | `shz_vec3_t` | | | `col4` | `shz_vec4_t` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_upper_triangular`](https://sh4zam.com/api/cpp/xmtrx/#init_upper_triangular) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:335`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L335) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_init_zero Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_init_zero/ ```c SHZ_INLINE void shz_xmtrx_init_zero(void) SHZ_NOEXCEPT; ``` Initializes XMTRX to contain the value of 0.0f for each element. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::init_zero`](https://sh4zam.com/api/cpp/xmtrx/#init_zero) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:252`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L252) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Initialization" --- # shz_xmtrx_invert Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_invert/ ```c void shz_xmtrx_invert(void) SHZ_NOEXCEPT; ``` Inverts XMTRX in-place. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Details Stores XMTRX to memory, computes the inverse via `shz_mat4x4_inverse()`, and reloads the result. ## Warnings - This routine is out-of-line. ## Availability - **C++ equivalent:** [`shz::xmtrx::invert`](https://sh4zam.com/api/cpp/xmtrx/#invert) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:854`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L854) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" --- # shz_xmtrx_load_2x2 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_2x2/ ```c SHZ_INLINE void shz_xmtrx_load_2x2(const shz_mat2x2_t* matrix) SHZ_NOEXCEPT; ``` Loads the given 2x2 matrix into XMTRX, initializing its remaining elements to identity. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat2x2_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:194`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L194) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_3x3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x3/ ```c SHZ_INLINE void shz_xmtrx_load_3x3(const shz_mat3x3_t* matrix) SHZ_NOEXCEPT; ``` Loads the given 3x3 matrix into XMTRX, initalizing its remaining elements to identity. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:188`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L188) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x4/ ```c SHZ_INLINE void shz_xmtrx_load_3x4(const shz_mat3x4_t* matrix) SHZ_NOEXCEPT; ``` Loads the given 3x4 matrix into XMTRX, initializing its remaining elements to identity. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:151`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L151) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_4x4/ ```c SHZ_INLINE void shz_xmtrx_load_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Loads the given 4x4 matrix as XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:124`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L124) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_apply_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_3x4/ > Loads XMTRX with the result of applying matrix2 onto matrix1 ```c SHZ_INLINE void shz_xmtrx_load_apply_3x4(const shz_mat3x4_t* matrix1, const shz_mat3x4_t* matrix2) SHZ_NOEXCEPT; ``` Loads XMTRX with the result of applying `matrix2` onto `matrix1`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix1` | `const shz_mat3x4_t *` | | | `matrix2` | `const shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Details This operation is equivalent to: [`shz_xmtrx_load_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x4/)(matrix1); [`shz_xmtrx_apply_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x4/)(matrix2); However, it has been optimized and pipelined for performing the load and multiply in parallel. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:719`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L719) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_load_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x4/), [`shz_xmtrx_apply_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x4/), [`shz_xmtrx_load_apply_store_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_3x4/) --- # shz_xmtrx_load_apply_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_4x4/ > Loads XMTRX with the result of applying matrix2 onto matrix1 ```c SHZ_INLINE void shz_xmtrx_load_apply_4x4(const shz_mat4x4_t* matrix1, const shz_mat4x4_t* matrix2) SHZ_NOEXCEPT; ``` Loads XMTRX with the result of applying `matrix2` onto `matrix1`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix1` | `const shz_mat4x4_t *` | | | `matrix2` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Details This operation is equivalent to: [`shz_xmtrx_load_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_4x4/)(matrix1); [`shz_xmtrx_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_4x4/)(matrix2); However, it has been optimized and pipelined for performing the load and multiply in parallel. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:628`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L628) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_load_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_4x4/), [`shz_xmtrx_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_4x4/), [`shz_xmtrx_load_apply_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_4x4/) --- # shz_xmtrx_load_apply_store_3x3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_3x3/ > Loads XMTRX with the 3x3 result of applying matrix2 onto matrix1, storing the result ```c SHZ_INLINE void shz_xmtrx_load_apply_store_3x3(shz_mat3x3_t* out, const shz_mat3x3_t* matrix1, const shz_mat3x3_t* matrix2) SHZ_NOEXCEPT; ``` Loads XMTRX with the 3x3 result of applying `matrix2` onto `matrix1`, storing the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `out` | `shz_mat3x3_t *` | | | `matrix1` | `const shz_mat3x3_t *` | | | `matrix2` | `const shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Details This operation is equivalent to: [`shz_xmtrx_load_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x3/)(matrix1); [`shz_xmtrx_apply_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x3/)(matrix2); [`shz_xmtrx_store_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x3/)(out); However, it has been optimized and pipelined for performing the loads, multiplies, and stores in parallel. ## Notes - The resulting matrix does not get stored within XMTRX, despite it getting clobbered. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:756`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L756) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_load_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x3/), [`shz_xmtrx_apply_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x3/), [`shz_xmtrx_store_3x3`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x3/) --- # shz_xmtrx_load_apply_store_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_3x4/ > Loads XMTRX with the 3x4 result of applying matrix2 onto matrix1, storing the result ```c SHZ_INLINE void shz_xmtrx_load_apply_store_3x4(shz_mat3x4_t* out, const shz_mat3x4_t* matrix1, const shz_mat3x4_t* matrix2) SHZ_NOEXCEPT; ``` Loads XMTRX with the 3x4 result of applying `matrix2` onto `matrix1`, storing the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `out` | `shz_mat3x4_t *` | | | `matrix1` | `const shz_mat3x4_t *` | | | `matrix2` | `const shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Details This operation is equivalent to: [`shz_xmtrx_load_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x4/)(matrix1); [`shz_xmtrx_apply_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x4/)(matrix2); [`shz_xmtrx_store_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x4/)(out); However, it has been optimized and pipelined for performing the loads, multiplies, and stores in parallel. ## Notes - The resulting matrix does not get stored within XMTRX, despite it getting clobbered. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:737`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L737) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_load_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_3x4/), [`shz_xmtrx_apply_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_3x4/), [`shz_xmtrx_store_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x4/) --- # shz_xmtrx_load_apply_store_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_4x4/ > Loads XMTRX with the 4x4 result of applying matrix2 onto matrix1, storing the result ```c SHZ_INLINE void shz_xmtrx_load_apply_store_4x4(shz_mat4x4_t* out, const shz_mat4x4_t* matrix1, const shz_mat4x4_t* matrix2) SHZ_NOEXCEPT; ``` Loads XMTRX with the 4x4 result of applying `matrix2` onto `matrix1`, storing the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `out` | `shz_mat4x4_t *` | | | `matrix1` | `const shz_mat4x4_t *` | | | `matrix2` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Details This operation is equivalent to: [`shz_xmtrx_load_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_4x4/)(matrix1); [`shz_xmtrx_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_apply_4x4/)(matrix2); [`shz_xmtrx_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_store_4x4/)(out); However, it has been optimized and pipelined for performing the loads, multiplies, and stores in parallel. ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:692`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L692) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_load_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_4x4/), [`shz_xmtrx_load_apply_store_unaligned_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_unaligned_4x4/) --- # shz_xmtrx_load_apply_store_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_unaligned_4x4/ > Loads XMTRX with the result of applying unaligned matrix2 onto unaligned matrix1, storing the result ```c SHZ_INLINE void shz_xmtrx_load_apply_store_unaligned_4x4(float out[16], const float matrix1[16], const float matrix2[16]) SHZ_NOEXCEPT; ``` Loads XMTRX with the result of applying unaligned `matrix2` onto unaligned `matrix1`, storing the result. ## Parameters | Name | Type | Description | | --- | --- | --- | | `out` | `float [16]` | | | `matrix1` | `const float [16]` | | | `matrix2` | `const float [16]` | | ## Returns Nothing (`void`). ## Details This routine is equivalent to `shz_xmtrx_load_apply_store_4x4()`, except that the three operand matrices do not require 8-byte alignment and can simply be 16-element single-precision float arrays. ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:704`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L704) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_load_apply_store_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_store_4x4/) --- # shz_xmtrx_load_apply_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_unaligned_4x4/ > Loads XMTRX with the result of applying unaligned matrix2 onto matrix1 ```c SHZ_INLINE void shz_xmtrx_load_apply_unaligned_4x4(const float matrix1[16], const float matrix2[16]) SHZ_NOEXCEPT; ``` Loads XMTRX with the result of applying unaligned `matrix2` onto `matrix1`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix1` | `const float [16]` | | | `matrix2` | `const float [16]` | | ## Returns Nothing (`void`). ## Details This routine is equivalent to `shz_xmtrx_load_apply_4x4()`, except that the two operand matrices do not require 8-byte alignment and can simply be 16-element single-precision float arrays. ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:639`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L639) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Compound Operations" ## See also [`shz_xmtrx_load_apply_4x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_apply_4x4/) --- # shz_xmtrx_load_cols_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_3x4/ ```c SHZ_INLINE void shz_xmtrx_load_cols_3x4(const shz_vec3_t* c1, const shz_vec3_t* c2, const shz_vec3_t* c3, const shz_vec3_t* c4) SHZ_NOEXCEPT; ``` Loads the 3x4 matrix formed from the given 4 3D column vectors into XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c1` | `const shz_vec3_t *` | | | `c2` | `const shz_vec3_t *` | | | `c3` | `const shz_vec3_t *` | | | `c4` | `const shz_vec3_t *` | | ## Returns Nothing (`void`). ## Details All remaining elements are initialized to identity matrix values. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:182`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L182) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" ## See also [`shz_xmtrx_load_rows_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_rows_3x4/) --- # shz_xmtrx_load_cols_4x3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_4x3/ ```c SHZ_INLINE void shz_xmtrx_load_cols_4x3(const shz_vec4_t* c1, const shz_vec4_t* c2, const shz_vec4_t* c3) SHZ_NOEXCEPT; ``` Loads the 3x4 matrix formed from the given 3 4D column vectors into XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c1` | `const shz_vec4_t *` | | | `c2` | `const shz_vec4_t *` | | | `c3` | `const shz_vec4_t *` | | ## Returns Nothing (`void`). ## Details All remaining elements are initialized to identity matrix values. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:162`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L162) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" ## See also [`shz_xmtrx_load_rows_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_rows_3x4/) --- # shz_xmtrx_load_cols_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_4x4/ ```c SHZ_INLINE void shz_xmtrx_load_cols_4x4(const shz_vec4_t* c1, const shz_vec4_t* c2, const shz_vec4_t* c3, const shz_vec4_t* c4) SHZ_NOEXCEPT; ``` Sets XMTRX equal to the 4x4 matrix created from the 4 given 4D column vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `c1` | `const shz_vec4_t *` | | | `c2` | `const shz_vec4_t *` | | | `c3` | `const shz_vec4_t *` | | | `c4` | `const shz_vec4_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:133`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L133) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_rows_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_rows_3x4/ ```c SHZ_INLINE void shz_xmtrx_load_rows_3x4(const shz_vec4_t* r1, const shz_vec4_t* r2, const shz_vec4_t* r3) SHZ_NOEXCEPT; ``` Loads the 3x4 matrix formed from the given 3 4D row vectors into XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `r1` | `const shz_vec4_t *` | | | `r2` | `const shz_vec4_t *` | | | `r3` | `const shz_vec4_t *` | | ## Returns Nothing (`void`). ## Details All remaining elements are initialized to identity matrix values. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:172`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L172) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" ## See also [`shz_xmtrx_load_cols_3x4`](https://sh4zam.com/api/xmtrx/shz_xmtrx_load_cols_3x4/) --- # shz_xmtrx_load_rows_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_rows_4x4/ ```c SHZ_INLINE void shz_xmtrx_load_rows_4x4(const shz_vec4_t* r1, const shz_vec4_t* r2, const shz_vec4_t* r3, const shz_vec4_t* r4) SHZ_NOEXCEPT; ``` Sets XMTRX equal to the 4x4 matrix created from the 4 given 4D row vectors. ## Parameters | Name | Type | Description | | --- | --- | --- | | `r1` | `const shz_vec4_t *` | | | `r2` | `const shz_vec4_t *` | | | `r3` | `const shz_vec4_t *` | | | `r4` | `const shz_vec4_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:139`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L139) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_transpose_3x3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_3x3/ ```c SHZ_INLINE void shz_xmtrx_load_transpose_3x3(const shz_mat3x3_t* matrix) SHZ_NOEXCEPT; ``` Loads the transpose of the given 3x3 matrix into XMTRX, initializing its remaining elements to identity. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:191`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L191) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_transpose_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_3x4/ ```c SHZ_INLINE void shz_xmtrx_load_transpose_3x4(const shz_mat3x4_t* matrix) SHZ_NOEXCEPT; ``` Loads XMTRX with the transpose of the given 3x4 matrix, initializing the bottom row to identity. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:154`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L154) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_transpose_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_4x4/ ```c SHZ_INLINE void shz_xmtrx_load_transpose_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Loads XMTRX with the transpose of the given 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:145`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L145) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_transpose_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_transpose_unaligned_4x4/ ```c SHZ_INLINE void shz_xmtrx_load_transpose_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT; ``` Loads XMTRX with the transpose of the 4x4 matrix created from the given unaligned array of 16 floats. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const float [16]` | | ## Returns Nothing (`void`). ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:148`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L148) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_unaligned_4x4/ ```c SHZ_INLINE void shz_xmtrx_load_unaligned_4x4(const float matrix[16]) SHZ_NOEXCEPT; ``` Loads the given array of unaligned 16 float values as the 4x4 XMTRX matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const float [16]` | | ## Returns Nothing (`void`). ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:130`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L130) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_load_wxyz_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_load_wxyz_4x4/ ```c SHZ_INLINE void shz_xmtrx_load_wxyz_4x4(const shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Loads the given 4x4 matrix as XMTRX, with the 4th column for translation being loaded as the first column. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_wxyz`: Register/column permutation so that `FTRV` yields W first (cycle 4 instead of 7), which helps perspective division. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::xmtrx::load_wxyz`](https://sh4zam.com/api/cpp/xmtrx/#load_wxyz) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:127`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L127) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Loading" --- # shz_xmtrx_negate Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_negate/ ```c SHZ_INLINE void shz_xmtrx_negate(void) SHZ_NOEXCEPT; ``` Negates each element held within XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::negate`](https://sh4zam.com/api/cpp/xmtrx/#negate) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:836`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L836) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" --- # shz_xmtrx_read_col Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_read_col/ > Returns the values at the given column index, as a 4D vector ```c SHZ_INLINE shz_vec4_t shz_xmtrx_read_col(unsigned int index) SHZ_NOEXCEPT; ``` Returns the values at the given column `index`, as a 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `index` | `unsigned int` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::xmtrx::read_col`](https://sh4zam.com/api/cpp/xmtrx/#read_col) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:102`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L102) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Accessors" --- # shz_xmtrx_read_row Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_read_row/ > Returns the values at the the given row index, as a 4D vector ```c SHZ_INLINE shz_vec4_t shz_xmtrx_read_row(unsigned int index) SHZ_NOEXCEPT; ``` Returns the values at the the given row `index`, as a 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `index` | `unsigned int` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** [`shz::xmtrx::read_row`](https://sh4zam.com/api/cpp/xmtrx/#read_row) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:99`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L99) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Accessors" --- # shz_xmtrx_read Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_read/ ```c SHZ_INLINE float shz_xmtrx_read(shz_xmtrx_reg_t xf) SHZ_NOEXCEPT; ``` Returns the floating-point value held within the given XMTRX register. ## Parameters | Name | Type | Description | | --- | --- | --- | | `xf` | `shz_xmtrx_reg_t` | | ## Returns `float` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:93`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L93) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Accessors" --- # shz_xmtrx_reg Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_reg/ ```c typedef enum shz_xmtrx_reg { SHZ_XMTRX_XF0, //!< FP register `xf0`. SHZ_XMTRX_XF1, //!< FP register `xf1`. SHZ_XMTRX_XF2, //!< FP register `xf2`. SHZ_XMTRX_XF3, //!< FP register `xf3`. SHZ_XMTRX_XF4, //!< FP register `xf4`. SHZ_XMTRX_XF5, //!< FP register `xf5`. SHZ_XMTRX_XF6, //!< FP register `xf6`. SHZ_XMTRX_XF7, //!< FP register `xf7`. SHZ_XMTRX_XF8, //!< FP register `xf8`. SHZ_XMTRX_XF9, //!< FP register `xf9`. SHZ_XMTRX_XF10, //!< FP register `xf10`. SHZ_XMTRX_XF11, //!< FP register `xf11`. SHZ_XMTRX_XF12, //!< FP register `xf12`. SHZ_XMTRX_XF13, //!< FP register `xf13`. SHZ_XMTRX_XF14, //!< FP register `xf14`. SHZ_XMTRX_XF15 //!< FP register `xf15`. } shz_xmtrx_reg_t, shz_xmtrx_reg; ``` Registers comprising XMTRX, in the FPU back-bank. ## Values - `SHZ_XMTRX_XF0`: FP register `xf0`. - `SHZ_XMTRX_XF1`: FP register `xf1`. - `SHZ_XMTRX_XF2`: FP register `xf2`. - `SHZ_XMTRX_XF3`: FP register `xf3`. - `SHZ_XMTRX_XF4`: FP register `xf4`. - `SHZ_XMTRX_XF5`: FP register `xf5`. - `SHZ_XMTRX_XF6`: FP register `xf6`. - `SHZ_XMTRX_XF7`: FP register `xf7`. - `SHZ_XMTRX_XF8`: FP register `xf8`. - `SHZ_XMTRX_XF9`: FP register `xf9`. - `SHZ_XMTRX_XF10`: FP register `xf10`. - `SHZ_XMTRX_XF11`: FP register `xf11`. - `SHZ_XMTRX_XF12`: FP register `xf12`. - `SHZ_XMTRX_XF13`: FP register `xf13`. - `SHZ_XMTRX_XF14`: FP register `xf14`. - `SHZ_XMTRX_XF15`: FP register `xf15`. ## Availability - **C++ equivalent:** none (usable from C++ as is) - **Back-ends:** n/a (not a function) - **Defined in:** [`sh4zam/shz_xmtrx.h:68`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L68) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Enumerations" --- # shz_xmtrx_rotate_x Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_x/ ```c SHZ_INLINE void shz_xmtrx_rotate_x(float radians) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D rotation matrix about the X axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::rotate_x`](https://sh4zam.com/api/cpp/xmtrx/#rotate_x) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:574`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L574) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_rotate_xyz Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_xyz/ ```c SHZ_INLINE void shz_xmtrx_rotate_xyz(float xRadians, float yRadians, float zRadians) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by 3D rotation matrices about the X then Y then Z axes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `xRadians` | `float` | | | `yRadians` | `float` | | | `zRadians` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::rotate_xyz`](https://sh4zam.com/api/cpp/xmtrx/#rotate_xyz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:583`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L583) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_rotate_y Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_y/ ```c SHZ_INLINE void shz_xmtrx_rotate_y(float radians) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D rotation matrix about the Y axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::rotate_y`](https://sh4zam.com/api/cpp/xmtrx/#rotate_y) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:577`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L577) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_rotate_yxz Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_yxz/ ```c SHZ_INLINE void shz_xmtrx_rotate_yxz(float yRadians, float xRadians, float zRadians) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by 3D rotation matrices about the Y then X then Z axes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `yRadians` | `float` | | | `xRadians` | `float` | | | `zRadians` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::rotate_yxz`](https://sh4zam.com/api/cpp/xmtrx/#rotate_yxz) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:592`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L592) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_rotate_z Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_z/ ```c SHZ_INLINE void shz_xmtrx_rotate_z(float radians) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D rotation matrix about the Z axis. ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::rotate_z`](https://sh4zam.com/api/cpp/xmtrx/#rotate_z) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:580`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L580) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_rotate_zxy Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_zxy/ ```c SHZ_INLINE void shz_xmtrx_rotate_zxy(float zRadians, float xRadians, float yRadians) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by 3D rotation matrices about the Z then X then Y axes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zRadians` | `float` | | | `xRadians` | `float` | | | `yRadians` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::rotate_zxy`](https://sh4zam.com/api/cpp/xmtrx/#rotate_zxy) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:589`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L589) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_rotate_zyx Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate_zyx/ ```c SHZ_INLINE void shz_xmtrx_rotate_zyx(float zRadians, float yRadians, float xRadians) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by 3D rotation matrices about the Z then Y then X axes. ## Parameters | Name | Type | Description | | --- | --- | --- | | `zRadians` | `float` | | | `yRadians` | `float` | | | `xRadians` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::rotate_zyx`](https://sh4zam.com/api/cpp/xmtrx/#rotate_zyx) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:586`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L586) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_rotate Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_rotate/ ```c SHZ_INLINE void shz_xmtrx_rotate(float radians, float xAxis, float yAxis, float zAxis) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by the 3D rotation matrix formed by the given axis and angle (glRotatef equivalent). ## Parameters | Name | Type | Description | | --- | --- | --- | | `radians` | `float` | | | `xAxis` | `float` | | | `yAxis` | `float` | | | `zAxis` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::rotate`](https://sh4zam.com/api/cpp/xmtrx/#rotate) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:595`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L595) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_scale_reverse Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_scale_reverse/ ```c SHZ_INLINE void shz_xmtrx_scale_reverse(float x, float y, float z) SHZ_NOEXCEPT; ``` Pre-multiplies and accumulates XMTRX onto the 3D scaling matrix with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Naming and requirements - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::scale_reverse`](https://sh4zam.com/api/cpp/xmtrx/#scale_reverse) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:608`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L608) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Reverse GL Transformations" --- # shz_xmtrx_scale Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_scale/ ```c SHZ_INLINE void shz_xmtrx_scale(float x, float y, float z) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D scaling matrix with the given components (glScalef() equivalent). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::scale`](https://sh4zam.com/api/cpp/xmtrx/#scale) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:571`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L571) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_set_scale Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_set_scale/ ```c SHZ_INLINE void shz_xmtrx_set_scale(float x, float y, float z) SHZ_NOEXCEPT; ``` Sets only the inner 3x3 submatrix of XMTRX to be a scaling matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::set_scale`](https://sh4zam.com/api/cpp/xmtrx/#set_scale) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:793`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L793) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Setters" --- # shz_xmtrx_set_translation Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_set_translation/ ```c SHZ_INLINE void shz_xmtrx_set_translation(float x, float y, float z) SHZ_NOEXCEPT; ``` Sets only the translational components of XMTRX to the given values. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::set_translation`](https://sh4zam.com/api/cpp/xmtrx/#set_translation) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:790`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L790) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Setters" --- # shz_xmtrx_store_2x2 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_2x2/ ```c SHZ_INLINE void shz_xmtrx_store_2x2(shz_mat2x2_t* matrix) SHZ_NOEXCEPT; ``` Stores the top-left 2x2 values currently held within XMTRX into the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `shz_mat2x2_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:228`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L228) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_store_3x3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x3/ ```c SHZ_INLINE void shz_xmtrx_store_3x3(shz_mat3x3_t* matrix) SHZ_NOEXCEPT; ``` Stores the top-left 3x3 values currently held within XMTRX into the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:222`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L222) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_store_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_3x4/ ```c SHZ_INLINE void shz_xmtrx_store_3x4(shz_mat3x4_t* matrix) SHZ_NOEXCEPT; ``` Stores the top-left 3x4 values currently held within XMTRX into the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:216`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L216) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_store_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_4x4/ ```c SHZ_INLINE void shz_xmtrx_store_4x4(shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Stores the current values held within XMTRX into the given 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:204`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L204) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_store_transpose_3x3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_3x3/ ```c SHZ_INLINE void shz_xmtrx_store_transpose_3x3(shz_mat3x3_t* matrix) SHZ_NOEXCEPT; ``` Stores the transpose of the top-left 3x3 values currently held within XMTRX into the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `shz_mat3x3_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:225`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L225) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_store_transpose_3x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_3x4/ ```c SHZ_INLINE void shz_xmtrx_store_transpose_3x4(shz_mat3x4_t* matrix) SHZ_NOEXCEPT; ``` Stores the transpose of the top-left 3x4 values currently held within XMTRX into the given matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `shz_mat3x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:219`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L219) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_store_transpose_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_4x4/ ```c SHZ_INLINE void shz_xmtrx_store_transpose_4x4(shz_mat4x4_t* matrix) SHZ_NOEXCEPT; ``` Stores the transpose of the current values held within XMTRX into the given 4x4 matrix. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:210`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L210) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_store_transpose_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_transpose_unaligned_4x4/ ```c SHZ_INLINE void shz_xmtrx_store_transpose_unaligned_4x4(float matrix[16]) SHZ_NOEXCEPT; ``` Stores the transpose of the the current values held within XMTRX into the given 16-element float array. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `float [16]` | | ## Returns Nothing (`void`). ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:213`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L213) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_store_unaligned_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_store_unaligned_4x4/ ```c SHZ_INLINE void shz_xmtrx_store_unaligned_4x4(float matrix[16]) SHZ_NOEXCEPT; ``` Stores the current values held within XMTRX into the given unaligned 16-float array. ## Parameters | Name | Type | Description | | --- | --- | --- | | `matrix` | `float [16]` | | ## Returns Nothing (`void`). ## Naming and requirements - `_unaligned`: Works on matrix data that is not 8-byte aligned, passed as a plain `float[16]`. The default routines use 64-bit paired `FMOV` loads that need 8-byte alignment. ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:207`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L207) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Storing" --- # shz_xmtrx_sub_4x4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_sub_4x4/ > Subtracts each element within mat from each element within XMTRX, storing the result in XMTRX ```c SHZ_INLINE void shz_xmtrx_sub_4x4(const shz_mat4x4_t* mat) SHZ_NOEXCEPT; ``` Subtracts each element within `mat` from each element within XMTRX, storing the result in XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `mat` | `const shz_mat4x4_t *` | | ## Returns Nothing (`void`). ## Naming and requirements - `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines. ## Availability - **C++ equivalent:** [`shz::xmtrx::sub`](https://sh4zam.com/api/cpp/xmtrx/#sub) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:823`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L823) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Component-Wise Matrix Operations" --- # shz_xmtrx_swap_cols Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_swap_cols/ ```c SHZ_INLINE void shz_xmtrx_swap_cols(unsigned int index1, unsigned int index2) SHZ_NOEXCEPT; ``` Swaps the values of the columns with the given indices. ## Parameters | Name | Type | Description | | --- | --- | --- | | `index1` | `unsigned int` | | | `index2` | `unsigned int` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::swap_cols`](https://sh4zam.com/api/cpp/xmtrx/#swap_cols) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:114`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L114) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Accessors" --- # shz_xmtrx_swap_rows Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_swap_rows/ ```c SHZ_INLINE void shz_xmtrx_swap_rows(unsigned int index1, unsigned int index2) SHZ_NOEXCEPT; ``` Swaps the values of the rows with the given indices. ## Parameters | Name | Type | Description | | --- | --- | --- | | `index1` | `unsigned int` | | | `index2` | `unsigned int` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::swap_rows`](https://sh4zam.com/api/cpp/xmtrx/#swap_rows) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:111`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L111) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Accessors" --- # shz_xmtrx_to_quat Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_to_quat/ ```c shz_quat_t shz_xmtrx_to_quat(void) SHZ_NOEXCEPT; ``` Constructs a quaternion from the 3D rotation matrix within XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns `shz_quat_t` ## Availability - **C++ equivalent:** [`shz::xmtrx::to_quat`](https://sh4zam.com/api/cpp/xmtrx/#to_quat) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:842`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L842) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" --- # shz_xmtrx_transform_point2 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point2/ > Returns the 2D point that is the result of transforming pt by XMTRX ```c SHZ_INLINE shz_vec2_t shz_xmtrx_transform_point2(shz_vec2_t pt) SHZ_NOEXCEPT; ``` Returns the 2D point that is the result of transforming `pt` by XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `pt` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:777`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L777) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Transformations" --- # shz_xmtrx_transform_point3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_point3/ > Returns the 3D point that is the result of transforming pt by XMTRX ```c SHZ_INLINE shz_vec3_t shz_xmtrx_transform_point3(shz_vec3_t pt) SHZ_NOEXCEPT; ``` Returns the 3D point that is the result of transforming `pt` by XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `pt` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:780`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L780) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Transformations" --- # shz_xmtrx_transform_vec2 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec2/ > Returns the 2D vector that is the result of transforming vec by XMTRX ```c SHZ_INLINE shz_vec2_t shz_xmtrx_transform_vec2(shz_vec2_t vec) SHZ_NOEXCEPT; ``` Returns the 2D vector that is the result of transforming `vec` by XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec2_t` | | ## Returns `shz_vec2_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:774`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L774) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Transformations" --- # shz_xmtrx_transform_vec3 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec3/ > Returns the 3D vector that is the result of transforming vec by XMTRX ```c SHZ_INLINE shz_vec3_t shz_xmtrx_transform_vec3(shz_vec3_t vec) SHZ_NOEXCEPT; ``` Returns the 3D vector that is the result of transforming `vec` by XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec3_t` | | ## Returns `shz_vec3_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:771`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L771) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Transformations" --- # shz_xmtrx_transform_vec4 Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_transform_vec4/ > Returns the 4D vector that is the result of transforming vec by XMTRX ```c SHZ_INLINE shz_vec4_t shz_xmtrx_transform_vec4(shz_vec4_t vec) SHZ_NOEXCEPT; ``` Returns the 4D vector that is the result of transforming `vec` by XMTRX. ## Parameters | Name | Type | Description | | --- | --- | --- | | `vec` | `shz_vec4_t` | | ## Returns `shz_vec4_t` ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:768`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L768) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Transformations" --- # shz_xmtrx_translate_reverse Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_translate_reverse/ ```c SHZ_INLINE void shz_xmtrx_translate_reverse(float x, float y, float z) SHZ_NOEXCEPT; ``` Pre-multiplies and accumulates XMTRX onto the 3D translation matrix with the given components. ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Naming and requirements - `_reverse`: Reversed multiplication order (pre-multiply instead of post-multiply). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::translate_reverse`](https://sh4zam.com/api/cpp/xmtrx/#translate_reverse) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:605`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L605) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Reverse GL Transformations" --- # shz_xmtrx_translate Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_translate/ ```c SHZ_INLINE void shz_xmtrx_translate(float x, float y, float z) SHZ_NOEXCEPT; ``` Multiplies and accumulates XMTRX by a 3D translation matrix with the given components (glTranslatef() equivalent). ## Parameters | Name | Type | Description | | --- | --- | --- | | `x` | `float` | | | `y` | `float` | | | `z` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::translate`](https://sh4zam.com/api/cpp/xmtrx/#translate) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:568`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L568) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "GL Transformations" --- # shz_xmtrx_transpose Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_transpose/ ```c SHZ_INLINE void shz_xmtrx_transpose(void) SHZ_NOEXCEPT; ``` Transposes the elements within XMTRX, in-place. ## Parameters | Name | Type | Description | | --- | --- | --- | | `` | `void` | | ## Returns Nothing (`void`). ## Naming and requirements - `_transpose`: Operates with the transposed matrix (row-major input, or inverse-rotation use). ([Naming and Suffixes](https://sh4zam.com/concepts/naming-and-suffixes/)) ## Availability - **C++ equivalent:** [`shz::xmtrx::transpose`](https://sh4zam.com/api/cpp/xmtrx/#transpose) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:833`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L833) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Miscellaneous" --- # shz_xmtrx_write_col Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_write_col/ > Sets the values at the given column index to the given 4D vector ```c SHZ_INLINE void shz_xmtrx_write_col(unsigned int index, shz_vec4_t vector) SHZ_NOEXCEPT; ``` Sets the values at the given column `index` to the given 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `index` | `unsigned int` | | | `vector` | `shz_vec4_t` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::write_col`](https://sh4zam.com/api/cpp/xmtrx/#write_col) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:108`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L108) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Accessors" --- # shz_xmtrx_write_row Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_write_row/ > Sets the values at the given row index to the given 4D vector ```c SHZ_INLINE void shz_xmtrx_write_row(unsigned int index, shz_vec4_t vector) SHZ_NOEXCEPT; ``` Sets the values at the given row `index` to the given 4D vector. ## Parameters | Name | Type | Description | | --- | --- | --- | | `index` | `unsigned int` | | | `vector` | `shz_vec4_t` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** [`shz::xmtrx::write_row`](https://sh4zam.com/api/cpp/xmtrx/#write_row) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:105`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L105) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Accessors" --- # shz_xmtrx_write Source: https://sh4zam.com/api/xmtrx/shz_xmtrx_write/ > Sets the floating-point value held within the given XMTRX register to value ```c SHZ_INLINE void shz_xmtrx_write(shz_xmtrx_reg_t xf, float value) SHZ_NOEXCEPT; ``` Sets the floating-point value held within the given XMTRX register to `value`. ## Parameters | Name | Type | Description | | --- | --- | --- | | `xf` | `shz_xmtrx_reg_t` | | | `value` | `float` | | ## Returns Nothing (`void`). ## Availability - **C++ equivalent:** none (call the C function from C++) - **Type-generic form:** none - **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation - **Defined in:** [`sh4zam/shz_xmtrx.h:96`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_xmtrx.h#L96) - **Module:** [XMTRX](https://sh4zam.com/api/xmtrx/), section "Accessors"