SH4ZAM! 0.1.0
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_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) SHZ_NOEXCEPT
 
shz_sincos_t shz_sincosf (float radians) SHZ_NOEXCEPT
 
shz_sincos_t shz_sincosf_deg (float degrees) SHZ_NOEXCEPT
 
float shz_sincos_tanf (shz_sincos_t sincos) SHZ_NOEXCEPT
 
float shz_sincos_secf (shz_sincos_t sincos) SHZ_NOEXCEPT
 
float shz_sincos_cscf (shz_sincos_t sincos) SHZ_NOEXCEPT
 
float shz_sincos_cotf (shz_sincos_t sincos) SHZ_NOEXCEPT
 
Independent Functions

Routines providing single trigonometric functions.

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

Routines providing inverse trigonometric functions.

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

Trigonometric functions for hyperbolas

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

Inverse trigonometric functions for hyperbolas

float shz_asinhf (float x) SHZ_NOEXCEPT
 
float shz_acoshf (float x) SHZ_NOEXCEPT
 
float shz_atanhf (float x) SHZ_NOEXCEPT
 
float shz_acschf (float x) SHZ_NOEXCEPT
 
float shz_asechf (float x) SHZ_NOEXCEPT
 
float shz_acothf (float x) SHZ_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_PI_2

#define SHZ_F_PI_2

Single-precision FP PI approximation divided by 2.

Definition at line 29 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 31 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 33 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 35 of file shz_trig.h.

◆ SHZ_FSCA_ERROR_MAX

#define SHZ_FSCA_ERROR_MAX

Maximum FP error for FSCA instruction.

Definition at line 37 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 40 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 42 of file shz_trig.h.

Typedef Documentation

◆ shz_sincos

Alternate C shz_sincos_t typedef for those who hate POSIX style.

Definition at line 61 of file shz_trig.h.

Function Documentation

◆ shz_sincosu16()

shz_sincos_t shz_sincosu16 ( uint16_t radians16)

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

◆ shz_sincosf()

shz_sincos_t shz_sincosf ( float radians)

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

◆ shz_sincosf_deg()

shz_sincos_t shz_sincosf_deg ( float degrees)

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

◆ shz_sincos_tanf()

float shz_sincos_tanf ( shz_sincos_t sincos)

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

◆ shz_sincos_secf()

float shz_sincos_secf ( shz_sincos_t sincos)

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)

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)

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

◆ shz_sinf()

float shz_sinf ( float radians)

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

◆ shz_sinf_deg()

float shz_sinf_deg ( float degrees)

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

◆ shz_cosf()

float shz_cosf ( float radians)

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

◆ shz_cosf_deg()

float shz_cosf_deg ( float degrees)

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

◆ shz_tanf()

float shz_tanf ( float radians)

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

◆ shz_tanf_deg()

float shz_tanf_deg ( float degrees)

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

◆ shz_secf()

float shz_secf ( float radians)

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

◆ shz_secf_deg()

float shz_secf_deg ( float degrees)

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

◆ shz_cscf()

float shz_cscf ( float radians)

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

◆ shz_cscf_deg()

float shz_cscf_deg ( float degrees)

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

◆ shz_cotf()

float shz_cotf ( float radians)

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

◆ shz_cotf_deg()

float shz_cotf_deg ( float degrees)

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

◆ shz_asinf()

float shz_asinf ( float x)

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

◆ shz_acosf()

float shz_acosf ( float x)

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

◆ shz_atanf_unit()

float shz_atanf_unit ( float x)

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

◆ shz_atanf_q1()

float shz_atanf_q1 ( float x)

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

◆ shz_atanf()

float shz_atanf ( float x)

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

◆ shz_atan2f()

float shz_atan2f ( float y,
float x )

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)

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

◆ shz_acscf()

float shz_acscf ( float x)

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

◆ shz_acotf()

float shz_acotf ( float x)

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

◆ shz_sinhf()

float shz_sinhf ( float x)

Fast hyperbolic sine function.

◆ shz_coshf()

float shz_coshf ( float x)

Fast hyperbolic cosine function.

◆ shz_tanhf()

float shz_tanhf ( float x)

Fast hyperbolic tangent function.

◆ shz_cschf()

float shz_cschf ( float x)

Fast hyperbolic cosecant function.

◆ shz_sechf()

float shz_sechf ( float x)

Fast hyperbolic secant function.

◆ shz_cothf()

float shz_cothf ( float x)

Fast hyperbolic cotangent function.

◆ shz_asinhf()

float shz_asinhf ( float x)

Fast hyperbolic arcsine function.

◆ shz_acoshf()

float shz_acoshf ( float x)

Fast hyperbolic arccosine function.

◆ shz_atanhf()

float shz_atanhf ( float x)

Fast hyperbolic arctangent function.

◆ shz_acschf()

float shz_acschf ( float x)

Fast hyperbolic arccosecant function.

◆ shz_asechf()

float shz_asechf ( float x)

Fast hyperbolic arcsecant function.

◆ shz_acothf()

float shz_acothf ( float x)

Fast hyperbolic arccotangent function.