Fix method being too broadly available

This implementation (transforming only the canonical form) makes sense
for 1-dimensional vertices. If the edge it bounds is transformed, then
the 1D form of the vertex doesn't need to be transformed, as the curve,
and therefore the vertices whole coordinate system, is transformed with
the edge. The canonical form needs to be transformed, so the conversion
back into 3D space is correct.

However, this method was available for 3D vertices too. In that case,
the implementation is incorrect, as the vertex location is identical to
its canonical form, and both need to be kept identical.
This commit is contained in:
Hanno Braun 2022-02-21 15:05:13 +01:00
parent 7c41b87f62
commit 61f339ba45
1 changed files with 12 additions and 10 deletions

View File

@ -69,6 +69,18 @@ impl Vertex<3> {
}
}
impl Vertex<1> {
/// Create a transformed vertex
///
/// The transformed vertex has its canonical form transformed by the
/// transformation provided, but is otherwise identical.
#[must_use]
pub fn transform(mut self, transform: &Transform) -> Self {
self.canonical = transform.transform_point(&self.canonical);
self
}
}
impl<const D: usize> Vertex<D> {
/// Access the location of this vertex
pub fn location(&self) -> &Point<D> {
@ -82,14 +94,4 @@ impl<const D: usize> Vertex<D> {
canonical: self.canonical,
}
}
/// Create a transformed vertex
///
/// The transformed vertex has its canonical form transformed by the
/// transformation provided, but is otherwise identical.
#[must_use]
pub fn transform(mut self, transform: &Transform) -> Self {
self.canonical = transform.transform_point(&self.canonical);
self
}
}