Implement TranslateExt for Vertex

This commit is contained in:
Hanno Braun 2025-02-24 19:23:10 +01:00
parent dd0074abdd
commit 3754d9e9b2
2 changed files with 13 additions and 8 deletions

View File

@ -1,4 +1,8 @@
use crate::{math::Vector, object::Handle, topology::face::Face};
use crate::{
math::Vector,
object::Handle,
topology::{face::Face, vertex::Vertex},
};
pub trait TranslateExt {
fn translate(self, offset: impl Into<Vector<3>>) -> Self;
@ -16,3 +20,10 @@ impl TranslateExt for Face {
)
}
}
impl TranslateExt for Vertex {
fn translate(self, offset: impl Into<Vector<3>>) -> Self {
let offset = offset.into();
Vertex::new(self.point + offset)
}
}

View File

@ -2,7 +2,7 @@ use std::fmt;
use crate::{
geometry::TriMesh,
math::{Point, Vector},
math::Point,
object::{HandleAny, Object},
};
@ -16,12 +16,6 @@ impl Vertex {
let point = point.into();
Self { point }
}
pub fn translate(self, offset: impl Into<Vector<3>>) -> Self {
Self {
point: self.point + offset,
}
}
}
impl Object for Vertex {