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

cpml.intersect.segment_segment fails to find intersects for some segments #90

Open
kromka-chleba opened this issue Aug 22, 2024 · 1 comment · May be fixed by #91
Open

cpml.intersect.segment_segment fails to find intersects for some segments #90

kromka-chleba opened this issue Aug 22, 2024 · 1 comment · May be fixed by #91

Comments

@kromka-chleba
Copy link

I'm using CPML's cpml.intersect.segment_segment for finding road intersections in my Minetest mod and I noticed that CPML fails to find intersections for some of them. I compared CPML output with mlib's mlib.segment.getIntersection for the data and mlib finds them correctly.

Data for which CPML fails but mlib works:

Case 1

Seg1: {
	{
		y = -32,
		z = 97,
		x = 448
	},
	{
		y = -32,
		z = 13,
		x = 532
	}
}
Seg2: {
	{
		y = -32,
		z = -12,
		x = 524
	},
	{
		y = -32,
		z = 208,
		x = 524
	}
}
mlib: {
	y = -32,
	z = 21,
	x = 524
}
CPML: nil

Case 2

Seg1: {
	{
		y = -32,
		z = 290,
		x = 688
	},
	{
		y = -32,
		z = 353,
		x = 625
	}
}
Seg2: {
	{
		y = -32,
		z = 208,
		x = 524
	},
	{
		y = -32,
		z = 331,
		x = 647
	}
}
mlib: {
	y = -32,
	z = 331,
	x = 647
}
CPML: nil

Case 3

Seg1: {
	{
		y = -32,
		z = 290,
		x = 688
	},
	{
		y = -32,
		z = 353,
		x = 625
	}
}
Seg2: {
	{
		y = -32,
		z = 331,
		x = 647
	},
	{
		y = -32,
		z = 448,
		x = 647
	}
}
mlib: {
	y = -32,
	z = 331,
	x = 647
}
CPML: nil

Case 4

Seg1: {
	{
		y = -32,
		z = 928,
		x = 489
	},
	{
		y = -32,
		z = 805,
		x = 612
	}
}
Seg2: {
	{
		y = -32,
		z = 810,
		x = 621
	},
	{
		y = -32,
		z = 810,
		x = 448
	}
}
mlib: {
	y = -32,
	z = 810,
	x = 607
}
CPML: nil
@kromka-chleba
Copy link
Author

kromka-chleba commented Aug 23, 2024

Okay, I did more tests and looks like cpml.intersect.line_line finds the intersection correctly but cpml.intersect.segment_segment fails. The reason behind this is that the latter function expects these segments to be component-wise min and max, which is totally weird because then cpml.intersect.line_line gets not the points of the segments but points with mixed components. Which is 1. incorrect 2. not documented anywhere.

I'll make a PR that fixes this soon, but I guess there are no buses in Gensokyo after all.

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

Successfully merging a pull request may close this issue.

1 participant