Skip to content

Update geom.c#2

Open
dolfje wants to merge 3 commits intoxmdi:mainfrom
dolfje:patch-1
Open

Update geom.c#2
dolfje wants to merge 3 commits intoxmdi:mainfrom
dolfje:patch-1

Conversation

@dolfje
Copy link

@dolfje dolfje commented May 10, 2022

The algorithm didn't work for the following 2 intersecting triangles:

float triangle1_pts[3][3]={{0,1000,0},{0,1000,1000},{1000,1000,1000}};
float triangle1_norm[3];
getNormal(triangle1_pts[0],triangle1_pts[1],triangle1_pts[2],triangle1_norm);
struct FACE* triangle1=makePolygonFace(3,triangle1_norm,triangle1_pts);

float triangle2_pts[3][3]={{375,775,625},{375,1025,625},{625,1025,625}};	
float triangle2_norm[3];
getNormal(triangle2_pts[0],triangle2_pts[1],triangle2_pts[2],triangle2_norm);
struct FACE* triangle2=makePolygonFace(3,triangle2_norm,triangle2_pts);

result=classifyTriangleIntersect(triangle1,triangle2);
printf("Triangle1-Triangle2 Intersection Test Result: %d\n",result);
if (result)
	triangleIntersectionPoints(triangle1,triangle2);

dolfje added 2 commits May 10, 2022 15:37
The algorithm didn't work for the following 2 intersecting triangles:

	float triangle1_pts[3][3]={{0,1000,0},{0,1000,1000},{1000,1000,1000}};
	float triangle1_norm[3];
	getNormal(triangle1_pts[0],triangle1_pts[1],triangle1_pts[2],triangle1_norm);
	struct FACE* triangle1=makePolygonFace(3,triangle1_norm,triangle1_pts);

	float triangle2_pts[3][3]={{375,775,625},{375,1025,625},{625,1025,625}};	
	float triangle2_norm[3];
	getNormal(triangle2_pts[0],triangle2_pts[1],triangle2_pts[2],triangle2_norm);
	struct FACE* triangle2=makePolygonFace(3,triangle2_norm,triangle2_pts);

	result=classifyTriangleIntersect(triangle1,triangle2);
	printf("Triangle1-Triangle2 Intersection Test Result: %d\n",result);
	if (result)
		triangleIntersectionPoints(triangle1,triangle2);
From in the paper:
Let i,j,k,l be the intersection points of L with edges p1 r1, p1 q1, p2 q2, p2 r2

Also gives an accurate intersection line for
triangle1: x: 0, y: 1000, z: 0 x: 0, y: 1000, z: 1000 x: 1000, y: 1000, z: 1000
triangle2: x: 375, y: 775, z: 375 x: 375, y: 1025, z: 375 x: 625, y: 1025, z: 375
@dolfje
Copy link
Author

dolfje commented May 10, 2022

Another fix:

From in the paper:
Let i,j,k,l be the intersection points of L with edges p1 r1, p1 q1, p2 q2, p2 r2

Also gives an accurate intersection line for
triangle1: x: 0, y: 1000, z: 0 x: 0, y: 1000, z: 1000 x: 1000, y: 1000, z: 1000
triangle2: x: 375, y: 775, z: 375 x: 375, y: 1025, z: 375 x: 625, y: 1025, z: 375

Swapping and rotating cannot be done at the same time. As you didn't put vertex 0 correct on the face2 yet, you cannot be sure to swap 1 and 2.
@dolfje
Copy link
Author

dolfje commented May 10, 2022

Swapping and rotating cannot be done at the same time. As you didn't put vertex 0 correct on the face2 yet, you cannot be sure to swap 1 and 2.

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 this pull request may close these issues.

1 participant