Skip to content

Instantly share code, notes, and snippets.

@Foadsf
Created April 6, 2019 21:25
Show Gist options
  • Select an option

  • Save Foadsf/4783a647f5a55a2be7671a6b3110941d to your computer and use it in GitHub Desktop.

Select an option

Save Foadsf/4783a647f5a55a2be7671a6b3110941d to your computer and use it in GitHub Desktop.
find circle from to points and radius
#include <stdio.h> // NULL,
#include <math.h>
typedef struct Point {
float x;
float y;
} point;
typedef struct Circle {
point c;
float r;
} circle;
typedef struct Circles {
circle* C;
unsigned int n;
} circles;
// typedef enum Cases {A, B, C} cases;
int signnum(double x) {
if (x > 0.0) return 1;
if (x < 0.0) return -1;
return 0;
}
// Cases detect(Point p1, Point p2, float r) {
// int tmpSign = signnum(4 * pow(r, 2) - pow((p1.x - p2.x), 2) - pow((p1.y - p2.y), 2));
// switch(tmpSign) {
// case -1 :
// return A;
// break;
// case 0 :
// return B;
// break;
// case 1 :
// return C;
// }
// }
Circles findCircle(Point p1, Point p2, float r) {
int tmpSign = signnum(4 * pow(r, 2) - pow((p1.x - p2.x), 2) - pow((p1.y - p2.y), 2));
circles tmpCircles;
switch(tmpSign) {
case -1 :
tmpCircles.n = 0;
tmpCircles.C = NULL;
break;
case 0 :
tmpCircles.n = 1;
circle tmpCircle = {};
break;
case 1 :
break;
}
return tmpCircles;
}
int main() {
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment