// gcc -g -o t3s_recta t3s_recta.c -lm 
#include <stdio.h>
#include <math.h>

#define EPSILON	0.0001	// marge d'error

typedef struct {
	float x, y;
} t_punt;

typedef struct {
	t_punt a, b;
} t_recta;

main() {
	t_punt p;
	t_recta r;
	printf("Intro punt 'x,y': ");
	scanf("%f,%f", &p.x, &p.y);
	printf("Intro recta 'x1,y1 x2,y2': ");
	scanf("%f,%f %f,%f", &r.a.x, &r.a.y, &r.b.x, &r.b.y);
	if (fabs(((r.a.y-r.b.y)/(r.a.x-r.b.x))*(p.x-r.b.x)+r.b.y-p.y) <
			EPSILON)
		printf("El punt pertany a la recta\n");
	else
		printf("El punt NO pertany a la recta\n");
}

