Trait micromath::F32Ext

source ·
pub trait F32Ext: Sized {
Show 29 methods // Required methods fn abs(self) -> f32; fn asin(self) -> f32; fn acos(self) -> f32; fn atan(self) -> f32; fn atan_norm(self) -> f32; fn atan2(self, other: f32) -> f32; fn atan2_norm(self, other: f32) -> f32; fn ceil(self) -> f32; fn cos(self) -> f32; fn div_euclid(self, other: f32) -> f32; fn floor(self) -> f32; fn hypot(self, other: f32) -> f32; fn inv(self) -> f32; fn invsqrt(self) -> f32; fn rem_euclid(self, other: f32) -> f32; fn sin(self) -> f32; fn sqrt(self) -> f32; fn tan(self) -> f32; fn trunc(self) -> f32; fn round(self) -> f32; fn fract(self) -> f32; fn copysign(self, sign: f32) -> f32; fn ln(self) -> f32; fn exp(self) -> f32; fn log(self, base: f32) -> f32; fn log2(self) -> f32; fn log10(self) -> f32; fn powf(self, n: f32) -> f32; fn powi(self, n: i32) -> f32;
}
Expand description

f32 extension providing various arithmetic approximations and polyfills for std functionality.

Required Methods§

source

fn abs(self) -> f32

Compute absolute value with a constant-time, data-independent implementation.

source

fn asin(self) -> f32

Approximate asin(x) in radians in the range [-pi/2, pi/2].

source

fn acos(self) -> f32

Approximate acos(x) in radians in the range [0, pi]

source

fn atan(self) -> f32

Approximate atan(x) in radians with a maximum error of 0.002.

source

fn atan_norm(self) -> f32

Approximate atan(x) normalized to the [−1,1] range with a maximum error of 0.1620 degrees.

source

fn atan2(self, other: f32) -> f32

Approximate the four quadrant arctangent atan2(x) in radians, with a maximum error of 0.002.

source

fn atan2_norm(self, other: f32) -> f32

Approximate the four quadrant arctangent. Normalized to the [0,4) range with a maximum error of 0.1620 degrees.

source

fn ceil(self) -> f32

Approximate floating point ceiling.

source

fn cos(self) -> f32

Approximate cosine in radians with a maximum error of 0.002.

source

fn div_euclid(self, other: f32) -> f32

Calculates Euclidean division, the matching method for rem_euclid.

source

fn floor(self) -> f32

Approximate floating point floor.

source

fn hypot(self, other: f32) -> f32

Approximate the length of the hypotenuse of a right-angle triangle given legs of length x and y.

source

fn inv(self) -> f32

Approximate 1/x with an average deviation of ~8%.

source

fn invsqrt(self) -> f32

Approximate inverse square root with an average deviation of ~5%.

source

fn rem_euclid(self, other: f32) -> f32

Calculates the least nonnegative remainder of self (mod other).

source

fn sin(self) -> f32

Approximate sine in radians with a maximum error of 0.002.

source

fn sqrt(self) -> f32

Approximate square root with an average deviation of ~5%.

source

fn tan(self) -> f32

Approximate tan(x) in radians with a maximum error of 0.6.

source

fn trunc(self) -> f32

Retrieve whole number part of floating point with sign.

source

fn round(self) -> f32

Round the number part of floating point with sign.

source

fn fract(self) -> f32

Retrieve the fractional part of floating point with sign.

source

fn copysign(self, sign: f32) -> f32

Copies the sign from one number to another and returns it.

source

fn ln(self) -> f32

Approximate ln(x).

source

fn exp(self) -> f32

Approximate e^x.

source

fn log(self, base: f32) -> f32

Approximate log with an arbitrary base.

source

fn log2(self) -> f32

Approximate log2.

source

fn log10(self) -> f32

Approximate log10.

source

fn powf(self, n: f32) -> f32

Approximate self^n.

source

fn powi(self, n: i32) -> f32

Approximate self^n where n is an i32

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl F32Ext for f32

source§

fn abs(self) -> f32

source§

fn asin(self) -> f32

source§

fn acos(self) -> f32

source§

fn atan(self) -> f32

source§

fn atan_norm(self) -> f32

source§

fn atan2(self, other: f32) -> f32

source§

fn atan2_norm(self, other: f32) -> f32

source§

fn ceil(self) -> f32

source§

fn cos(self) -> f32

source§

fn div_euclid(self, other: f32) -> f32

source§

fn floor(self) -> f32

source§

fn hypot(self, other: f32) -> f32

source§

fn inv(self) -> f32

source§

fn invsqrt(self) -> f32

source§

fn rem_euclid(self, other: f32) -> f32

source§

fn sin(self) -> f32

source§

fn sqrt(self) -> f32

source§

fn tan(self) -> f32

source§

fn trunc(self) -> f32

source§

fn round(self) -> f32

source§

fn fract(self) -> f32

source§

fn copysign(self, sign: f32) -> f32

source§

fn ln(self) -> f32

source§

fn exp(self) -> f32

source§

fn log(self, base: f32) -> f32

source§

fn log2(self) -> f32

source§

fn log10(self) -> f32

source§

fn powf(self, n: f32) -> f32

source§

fn powi(self, n: i32) -> f32

Implementors§