Skip to main content

Cordic64

Struct Cordic64 

Source
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

Source

pub const FRACTIONAL_BITS: u32 = 62

Number of fractional bits in the signed results.

Source

pub const ONE: i64

The fixed-point representation of 1.0.

Source

pub const MAX_ITERATIONS: u32 = 62

The maximum number of micro-rotations.

Source

pub const DEFAULT_ITERATIONS: u32 = 52

A good default iteration count (about the accuracy floor of the word size).

Source

pub fn new(iterations: u32) -> Result<Cordic64, ErrorsJSL>

Creates a rotator with iterations micro-rotations (1 to Self::MAX_ITERATIONS).

Source

pub fn iterations(&self) -> u32

Source

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.

Source

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.

Source

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.

Source

pub fn angle_from_turns(turns: f64) -> u64

Converts an angle in turns to a binary angle (modulo one turn).

Source

pub fn angle_from_radians(radians: f64) -> u64

Converts an angle in radians to a binary angle (modulo one turn).

Source

pub fn angle_to_radians(angle: u64) -> f64

Converts a binary angle to radians in [0, 2*pi).

Trait Implementations§

Source§

impl Clone for Cordic64

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Cordic64

Source§

impl Debug for Cordic64

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.