Make Point generic over dimensionality

This commit is contained in:
Hanno Braun 2024-12-17 20:31:55 +01:00
parent ca72d1e897
commit b75389d622
2 changed files with 6 additions and 6 deletions

View File

@ -9,12 +9,12 @@ use super::{
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Vertex { pub struct Vertex {
pub point: Point, pub point: Point<3>,
} }
impl<P> From<P> for Vertex impl<P> From<P> for Vertex
where where
P: Into<Point>, P: Into<Point<3>>,
{ {
fn from(point: P) -> Self { fn from(point: P) -> Self {
Self { Self {

View File

@ -3,11 +3,11 @@ use std::ops;
use super::Vector; use super::Vector;
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Point { pub struct Point<const D: usize> {
pub coords: Vector<3>, pub coords: Vector<D>,
} }
impl<T> From<T> for Point impl<T> From<T> for Point<3>
where where
T: Into<Vector<3>>, T: Into<Vector<3>>,
{ {
@ -18,7 +18,7 @@ where
} }
} }
impl<T> ops::Add<T> for Point impl<T> ops::Add<T> for Point<3>
where where
T: Into<Vector<3>>, T: Into<Vector<3>>,
{ {