use core::ops::{Add, Mul};
use num_traits::real::Real;
use num_traits::{One, Zero};
pub use self::{vector2::*, vector3::*, vector4::*};
mod vector2;
mod vector3;
mod vector4;
pub trait Vector<T, const DIM: usize> {
fn broadcast(value: T) -> Self
where
T: Copy;
fn zero() -> Self
where
T: Zero + Copy;
fn one() -> Self
where
T: One + Copy;
fn iota() -> Self
where
T: Zero + One;
fn into_array(self) -> [T; DIM];
fn dot(self, other: Self) -> T
where
T: Add<Output = T> + Mul<Output = T> + Copy;
fn magnitude_squared(self) -> T
where
T: Copy + Add<Output = T> + Mul<Output = T>;
fn magnitude(self) -> T
where
T: Add<Output = T> + Real;
fn apply<F>(&mut self, f: F)
where
T: Copy,
F: Fn(T) -> T;
fn min(&self, other: &Self) -> Self
where
T: Ord + Copy;
fn max(&self, other: &Self) -> Self
where
T: Ord + Copy;
fn ceil(&self) -> Self
where
T: Real;
fn floor(&self) -> Self
where
T: Real;
fn sum(self) -> T
where
T: Add<T, Output = T>;
fn sqrt(self) -> Self
where
T: Real;
}
pub trait VectorMap<T, U> {
type Output;
fn map<F>(&self, f: F) -> Self::Output
where
F: Fn(T) -> U;
}