Skip to content

Commit

Permalink
triangulate_monotone_polygon: removed bug concerning co-linear revers…
Browse files Browse the repository at this point in the history
…al of

segments
new: test_triangulate_monotone_polygon_colinear,
test_ptNode_colinear_reversal, tests for co-linear vertical lines
removed: test_add_segment_special_5
  • Loading branch information
jahting committed Jul 24, 2014
1 parent 6cbfee2 commit aa47b91
Show file tree
Hide file tree
Showing 6 changed files with 388 additions and 172 deletions.
12 changes: 11 additions & 1 deletion build/pnltri.js
Original file line number Diff line number Diff line change
Expand Up @@ -2183,7 +2183,17 @@ PNLTRI.MonoTriangulator.prototype = {
while ( (frontVert != endVert) || (vertBackLogIdx > 1) ) {
if (vertBackLogIdx > 0) {
// vertBackLog is not empty
if ( PNLTRI.Math.ptsCrossProd( frontVert, vertBackLog[vertBackLogIdx-1], vertBackLog[vertBackLogIdx] ) > 0 ) { // TODO !!
var angle = PNLTRI.Math.ptsCrossProd( frontVert, vertBackLog[vertBackLogIdx-1], vertBackLog[vertBackLogIdx] ); // TODO !!
if ( Math.abs(angle) <= PNLTRI.Math.EPSILON_P ) {
// co-linear
if ( PNLTRI.Math.compare_pts_yx( frontVert, vertBackLog[vertBackLogIdx] ) != PNLTRI.Math.compare_pts_yx( vertBackLog[vertBackLogIdx], vertBackLog[vertBackLogIdx-1] ) ) {
// console.log("triangulate_monotone_polygon: colinear", frontVert.x - vertBackLog[vertBackLogIdx].x, frontVert.y - vertBackLog[vertBackLogIdx].y,
// vertBackLog[vertBackLogIdx].x - vertBackLog[vertBackLogIdx-1].x, vertBackLog[vertBackLogIdx].y - vertBackLog[vertBackLogIdx-1].y,
// frontVert, vertBackLog[vertBackLogIdx], vertBackLog[vertBackLogIdx-1] );
angle = 1; // co-linear-reversal => create triangle
}
}
if ( angle > 0 ) {
// convex corner: cut if off
this.polyData.addTriangle( vertBackLog[vertBackLogIdx-1], vertBackLog[vertBackLogIdx], frontVert );
vertBackLogIdx--;
Expand Down
40 changes: 20 additions & 20 deletions build/pnltri.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aa47b91

Please sign in to comment.