#include <stdio.h>
#include <math.h>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

typedef struct {
	float x, y;
} Point;

Point get_rotation(Point start, Point center, float rad) {
	Point res;
	res.x = (start.x - center.x) * cos(rad) - (start.y - center.y) * sin(rad) + center.x;
	res.y = (start.x - center.x) * sin(rad) + (start.y - center.y) * cos(rad) + center.y;
	return res;
}

void calc(Point gaze_start, Point gaze_end, int fov_degree) {
	
	float rad = M_PI * fov_degree / 360;
	Point fov_p1 = get_rotation(gaze_end, gaze_start, rad);
	Point fov_p2 = get_rotation(gaze_end, gaze_start, -rad);
	printf("fov_p1: %.2f %.2f\n", fov_p1.x, fov_p1.y);
	printf("fov_p2: %.2f %.2f\n", fov_p2.x, fov_p2.y);
}

int main(void) {
	Point gaze_start = {669,82};
	Point gaze_end = {289,644};
	calc(gaze_start, gaze_end, 45);
	return 0;
}
