You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The triangles produced by the code in the master branch seems to be oriented in clockwise order whereas Mapbox's delaunator library advertises the orientation produced by code to be counterclockwise. Since this is a port of the latter, and that the counterclockwise order is more typical, I was just wondering if this is a bug or is it intentional?
For e.g., running the binary compiled from basic.cpp using the test data
The 3 points of each triangle for this case is clearly in a clockwise order.
I compared the code to the JS code in the Mapbox's repository and I noticed 2 key differences:
inline bool orient(
const double px,
const double py,
const double qx,
const double qy,
const double rx,
const double ry) {
// Current code. This seems to be a bug
// return (qy - py) * (rx - qx) - (qx - px) * (ry - qy) < 0.0;
// orient2dfast from https://github.com/mourner/robust-predicates/blob/master/src/orient2d.js
// The above library appears to be a port of Prof Jonathan Shewchuk's robust predicate library
// Also see Prof Shewchuk's page http://www.cs.cmu.edu/~quake/robust.html
return ((py - ry) * (qx - rx) - (px - rx) * (qy - ry)) < 0.0;
}
Another difference is in the legalize method
// edge swapped on the other side of the hull (rare); fix the halfedge reference
if (hbl == INVALID_INDEX) {
std::size_t e = hull_start;
do {
if (hull_tri[e] == bl) {
hull_tri[e] = a;
break;
}
// Current code
// e = hull_next[e];
// Code in Mapbox's JS library
e = hull_prev[e];
} while (e != hull_start);
}
However, making the above 2 changes still did not fix the orientation.
Am I missing something? Or is the origin at the top-left corner instead of the bottom-left?
The text was updated successfully, but these errors were encountered:
The changes to the method orient are unnecessary as on closer inspection they are equivalent.
The second difference concerning changing hull_next to hull_prev in legalize is addressed in #32 .
Lastly, the origin appears to be at the top-left corner. Closing as no changes needed.
The triangles produced by the code in the master branch seems to be oriented in clockwise order whereas Mapbox's delaunator library advertises the orientation produced by code to be counterclockwise. Since this is a port of the latter, and that the counterclockwise order is more typical, I was just wondering if this is a bug or is it intentional?
For e.g., running the binary compiled from
basic.cpp
using the test dataproduces triangles
The 3 points of each triangle for this case is clearly in a clockwise order.
I compared the code to the JS code in the Mapbox's repository and I noticed 2 key differences:
Another difference is in the
legalize
methodHowever, making the above 2 changes still did not fix the orientation.
Am I missing something? Or is the origin at the top-left corner instead of the bottom-left?
The text was updated successfully, but these errors were encountered: