This repository has been archived on 2026-05-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
prog-103-p-04-2030/HolidayTrip/Fundamentals/radar/radar.c
T
2026-02-15 19:53:55 +01:00

32 lines
776 B
C

#include "radar.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double compute_distance(struct point a, struct point b){
return sqrt( pow((b.x - a.x),2) + pow((b.y - a.y),2) );
}
int is_in_area(struct point center, double radius, struct point point){
int rslt = compute_distance(center, point);
if(rslt > radius) return 0;
return 1;
}
size_t detect_points(struct point center, double range, struct point *interesting_points, size_t nb_points){
size_t found = 0;
for(size_t i = 0; i < nb_points; i++){
if(is_in_area(center, range,interesting_points[i]) == 1){
printf("{%f, %f}\n",interesting_points[i].x, interesting_points[i].y);
found ++;
}
}
return found;
}