Skip to content

acrilique/cordic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordic

Quite inefficient, simple CORDIC algorithm implementation for educational purposes.

Available in both C and Rust.

C

Library

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.c

CLI App

The CLI application can be compiled with:

gcc -o cordic cordic-cli.c cordic.c

After compilation, you can check the usage options with the following command:

./cordic --help

Rust

The Rust implementation lives in the rust/ directory. It is generic over integer types (i16, i32) and computes lookup tables at compile time.

Usage

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();

Tests

cd rust && cargo test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors