finding equidistant point in triangle with vertices a, b and c. language is c -


i know steps calculate circumcentre of triangle couldn't understand how implement in program. please help. vertices a(2, 4) b(10, 15) c(5, 8) program step 1. finding midpoint a, bc, ca. (x1+x2)/2 (y1+y2)/2 step 2. finding slopes ab, bc, ca m=(y1-y2)/(x2-x1) step 3. finding perpendicular bisectors slope -1/m step 4. finding equations. using midpoint , perpendicular bisectors slope (y-y1)=m(x-x1). step 5. solving , finding x , y.

#include <stdio.h> #include <math.h>  typedef struct point {     double x, y; } point;  #if 0 ax + = c ax + = c  x = (c - by)/a = (c - by)/a ac - aby = ac - aby (ab - ab)y = ac - ac y = (ac - ac) / (ab - ab) x = (bc - bc) / (ab - ab) #endif  point ans(double a, double b, double c, double a, double b, double c){     point ret = {fp_nan, fp_nan};     double d = a*b -a*b;     if(d == 0)         return ret;     ret.x = (b*c - b*c) / d;     ret.y = (a*c - a*c) / d;     return ret; }  #if 0 (x-ox)^2+(y-oy)^2=r^2  (xa-ox)^2+(ya-oy)^2=(xb-ox)^2+(yb-oy)^2 (xa-ox)^2+(ya-oy)^2=(xc-ox)^2+(yc-oy)^2  2(xb-xa)ox + 2(yb-ya)oy + xa^2-xb^2+ya^2-yb^2 = 0 2(xc-xa)ox + 2(yc-ya)oy + xa^2-xc^2+ya^2-yc^2 = 0 #endif  point center(point a, point b, point c){     return ans(2*(b.x-a.x), 2*(b.y-a.y), b.y*b.y - a.y*a.y + b.x*b.x - a.x*a.x,                2*(c.x-a.x), 2*(c.y-a.y), c.y*c.y - a.y*a.y + c.x*c.x - a.x*a.x); }  int main(void){     point = { 2, 4}, b = {10, 15}, c = {5, 8};     point o = center(a, b, c);     printf("(%f, %f)\n", o.x, o.y);     return 0; } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -