pub struct Cordic64 { /* private fields */ }Expand description
A 64-bit CORDIC rotator: u64 binary angles (2^64 per turn, the same width as the NCO
phase) and i64 Q1.62 results. Reaches double-precision accuracy (about 4e-16) at 52
iterations and about 3e-18 at the maximum of 62.
Implementations§
Source§impl Cordic64
impl Cordic64
Sourcepub const FRACTIONAL_BITS: u32 = 62
pub const FRACTIONAL_BITS: u32 = 62
Number of fractional bits in the signed results.
Sourcepub const MAX_ITERATIONS: u32 = 62
pub const MAX_ITERATIONS: u32 = 62
The maximum number of micro-rotations.
Sourcepub const DEFAULT_ITERATIONS: u32 = 52
pub const DEFAULT_ITERATIONS: u32 = 52
A good default iteration count (about the accuracy floor of the word size).
Sourcepub fn new(iterations: u32) -> Result<Cordic64, ErrorsJSL>
pub fn new(iterations: u32) -> Result<Cordic64, ErrorsJSL>
Creates a rotator with iterations micro-rotations (1 to Self::MAX_ITERATIONS).
pub fn iterations(&self) -> u32
Sourcepub fn gain(&self) -> f64
pub fn gain(&self) -> f64
The gain K = Π sqrt(1 + 2^-2i) that the micro-rotations add (about 1.6468), which
the rotator compensates for by starting from 1/K.
Sourcepub fn sin_cos_fixed(&self, angle: u64) -> (i64, i64)
pub fn sin_cos_fixed(&self, angle: u64) -> (i64, i64)
Returns (sin, cos) of a binary angle as signed fixed-point values with
Self::FRACTIONAL_BITS fractional bits, using integer arithmetic only.
Sourcepub fn sin_cos(&self, radians: f64) -> (f64, f64)
pub fn sin_cos(&self, radians: f64) -> (f64, f64)
Floating-point convenience: (sin, cos) of an angle in radians (any real value).
The angle is first quantized to a binary angle.
Sourcepub fn angle_from_turns(turns: f64) -> u64
pub fn angle_from_turns(turns: f64) -> u64
Converts an angle in turns to a binary angle (modulo one turn).
Sourcepub fn angle_from_radians(radians: f64) -> u64
pub fn angle_from_radians(radians: f64) -> u64
Converts an angle in radians to a binary angle (modulo one turn).
Sourcepub fn angle_to_radians(angle: u64) -> f64
pub fn angle_to_radians(angle: u64) -> f64
Converts a binary angle to radians in [0, 2*pi).