Skip to content

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

@davi-v

Description

@davi-v

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions