-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why contour draw out-of-data points #15
Comments
Well, this is not really a bug, but just a side effect of relying on automatic delaunay triangulation. The algorithm doesn't distinguish points on the boundary and on the interior, so the result is always a convex hull. For now, my suggestion is that you perform triangulation manually and send them into the plugin with the If there is a triangulation algorithm that accepts boundary hints, I may build it into the plugin, but I don't know of any on the top of my head. Suggestions? |
Looks like what you need is called Constrained Delaunay, and there are a few JS libraries out there:
I believe cdt2d could be a drop-in replacement, adding extra arguments for @hoanphi2201 Would you mind giving it a try to see if this is good for your needs before I patch the library? |
@paulo-raca Well I will try it. Hopefully you will patch the library as soon as possible. Thank you very much |
@paulo-raca Can you give me a more detailed solution? I do not have much knowledge about delaunay triangulation |
This isn't tested, but should be something like this:
|
Hello @paulo-raca why boundaryIndexes is a 1-dimensional array. I thought the boundary is a 2-dimensional array of x and y |
They are indexes of |
@paulo-raca triangles return [] array. why ? boundaryIndexes from the dataPoints array that at that point is the boundary
|
If remove { exterior: false } return array 747 element |
I guess the boundary might be open? 🤔 Can you dump the contents of |
|
Sounds right.... Thank you |
@paulo-raca Thank you, I hope to receive your feedback soon |
@paulo-raca here is boundary index
|
@paulo-raca I have seen it run properly. |
Nice, what did you have to change? You mean the zig-zaging at the bottom of the image? |
Got an idea: the delaunay triangulation is sensitive to stretching the aspect ratio, and in your case the scale on the x-axis is about 50 times bigger than on the y-axis. To work around that the plug-in normally works with screen coordinates, but we can work around that |
Use _2dPoints.push([dataPoints[i][0], 50*dataPoints[i][1]]) does not change triangles |
Oh, I hadn't understood the problem 🤦♂️ From you previous post, the boundary doesn't include any point with y=0, so it seems like the algorithm is ignoring all points at the bottom of the chart |
I meant they are not inside the boundary you mentioned earlier:
Keep in mind that these form a close polygon,. So you must also include all points with |
I did not understand the boundary point. Do I need to get points with y = 0? |
Yes, that's what I meant. 🤔 I don't know why you are getting an empty result... |
here is here is boundary index, include points with y = 0 (42 element)
|
Thanks! One way is to start your list with upper boundary points ordered by |
@paulo-raca |
Hey guys, come over here from mapbox post, I just made a js library that can be used to create concave polygons, takes in points in unsorted order and spits out a delaunay object or coord array or boundary, what have you... |
Probably too late, but I've added support for cdt2d in the plugin and wrote a demo with concave external boundary: |
These points are not in the data.
https://jsfiddle.net/phihoan2201/2nb8op56/1/
The text was updated successfully, but these errors were encountered: