pub struct Point { /* private fields */ }Expand description
A point in dimensional space
Implementations§
Source§impl Point
impl Point
Sourcepub fn new(dims: Vec<f32>) -> Self
pub fn new(dims: Vec<f32>) -> Self
Create a new point from a vector of dimensions
§Example
use arms::Point;
let p = Point::new(vec![1.0, 2.0, 3.0]);
assert_eq!(p.dimensionality(), 3);Sourcepub fn origin(dims: usize) -> Self
pub fn origin(dims: usize) -> Self
Create an origin point (all zeros) of given dimensionality
§Example
use arms::Point;
let origin = Point::origin(768);
assert_eq!(origin.dimensionality(), 768);
assert!(origin.dims().iter().all(|&x| x == 0.0));Sourcepub fn dimensionality(&self) -> usize
pub fn dimensionality(&self) -> usize
Get the dimensionality of this point
Sourcepub fn magnitude(&self) -> f32
pub fn magnitude(&self) -> f32
Calculate the magnitude (L2 norm) of this point
§Example
use arms::Point;
let p = Point::new(vec![3.0, 4.0]);
assert!((p.magnitude() - 5.0).abs() < 0.0001);Sourcepub fn is_normalized(&self) -> bool
pub fn is_normalized(&self) -> bool
Check if this point is normalized (magnitude ≈ 1.0)
Trait Implementations§
impl StructuralPartialEq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnwindSafe for Point
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more