SH4ZAM! 0.9.1
Fast math library for the Sega Dreamcast's SH4 CPU
Loading...
Searching...
No Matches
shz_trig.h File Reference
#include "shz_scalar.h"
#include "inline/shz_trig.inl.h"
Include dependency graph for shz_trig.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  shz_sincos_t
 

Macros

#define SHZ_F_PI
 
#define SHZ_F_TAU
 
#define SHZ_F_PI_2
 
#define SHZ_F_PI_4
 
#define SHZ_FSCA_RAD_FACTOR
 
#define SHZ_FSCA_DEG_FACTOR
 
#define SHZ_FSCA_ERROR_MAX
 
#define SHZ_DEG_TO_RAD(deg)
 
#define SHZ_RAD_TO_DEG(rad)
 

Typedefs

typedef shz_sincos_t shz_sincos
 

Functions

Sin/Cos Pairs

Routines involving precomputed sine + cosine pairs.

shz_sincos_t shz_sincosu16 (uint16_t radians16) noexcept
 
shz_sincos_t shz_sincosf (float radians) noexcept
 
shz_sincos_t shz_sincosf_deg (float degrees) noexcept
 
float shz_sincos_tanf (shz_sincos_t sincos) noexcept
 
float shz_sincos_secf (shz_sincos_t sincos) noexcept
 
float shz_sincos_cscf (shz_sincos_t sincos) noexcept
 
float shz_sincos_cotf (shz_sincos_t sincos) noexcept
 
Independent Functions

Routines providing single trigonometric functions.

float shz_sinf (float radians) noexcept
 
float shz_sinf_deg (float degrees) noexcept
 
float shz_cosf (float radians) noexcept
 
float shz_cosf_deg (float degrees) noexcept
 
float shz_tanf (float radians) noexcept
 
float shz_tanf_deg (float degrees) noexcept
 
float shz_secf (float radians) noexcept
 
float shz_secf_deg (float degrees) noexcept
 
float shz_cscf (float radians) noexcept
 
float shz_cscf_deg (float degrees) noexcept
 
float shz_cotf (float radians) noexcept
 
float shz_cotf_deg (float degrees) noexcept
 
Inverse Functions

Routines providing inverse trigonometric functions.

float shz_asinf (float x) noexcept
 
float shz_acosf (float x) noexcept
 
float shz_atanf_unit (float x) noexcept
 
float shz_atanf_q1 (float x) noexcept
 
float shz_atanf (float x) noexcept
 
float shz_atan2f (float y, float x) noexcept
 
float shz_asecf (float x) noexcept
 
float shz_acscf (float x) noexcept
 
float shz_acotf (float x) noexcept
 
Hyperbolic Functions

Trigonometric functions for hyperbolas

float shz_sinhf (float x) noexcept
 
float shz_coshf (float x) noexcept
 
float shz_tanhf (float x) noexcept
 
float shz_cschf (float x) noexcept
 
float shz_sechf (float x) noexcept
 
float shz_cothf (float x) noexcept
 
Inverse Hyperbolic Functions

Inverse trigonometric functions for hyperbolas

float shz_asinhf (float x) noexcept
 
float shz_acoshf (float x) noexcept
 
float shz_atanhf (float x) noexcept
 
float shz_acschf (float x) noexcept
 
float shz_asechf (float x) noexcept
 
float shz_acothf (float x) noexcept
 

Detailed Description

Trigonometry functions and macros.

This file provides an API offering fast versions of trigonometry functions.

Author
2025, 2026 Falco Girgis
2025 Paul Cercueil

Definition in file shz_trig.h.

Macro Definition Documentation

◆ SHZ_F_PI

#define SHZ_F_PI

Single-precision floating-point PI approximation (do not use M_PI!)

Definition at line 27 of file shz_trig.h.

◆ SHZ_F_TAU

#define SHZ_F_TAU

Single-precision FP PI approximation times 2.

Definition at line 29 of file shz_trig.h.

◆ SHZ_F_PI_2

#define SHZ_F_PI_2

Single-precision FP PI approximation divided by 2.

Definition at line 31 of file shz_trig.h.

◆ SHZ_F_PI_4

#define SHZ_F_PI_4

Single-precision FP PI approximation divided by 4.

Definition at line 33 of file shz_trig.h.

◆ SHZ_FSCA_RAD_FACTOR

#define SHZ_FSCA_RAD_FACTOR

Multiplicative factor for passing the FSCA instruction angles in radians.

Definition at line 35 of file shz_trig.h.

◆ SHZ_FSCA_DEG_FACTOR

#define SHZ_FSCA_DEG_FACTOR

Multiplicative factor for passing the FSCA instrution angles in degrees.

Definition at line 37 of file shz_trig.h.

◆ SHZ_FSCA_ERROR_MAX

#define SHZ_FSCA_ERROR_MAX

Maximum FP error for FSCA instruction.

Definition at line 39 of file shz_trig.h.

◆ SHZ_DEG_TO_RAD

#define SHZ_DEG_TO_RAD ( deg)

Converts the given angle in degrees to radians.

Definition at line 42 of file shz_trig.h.

◆ SHZ_RAD_TO_DEG

#define SHZ_RAD_TO_DEG ( rad)

Converts the given angle in radians to degrees.

Definition at line 44 of file shz_trig.h.

Typedef Documentation

◆ shz_sincos

Alternate C shz_sincos_t typedef for those who hate POSIX style.

Definition at line 63 of file shz_trig.h.

Function Documentation

◆ shz_sincosu16()

shz_sincos_t shz_sincosu16 ( uint16_t radians16)
noexcept

Returns sinf()/cosf() pairs for the given unsigned 16-bit angle in radians.

