Skip to content
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

Bug when generating voronoi clipped in a rectangle with only 2 vertices #68

Open
davi-v opened this issue Sep 17, 2022 · 0 comments
Open

Comments

@davi-v
Copy link

davi-v commented Sep 17, 2022

I was running simulations using your library, and I found some errors. Here's an example:

jcv_diagram d{};

// example that fails using double
//jcv_point points[]
//{
//	{888.19238281250000, 377.82843017578125},
//	{914.00000000000000, 341.00000000000000},
//};

// example that fails using the standard float version of the library
jcv_point points[]
	{
		{883.382263f, 340.749908f},
		{850.622253f, 378.323486f},
	};

jcv_rect rect;
rect.min = { 600, 250 };
rect.max = { 1000, 650 };
const auto count = sizeof(points) / sizeof(*points);
jcv_diagram_generate(count, points, &rect, 0, &d);
const jcv_site* sites = jcv_diagram_get_sites(&d);
for (int i = 0; i != d.numsites; i++)
{
	const jcv_site* site = &sites[i];
	const jcv_graphedge* e = site->edges;
	int cnt = 0;
	while (e)
	{
		cnt++;
		e = e->next;
	}
	std::cout << cnt << " sides\n";
}

/* output:
4 sides
2 sides
Obviously wrong. One can clearly see the voronoi should have 5 sides and 3 sides in each cell
*/

I believe it is associated with this issue, but this one is easier to reproduce because of only 2 vertices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant