Commit e8da5590 authored by xingqiao's avatar xingqiao
Browse files

Merge branch 'master' of gitlab.eecs.umich.edu:hsanghyu/p4robotics-templates

parents b4feaf28 9087171c
#include <stdio.h>
#include <stdbool.h>
#define M_PI 3.14159265358979323846
typedef struct polygon {
int n_points;
double xs[16];
double ys[16];
} polygon_t;
bool contains(polygon_t *pg, double x, double y) {
// point is contained if it is on the "inside" of the four lines
}
bool lines_intersect(double x0, double y0, double x1, double y1,
double x2, double y2, double x3, double y3) {
}
bool check_intersection(polygon_t *pg1, polygon_t *pg2) {
bool any_intersection = false;
return any_intersection;
}
bool check_collides(polygon_t *pg1, polygon_t *pg2) {
bool intersects = check_intersection(pg1, pg2);
bool contains1 = false;
for (int i = 0; i < pg2->n_points; i++) {
if (contains(pg1, pg2->xs[i], pg2->ys[i])) {
}
}
bool contains2 = false;
for (int i = 0; i < pg1->n_points; i++) {
if (contains(pg2, pg1->xs[i], pg1->ys[i])) {
}
}
return intersects || contains1 || contains2;
}
polygon_t parse_polygon(FILE *f) {
polygon_t pg = {0};
return pg;
}
int main(void) {
FILE *f = fopen("polygons.csv", "r");
char throwaway[256];
fgets(throwaway, sizeof(throwaway), f);
polygon_t pg1 = parse_polygon(f);
polygon_t pg2 = parse_polygon(f);
fclose(f);
if (check_collides(, )) {
printf("collision!\n");
} else {
printf("no collision\n");
}
return 0;
}
#include <stdio.h>
int main(int argc, char *argv[]) {
if (argc != 4) {
fprintf(stderr, "usage: %s <encrypt|decrypt> <password> <message>\n", argv[0]);
exit(1);
}
if (strcmp(, "encrypt") == ) {
} else if (strcmp(, "decrypt") == ) {
} else {
}
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment