Again, you're on the right track.
Code:
float tri_ptA_x, tri_ptA_y, tri_ptA_z;
float tri_ptB_x, tri_ptB_y, tri_ptB_z;
float tri_ptC_x, tri_ptC_y, tri_ptC_z;
float seg_ptP_x, seg_ptP_y, seg_ptP_z;
float seg_ptQ_x, seg_ptQ_y, seg_ptQ_z;
Those definitions above can be substituted for our dot notation. Remember, we're passing in two parameters to our DoesIntersect function. We pass tri and seg. See my above post for the prototype of the function. Instead of 'void', you would have those two parameters.
Then, we can use tri and seg in our DoesIntersect function.
Code:
tri.p1.x = 0;
tri.p1.y = 0;
tri.p1.z = 0;
/* And so on. */
seg.p1.x = 0;
seg.p2.x = 0;
/* And so on. */
I'm tinkering with the rest of your code. Keep posting questions while I work with it.
And I would recommend more descriptive variable names. It took me five minutes just to figure out what a and b and r and u_u_ux are.
***EDIT***
Here is an updated version of your main:
Code:
#include <stdio.h>
#include <math.h>
typedef struct
{
double x;
double y;
double z;
} point;
typedef struct
{
point p1;
point p2;
point p3;
} triangle;
typedef struct
{
point p1;
point p2;
} segment;
int DoesIntersect(triangle tri, segment seg);
int main(void)
{
triangle tri;
segment seg;
int result;
char input_buffer[160];
int check_input;
/** POPULATE YOUR TRIANGLE WITH THREE POINTS HERE. */
printf("TRIANGLE 1, POINT 1-> Input coordinates x y z: ");
fflush(stdout);
fgets(input_buffer, sizeof(input_buffer), stdin);
check_input = sscanf(input_buffer, "%f %f %f", &tri.p1.x, &tri.p1.y, &tri.p1.z);
if (check_input !=3)
{
printf("Improper format.");
return 0;
}
printf("TRIANGLE 1, POINT 2-> Input coordinates x y z: ");
fflush(stdout);
fgets(input_buffer, sizeof(input_buffer), stdin);
check_input = sscanf(input_buffer, "%f %f %f", &tri.p2.x, &tri.p2.y, &tri.p2.z);
if (check_input !=3)
{
printf("Improper format.");
return 0;
}
printf("TRIANGLE 1, POINT 3-> Input coordinates x y z: ");
fflush(stdout);
fgets(input_buffer, sizeof(input_buffer), stdin);
check_input = sscanf(input_buffer, "%f %f %f", &tri.p3.x, &tri.p3.y, &tri.p3.z);
if (check_input !=3)
{
printf("Improper format.");
return 0;
}
/** POPULATE YOUR LINE SEGMENT WITH TWO POINTS HERE. */
printf("SEGMENT 1, POINT 1-> Input coordinates x y z: ");
fflush(stdout);
fgets(input_buffer, sizeof(input_buffer), stdin);
check_input = sscanf(input_buffer, "%f %f %f", &seg.p1.x, &seg.p1.y, &seg.p1.z);
if (check_input !=3)
{
printf("Improper format.");
return 0;
}
printf("SEGMENT 1, POINT 2-> Input coordinates x y z: ");
fflush(stdout);
fgets(input_buffer, sizeof(input_buffer), stdin);
check_input = sscanf(input_buffer, "%f %f %f", &seg.p2.x, &seg.p2.y, &seg.p2.z);
if (check_input !=3)
{
printf("Improper format.");
return 0;
}
/** RUN YOUR INTERSECTION CHECKER HERE. */
result = DoesIntersect(tri, seg);
return 0;
}
Can you understand what I'm doing? Notice how I only worry about ONE triangle and ONE line segment, not 8 or 12 or whatever. Start small.