◆ shz_sincosf()

shz_sincos_t shz_sincosf ( float radians)
noexcept

Returns sinf()/cosf() pairs for the given floating-point angle in radians.

◆ shz_sincosf_deg()

shz_sincos_t shz_sincosf_deg ( float degrees)
noexcept

Returns sinf/cosf() pairs for the given floating-point angle in degrees.

◆ shz_sincos_tanf()

float shz_sincos_tanf ( shz_sincos_t sincos)
noexcept

Returns tanf() from the given pre-computed sincos pair.

◆ shz_sincos_secf()

float shz_sincos_secf ( shz_sincos_t sincos)
noexcept

Returns the floating-point secant (1.0f / cosf(x)) from the given pre-computed sincos pair.

◆ shz_sincos_cscf()

float shz_sincos_cscf ( shz_sincos_t sincos)
noexcept

Returns the floating-point cosecant (1.0f / sinf(x)) from the given pre-computed sincos pair.

◆ shz_sincos_cotf()

float shz_sincos_cotf ( shz_sincos_t sincos)
noexcept

Returns the floating-point cotangent (1.0f / tanf(x)) from the given pre-computed sincos pair.

◆ shz_sinf()

float shz_sinf ( float radians)
noexcept

One-off routine for returning only sinf() from an angle in radians.

◆ shz_sinf_deg()

float shz_sinf_deg ( float degrees)
noexcept

One-off routine for returning only sinf() from an angle in degrees.

◆ shz_cosf()

float shz_cosf ( float radians)
noexcept

One-off routine for returning only cosf() from an angle in radians.

◆ shz_cosf_deg()

float shz_cosf_deg ( float degrees)
noexcept

One-off routine for returning only cosf() from an angle in degrees.

◆ shz_tanf()

float shz_tanf ( float radians)
noexcept

One-off routine for returning only tanf() from an angle in radians.

◆ shz_tanf_deg()

float shz_tanf_deg ( float degrees)
noexcept

One-off routine for returning only tanf() from an angle in degrees.

◆ shz_secf()

float shz_secf ( float radians)
noexcept

One-off routine for returning only secant (1 / cos(x)) from an angle in radians.

◆ shz_secf_deg()

float shz_secf_deg ( float degrees)
noexcept

One-off routine for returning only secant (1 / cos(x)) from an angle in degrees.

◆ shz_cscf()

float shz_cscf ( float radians)
noexcept

One-off routine for returning only cosecant (1 / sin(x)) from an angle in radians.

◆ shz_cscf_deg()

float shz_cscf_deg ( float degrees)
noexcept

One-off routine for returning only cosecant (1 / sin(x)) from an angle in degrees.

◆ shz_cotf()

float shz_cotf ( float radians)
noexcept

One-off routine for returning only cotangent (1 / tan(x)) from an angle in radians.

◆ shz_cotf_deg()

float shz_cotf_deg ( float degrees)
noexcept

One-off routine for returning only cotangent (1 / cot(x)) from an angle in degrees.

◆ shz_asinf()

float shz_asinf ( float x)
noexcept

Fast arcsine approximation; equivalent to C's asinf().

◆ shz_acosf()

float shz_acosf ( float x)
noexcept

Fast arccosine approximation; equivalent to C's acosf().

◆ shz_atanf_unit()

float shz_atanf_unit ( float x)
noexcept

Fast arctangent approximation for unit values between 0.0f and 1.0f.

◆ shz_atanf_q1()

float shz_atanf_q1 ( float x)
noexcept

Fast arctangent approximation for values lying within the first quadrant (>= 0.0f).

◆ shz_atanf()

float shz_atanf ( float x)
noexcept

Fast arctangent approximation; equvalent to C's atanf().

◆ shz_atan2f()

float shz_atan2f ( float y,
float x )
noexcept

Computes arctangent of y / x, using the signs of arguments to determine correct quadtrant. Equivalent to C's atan2f().

◆ shz_asecf()

float shz_asecf ( float x)
noexcept

Fast arcsecant/inverse secant approximation, taking units in radians.

◆ shz_acscf()

float shz_acscf ( float x)
noexcept

Fast arccosecant/inverse cosecant approximation; taking units in radians.

◆ shz_acotf()

float shz_acotf ( float x)
noexcept

Fast arccotangent/inverse cotangent approximation; taking units in radians.

◆ shz_sinhf()

float shz_sinhf ( float x)
noexcept

Fast hyperbolic sine function.

◆ shz_coshf()

float shz_coshf ( float x)
noexcept

Fast hyperbolic cosine function.

◆ shz_tanhf()

float shz_tanhf ( float x)
noexcept

Fast hyperbolic tangent function.

◆ shz_cschf()

float shz_cschf ( float x)
noexcept

Fast hyperbolic cosecant function.

◆ shz_sechf()

float shz_sechf ( float x)
noexcept

Fast hyperbolic secant function.

◆ shz_cothf()

float shz_cothf ( float x)
noexcept

Fast hyperbolic cotangent function.

◆ shz_asinhf()

float shz_asinhf ( float x)
noexcept

Fast hyperbolic arcsine function.

◆ shz_acoshf()

float shz_acoshf ( float x)
noexcept

Fast hyperbolic arccosine function.

◆ shz_atanhf()

float shz_atanhf ( float x)
noexcept

Fast hyperbolic arctangent function.

◆ shz_acschf()

float shz_acschf ( float x)
noexcept

Fast hyperbolic arccosecant function.

◆ shz_asechf()

float shz_asechf ( float x)
noexcept

Fast hyperbolic arcsecant function.

◆ shz_acothf()

float shz_acothf ( float x)
noexcept

Fast hyperbolic arccotangent function.