SH4ZAM! 0.1.0
Fast math library for the Sega Dreamcast's SH4 CPU
Loading...
Searching...
No Matches
shz::sincos Struct Reference

#include <shz_trig.hpp>

Inheritance diagram for shz::sincos:
Collaboration diagram for shz::sincos:

Public Member Functions

 sincos (shz_sincos_t val) noexcept
 
float sinf () const noexcept
 
float cosf () const noexcept
 
float tanf () const noexcept
 
float secf () const noexcept
 
float cscf () const noexcept
 
float cotf () const noexcept
 
 operator std::pair< float, float > () const noexcept
 

Static Public Member Functions

static sincos from_radians (float rad) noexcept
 
static sincos from_radians (uint16_t rad) noexcept
 
static sincos from_degrees (float deg) noexcept
 

Additional Inherited Members

- Data Fields inherited from shz_sincos_t
float sin
 
float cos
 

Detailed Description

C++ sine/cosine approximation pairs.

This structure contains the precomputed values for both sine and cosine of an angle.

Definition at line 42 of file shz_trig.hpp.

Constructor & Destructor Documentation

◆ sincos()

shz::sincos::sincos ( shz_sincos_t val)
inlinenoexcept

Converting constructor from C struct.

Definition at line 44 of file shz_trig.hpp.

44 :
45 shz_sincos_t(val) {}

Member Function Documentation

◆ from_radians() [1/2]

static sincos shz::sincos::from_radians ( float rad)
inlinestaticnoexcept

Returns a new sin/cos pair from the given angle in radians.

Definition at line 48 of file shz_trig.hpp.

48 {
49 return shz_sincosf(rad);
50 }
shz_sincos_t shz_sincosf(float radians) SHZ_NOEXCEPT
Returns sinf()/cosf() pairs for the given floating-point angle in radians.

◆ from_radians() [2/2]

static sincos shz::sincos::from_radians ( uint16_t rad)
inlinestaticnoexcept

Returns a new sin/cos pair from the given 16-bit integer angle in radians.

Definition at line 53 of file shz_trig.hpp.

53 {
54 return shz_sincosu16(rad);
55 }
shz_sincos_t shz_sincosu16(uint16_t radians16) SHZ_NOEXCEPT
Returns sinf()/cosf() pairs for the given unsigned 16-bit angle in radians.

◆ from_degrees()

static sincos shz::sincos::from_degrees ( float deg)
inlinestaticnoexcept

Returns a new sin/cos pair from the given angle in degrees.

Definition at line 58 of file shz_trig.hpp.

58 {
59 return shz_sincosf_deg(deg);
60 }
shz_sincos_t shz_sincosf_deg(float degrees) SHZ_NOEXCEPT
Returns sinf/cosf() pairs for the given floating-point angle in degrees.

◆ sinf()

float shz::sincos::sinf ( ) const
inlinenoexcept

Returns the sine component from the pair.

Definition at line 63 of file shz_trig.hpp.

63{ return this->sin; }
float sin
sinf() approximation for the angle
Definition shz_trig.h:56

◆ cosf()

float shz::sincos::cosf ( ) const
inlinenoexcept

Returns the cosine component from the pair.

Definition at line 65 of file shz_trig.hpp.

65{ return this->cos; }
float cos
cosf() approximation for the angle
Definition shz_trig.h:57

◆ tanf()

float shz::sincos::tanf ( ) const
inlinenoexcept

Calculates the tangent from the given pair.

Definition at line 67 of file shz_trig.hpp.

67{ return shz_sincos_tanf(*this); }
float shz_sincos_tanf(shz_sincos_t sincos) SHZ_NOEXCEPT
Returns tanf() from the given pre-computed sincos pair.

◆ secf()

float shz::sincos::secf ( ) const
inlinenoexcept

Calculates the secant from the given pair.

Definition at line 69 of file shz_trig.hpp.

69{ return shz_sincos_secf(*this); }
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.

◆ cscf()

float shz::sincos::cscf ( ) const
inlinenoexcept

Calculates the cosecant from the given pair.

Definition at line 71 of file shz_trig.hpp.

71{ return shz_sincos_cscf(*this); }
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.

◆ cotf()

float shz::sincos::cotf ( ) const
inlinenoexcept

Calculates the cotangent from the given pair.

Definition at line 73 of file shz_trig.hpp.

73{ return shz_sincos_cotf(*this); }
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.

◆ operator std::pair< float, float >()

shz::sincos::operator std::pair< float, float > ( ) const
inlinenoexcept

Definition at line 76 of file shz_trig.hpp.

76 {
77 return std::pair(sinf(), cosf());
78 }
float sinf() const noexcept
Returns the sine component from the pair.
Definition shz_trig.hpp:63
float cosf() const noexcept
Returns the cosine component from the pair.
Definition shz_trig.hpp:65

The documentation for this struct was generated from the following file: