Quite inefficient, simple CORDIC algorithm implementation for educational purposes.
Available in both C and Rust.
The C library can be included in C source code with:
#include "cordic.h"Then during compilation, remember compiling the cordic source file along with your code:
gcc -o my-program my-source.c cordic.cThe CLI application can be compiled with:
gcc -o cordic cordic-cli.c cordic.cAfter compilation, you can check the usage options with the following command:
./cordic --helpThe Rust implementation lives in the rust/ directory. It is generic over integer
types (i16, i32) and computes lookup tables at compile time.
Add the crate as a dependency and call cordic:
use cordic::{cordic, CordicMode};
// Rotate the unit vector (1, 0) by 45° using i32 BAMS
let x: i32 = 65536; // 1.0 in Q16 fixed point
let z: i32 = 0x20000000; // 45° in 32-bit BAMS
let (x_out, y_out, z_out) = cordic(CordicMode::Rotate, 30, x, 0, z).unwrap();cd rust && cargo test