Closed mpadge closed 5 years ago
Looks interesting. I will look into this in a few days. Might be a good opportunity to add unit tests and verify each function against V8 version. Were parameters the same in both versions? How was the convex hull computed for the CPP version?
Using the Python wrapper on your data I obtain different results. Not saying they are perfect / the same as V8 but they look more reasonable. Would be good to agree on common testing code.
I used the following:
from concaveman import concaveman2d
from scipy.spatial import ConvexHull
import numpy as np
x = [189, 189, 189, 190, 190, 190, 191, 191, 191, 191, 191, 192, 192, 192, 192, 193, 193, 193, 193, 193, 193, 194, 194, 194, 194, 194, 194, 195, 195, 195, 195, 195,$
y = [1124, 1129, 1134, 1126, 1131, 1136, 1126, 1131, 1136, 1142, 1147, 1127, 1133, 1138, 1144, 1124, 1129, 1135, 1140, 1145, 1151, 1125, 1130, 1136, 1141, 1146, 115$
pts = list(zip(x, y))
pts = np.array(pts)
h = ConvexHull(pts)
cc = concaveman2d(pts, h.vertices, 1, 10)
concaveman2d(pts, h.vertices, 1, 10)
concaveman2d(pts, h.vertices, 1, 0)
Thanks for investigating, and i can confirm that the python code works:
That was enough to prompt me to dig deeper into my wrapper and work out that it was my mistake anyway. Result now looks like this:
Sorry about that, and thanks again!
Nice. Thank you for this and for your kind words about my work. I still think it would be good to comprehensively test V8 vs. CPP. I will remember this when I have some free time.
Hi @sadaszewski just wanted to let you know that i've done the benchmarking here, with very clear results as expected. Your C++ implementation is 6-7 times faster than the .js
version. Feel free to use/abuse that result and associated code as you like. Nice work!
Hi @mpadge, many thanks - your input is much appreciated. C++ is definitely the winner here, so easy to call from anywhere and so fast. When C++20 modules land I foretell a great Renaissance for C++ :)
The following data give an apparently wrong result:
The result then looks like this:
The
V8
version gives the expected result like this:You should be able to copy-paste those data into a
main
fn to reproduce ... Any help would be greatly appreciated. Thanks again!