Trait typed_floats::Hypot
source · pub trait Hypot<T> {
type Output;
// Required method
fn hypot(self, rhs: T) -> Self::Output;
}
Expand description
This trait is used to specify the return type of the Hypot::hypot()
function.
Required Associated Types§
sourcetype Output
type Output
The resulting type after applying Hypot::hypot()
.
Required Methods§
sourcefn hypot(self, rhs: T) -> Self::Output
fn hypot(self, rhs: T) -> Self::Output
Compute the distance between the origin and a point (x
, y
) on the
Euclidean plane. Equivalently, compute the length of the hypotenuse of a
right-angle triangle with other sides having length x.abs()
and
y.abs()
.
§Examples
let x: NonNaN = 3.0.try_into().unwrap();
let y: NonNaN = 4.0.try_into().unwrap();
assert_eq!(x.hypot(y), 5.0);
See f64::hypot()
for more details.