Make Vector generic over dimensionality

This commit is contained in:
Hanno Braun 2024-12-17 20:29:39 +01:00
parent a2393d7325
commit 24ab6c42a2
2 changed files with 8 additions and 8 deletions

View File

@ -4,12 +4,12 @@ use super::Vector;
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Point {
pub coords: Vector,
pub coords: Vector<3>,
}
impl<T> From<T> for Point
where
T: Into<Vector>,
T: Into<Vector<3>>,
{
fn from(coords: T) -> Self {
Self {
@ -20,7 +20,7 @@ where
impl<T> ops::Add<T> for Point
where
T: Into<Vector>,
T: Into<Vector<3>>,
{
type Output = Self;

View File

@ -5,11 +5,11 @@ use iter_fixed::IntoIteratorFixed;
use super::Scalar;
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Vector {
pub components: [Scalar; 3],
pub struct Vector<const D: usize> {
pub components: [Scalar; D],
}
impl<S> From<[S; 3]> for Vector
impl<S> From<[S; 3]> for Vector<3>
where
S: Into<Scalar>,
{
@ -20,9 +20,9 @@ where
}
}
impl<T> ops::Add<T> for Vector
impl<T> ops::Add<T> for Vector<3>
where
T: Into<Vector>,
T: Into<Vector<3>>,
{
type Output = Self;