Skip to main content

VectorAngle

Trait VectorAngle 

Source
pub trait VectorAngle {
    // Required method
    fn angle(&self, other: &Self) -> Result<f64, LaError>;
}
Expand description

Unsigned angles for borrowed vector coordinates.

Implemented for [f64]. Import this trait directly or through crate::prelude to call left.angle(right) on coordinate slices. For finite fixed-size storage, use crate::Vector::angle, which shares the numerical implementation without repeating coordinate validation.

Required Methods§

Source

fn angle(&self, other: &Self) -> Result<f64, LaError>

Unsigned angle to another finite, nonzero vector, in radians in [0, π].

Borrows equal-length coordinate slices without allocating. Every positive ambient length is supported, including runtime D + 1 spherical coordinates; no matrix dispatch limit applies. Magnitudes may differ arbitrarily and the input norms need not be representable. Signed zeros are treated as zero. Identical inputs return positive zero, and opposite inputs return π.

This is a rounded numerical operation, not an exact parallelism predicate or a correctly rounded result. No certified absolute error bound is provided. An atan2 of the exterior-product norm and dot product avoids the endpoint sensitivity of acos. Power-of-two scaling and compensated products preserve small differences without first rounding normalized directions. Work is quadratic in the ambient length, with constant auxiliary storage; the intended performance scope is small dimensions. An angle below the binary64 output range can round to zero. See the derivation and limitations and REFERENCES.md [18–19].

§Errors

Validation proceeds in this order:

A non-finite computed result is reported as LaError::NonFinite with ArithmeticOperation::VectorAngle computation provenance.

§Examples
use la_stack::prelude::*;

let tiny = f64::from_bits(1);
let left = [1.0, 0.0, 0.0];
let right = [1.0, tiny, 0.0];
assert_eq!(left.as_slice().angle(right.as_slice())?, tiny);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl VectorAngle for [f64]

Source§

fn angle(&self, other: &Self) -> Result<f64, LaError>

Implementors§