From d0468e3b8518fec5e1c728c1192389fddf5cd949 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Sun, 10 Nov 2024 20:12:39 +0100 Subject: [PATCH] Sync --- src/per_face_normals.cpp | 8 ++++---- src/triangle_area_normal.cpp | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/per_face_normals.cpp b/src/per_face_normals.cpp index 8ec82cd..68170db 100644 --- a/src/per_face_normals.cpp +++ b/src/per_face_normals.cpp @@ -6,8 +6,8 @@ void per_face_normals( const Eigen::MatrixXi & F, Eigen::MatrixXd & N) { - //////////////////////////////////////////////////////////////////////////// - // Replace with your code: - N = Eigen::MatrixXd::Zero(F.rows(),3); - //////////////////////////////////////////////////////////////////////////// + for (int i = 0; i < F.rows(); i++) + { + N.row(i) = triangle_area_normal(V.row(F(i, 0) - 1), V.row(F(i, 1) - 1), V.row(F(i, 2) - 1)); + } } diff --git a/src/triangle_area_normal.cpp b/src/triangle_area_normal.cpp index 4ecad22..14cdfa5 100644 --- a/src/triangle_area_normal.cpp +++ b/src/triangle_area_normal.cpp @@ -6,8 +6,5 @@ Eigen::RowVector3d triangle_area_normal( const Eigen::RowVector3d & b, const Eigen::RowVector3d & c) { - //////////////////////////////////////////////////////////////////////////// - // Replace with your code: - //////////////////////////////////////////////////////////////////////////// - return Eigen::RowVector3d(0,0,0); + return (a + b + c).normalized() * ((b - a).cross(c - a) / 2.0).norm(); }