Remove Triangle::points

With the `points` field public, it has become redundant.
This commit is contained in:
Hanno Braun 2024-07-29 19:25:50 +02:00
parent be31c2d10a
commit 14e1982545
6 changed files with 7 additions and 12 deletions

View File

@ -42,7 +42,7 @@ impl Polygon {
} }
pub fn contains_triangle(&self, triangle: impl Into<Triangle<2>>) -> bool { pub fn contains_triangle(&self, triangle: impl Into<Triangle<2>>) -> bool {
let [a, b, c] = triangle.into().points(); let [a, b, c] = triangle.into().points;
let mut might_be_hole = true; let mut might_be_hole = true;

View File

@ -89,7 +89,7 @@ pub fn export_stl(
) -> Result<(), Error> { ) -> Result<(), Error> {
let points = mesh let points = mesh
.triangles() .triangles()
.map(|triangle| triangle.inner.points()) .map(|triangle| triangle.inner.points)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let vertices = points.iter().map(|points| { let vertices = points.iter().map(|points| {
@ -136,7 +136,7 @@ pub fn export_obj(
) -> Result<(), Error> { ) -> Result<(), Error> {
for (cnt, t) in mesh.triangles().enumerate() { for (cnt, t) in mesh.triangles().enumerate() {
// write each point of the triangle // write each point of the triangle
for v in t.inner.points() { for v in t.inner.points {
wavefront_rs::obj::writer::Writer { auto_newline: true } wavefront_rs::obj::writer::Writer { auto_newline: true }
.write( .write(
&mut write, &mut write,

View File

@ -80,7 +80,7 @@ impl Mesh<Point<3>> {
) { ) {
let triangle = triangle.into(); let triangle = triangle.into();
for point in triangle.points() { for point in triangle.points {
self.push_vertex(point); self.push_vertex(point);
} }

View File

@ -78,7 +78,7 @@ impl Transform {
/// Transform the given triangle /// Transform the given triangle
pub fn transform_triangle(&self, triangle: &Triangle<3>) -> Triangle<3> { pub fn transform_triangle(&self, triangle: &Triangle<3>) -> Triangle<3> {
let [a, b, c] = &triangle.points(); let [a, b, c] = &triangle.points;
Triangle::from([ Triangle::from([
self.transform_point(a), self.transform_point(a),
self.transform_point(b), self.transform_point(b),

View File

@ -23,11 +23,6 @@ impl<const D: usize> Triangle<D> {
Self { points } Self { points }
} }
/// Access the triangle's points
pub fn points(&self) -> [Point<D>; 3] {
self.points
}
/// # Determine whether the triangle is valid /// # Determine whether the triangle is valid
/// ///
/// A triangle is valid, if it is not degenerate. In a degenerate triangle, /// A triangle is valid, if it is not degenerate. In a degenerate triangle,
@ -88,7 +83,7 @@ impl Triangle<2> {
impl Triangle<3> { impl Triangle<3> {
/// Convert the triangle to a Parry triangle /// Convert the triangle to a Parry triangle
pub fn to_parry(self) -> parry3d_f64::shape::Triangle { pub fn to_parry(self) -> parry3d_f64::shape::Triangle {
self.points().map(|vertex| vertex.to_na()).into() self.points.map(|vertex| vertex.to_na()).into()
} }
/// Cast a ray against the Triangle /// Cast a ray against the Triangle

View File

@ -29,7 +29,7 @@ impl From<&Mesh<fj_math::Point<3>>> for Vertices {
let mut m = Mesh::new(); let mut m = Mesh::new();
for triangle in mesh.triangles() { for triangle in mesh.triangles() {
let [a, b, c] = triangle.inner.points(); let [a, b, c] = triangle.inner.points;
let normal = (b - a).cross(&(c - a)).normalize(); let normal = (b - a).cross(&(c - a)).normalize();
let color = triangle.color; let color = triangle.color;