Skip to content

Commit f51da9b

Browse files
committed
Name test properly. Put triangle sum in class for now.
1 parent 1a43db3 commit f51da9b

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

include/delaunator.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,23 @@ double Delaunator::get_hull_area() {
449449
return sum(hull_area);
450450
}
451451

452+
double Delaunator::get_triangle_area()
453+
{
454+
std::vector<double> vals;
455+
for (size_t i = 0; i < triangles.size(); i += 3)
456+
{
457+
const double ax = coords[2 * triangles[i]];
458+
const double ay = coords[2 * triangles[i] + 1];
459+
const double bx = coords[2 * triangles[i + 1]];
460+
const double by = coords[2 * triangles[i + 1] + 1];
461+
const double cx = coords[2 * triangles[i + 2]];
462+
const double cy = coords[2 * triangles[i + 2] + 1];
463+
double val = std::fabs((by - ay) * (cx - bx) - (bx - ax) * (cy - by));
464+
vals.push_back(val);
465+
}
466+
return sum(vals);
467+
}
468+
452469
std::size_t Delaunator::legalize(std::size_t a) {
453470
std::size_t i = 0;
454471
std::size_t ar = 0;

include/delaunator.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Delaunator {
5959

6060
INLINE Delaunator(std::vector<double> const& in_coords);
6161
INLINE double get_hull_area();
62+
INLINE double get_triangle_area();
6263

6364
private:
6465
std::vector<std::size_t> m_hash;

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ function(d_add_test _testfile)
2222
endfunction()
2323

2424
enable_testing()
25-
d_add_test(issue-2.cpp)
25+
d_add_test(issue-8.cpp)
2626
d_add_test(delaunator.test.cpp)
File renamed without changes.

0 commit comments

Comments
 (0)