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§

trig_table_gen_f32
Generate a trig table of F32s. Provide the size of the table in usize.
trig_table_gen_f64
Generate a trig table of F64s. Provide the size of the table in usize.

Structs§

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

Constants§

FULL_CIRC_F32
Full circumference in radians, equal to 2π. F32.
FULL_CIRC_F64
Full circumference in radians, equal to 2π. F32.
GEN_LIMIT_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.
GEN_LIMIT_F64
Generation limit for the trig table. F64
HALF_CIRC_F32
Half circumference in radians, equal to 1π. F32.
HALF_CIRC_F64
Half circumference in radians, equal to 1π. F64.
PI_F32
Archimedes’ constant (π)
PI_F64
Archimedes’ constant (π)
QUART_CIRC_F32
Quarter circumference in radians, equal to ½π. F32.
QUART_CIRC_F64
Quarter circumference in radians, equal to ½π. F64.

Functions§

abs_f32
Get the absolute value of a float. F32.
abs_f64
Get the absolute value of a float. F64.
rem_32
Corrected remainder due to floating point silliness
rem_64
Corrected remainder due to floating point silliness