Crate ape_table_trig

source ·
Expand description

Implementations of sin, cos, and tan using precalculated tables.

Using these functions can significantly improve performance on systems with limited to no naitive floating point support, like the RP2040. Designed to be no_std compatible out of the box.

Example:

use ape_table_trig::*;

// Table has an accuracy down to 1πmrad
static TABLE: [f32; 1000] = trig_table_gen_f32!(1000);

fn main() {
    let table = TrigTableF32::new(&TABLE);

    // Calculate the sine of 1π radians
    let sine = table.sin(PI_F32);
}

Macros

Structs

  • Used to perform sin, cos, and tan functions on trig tables. F32.
  • Used to perform sin, cos, and tan functions on trig tables. F64.

Constants

  • Full circumference in radians, equal to 2π. F32.
  • Full circumference in radians, equal to 2π. F32.
  • Generation limit for the trig table. Currently the table generation generates sin(0)..sin(1π), and then uses some math to finesse the table to work for all other values. F32.
  • Generation limit for the trig table. F64
  • Half circumference in radians, equal to 1π. F32.
  • Half circumference in radians, equal to 1π. F64.
  • Archimedes’ constant (π)
  • Archimedes’ constant (π)
  • Quarter circumference in radians, equal to ½π. F32.
  • Quarter circumference in radians, equal to ½π. F64.

Functions

  • Get the absolute value of a float. F32.
  • Get the absolute value of a float. F64.
  • Corrected remainder due to floating point silliness
  • Corrected remainder due to floating point silliness