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

Update geom.c #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 18 additions & 24 deletions 015/geom.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,35 +758,29 @@ int classifyTriangleIntersect(struct FACE* face1, struct FACE* face2){
// on that side of the other triangle's plane
if (((Y5<0)&&(Y4>0)&&(Y6>0))||((Y5>0)&&(Y4<0)&&(Y6<0))){
rotateFaceNodes(face1,2);
float Y=magicDeterminant3(face2->node_array[0],face2->node_array[1],
face2->node_array[2],face1->node_array[0]);
if (Y<0){ // assure new node0 on face1 in positive subspace of face2
swapFaceNodes(face2,1,2);
}
y4 = y5;
}
else if (((Y6<0)&&(Y4>0)&&(Y5>0))||((Y6>0)&&(Y4<0)&&(Y5<0))){
rotateFaceNodes(face1,1);
float Y=magicDeterminant3(face2->node_array[0],face2->node_array[1],
face2->node_array[2],face1->node_array[0]);
if (Y<0){ // assure new node0 on face1 in positive subspace of face2
swapFaceNodes(face2,1,2);
}
y4 = y6;
}
if (((Y2<0)&&(Y1>0)&&(Y3>0))||((Y2>0)&&(Y1<0)&&(Y3<0))){
rotateFaceNodes(face2,2);
float Y=magicDeterminant3(face1->node_array[0],face1->node_array[1],
face1->node_array[2],face2->node_array[0]);
if (Y<0){ // assure new node0 on face2 in positive subspace of face1
swapFaceNodes(face1,1,2);
}
y1 = y2;
}
else if (((Y3<0)&&(Y1>0)&&(Y2>0))||((Y3>0)&&(Y1<0)&&(Y2<0))){
rotateFaceNodes(face2,1);
float Y=magicDeterminant3(face1->node_array[0],face1->node_array[1],
face1->node_array[2],face2->node_array[0]);
if (Y<0){ // assure new node0 on face2 in positive subspace of face1
swapFaceNodes(face1,1,2);
}
y1 = y3;
}

// assure new node0 on face2 in positive subspace of face1
if (Y4<0){
swapFaceNodes(face2 ,1,2);
}

// assure new node0 on face2 in positive subspace of face1
if (Y1<0){
swapFaceNodes(face1,1,2);
}

float Y7=magicDeterminant3(face1->node_array[0],face1->node_array[1],
Expand Down Expand Up @@ -839,20 +833,20 @@ void triangleIntersectionPoints(struct FACE* face1, struct FACE* face2){
float point1[3], point2[3];

if (mode==1){ //k-i-l-j intersection, aka intersection from i to l on both triangles
edgeLineIntersection(face1->node_array[0],face1->node_array[1],N3,P3,point1); // i
edgeLineIntersection(face1->node_array[0],face1->node_array[2],N3,P3,point1); // i
edgeLineIntersection(face2->node_array[0],face2->node_array[2],N3,P3,point2); // l
}
else if (mode==2){ //k-i-j-l intersection, aka intersection from i to j on both triangles
edgeLineIntersection(face1->node_array[0],face1->node_array[1],N3,P3,point1); // i
edgeLineIntersection(face1->node_array[0],face1->node_array[2],N3,P3,point2); // j
edgeLineIntersection(face1->node_array[0],face1->node_array[2],N3,P3,point1); // i
edgeLineIntersection(face1->node_array[0],face1->node_array[1],N3,P3,point2); // j
}
else if (mode==3){ //i-k-l-j intersection, aka intersection from k to l on both triangles
edgeLineIntersection(face2->node_array[0],face2->node_array[1],N3,P3,point1); // k
edgeLineIntersection(face2->node_array[0],face2->node_array[2],N3,P3,point2); // l
}
else if (mode==4){ //i-k-j-l intersection, aka intersection from k to j on both triangles
edgeLineIntersection(face2->node_array[0],face2->node_array[1],N3,P3,point1); // k
edgeLineIntersection(face1->node_array[0],face1->node_array[2],N3,P3,point2); // j
edgeLineIntersection(face1->node_array[0],face1->node_array[1],N3,P3,point2); // j
}
printf("Triangle intersection occurs between (%f,%f,%f) & (%f,%f,%f)\n",point1[0],point1[1],point1[2],point2[0],point2[1],point2[2]);
}
Expand Down