Skip to content

Commit

Permalink
filtering of colinear vertices during fan triangulation
Browse files Browse the repository at this point in the history
  • Loading branch information
benediktschwab committed Aug 3, 2023
1 parent 56a5513 commit 391b51f
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import arrow.core.nonEmptyListOf
import arrow.core.right
import io.rtron.math.geometry.euclidean.threed.point.Vector3D
import io.rtron.math.geometry.euclidean.threed.surface.Polygon3D
import io.rtron.math.processing.isColinear

/**
* Fan triangulation algorithm by simply selecting a base vertex and generating the triangles by iterating over
Expand All @@ -38,6 +39,7 @@ class FanTriangulationAlgorithm : TriangulationAlgorithm() {

val polygons = vertices.tail
.zipWithNext()
.filter { !listOf(vertices.head, it.first, it.second).isColinear(tolerance) }
.map { Polygon3D(nonEmptyListOf(vertices.head, it.first, it.second), tolerance) }

return polygons.right()
Expand Down

0 comments on commit 391b51f

Please sign in to comment.