Rectangular knowledge

Rectangular known three points to find another point

void getrce(int x1,int y1,int x2,int y2,int x3,int y3,int w)
{
    int k=w-1;
    int ab=idis(k-2,k-1),ac=idis(k-2,k),bc=idis(k-1,k);
    double x4,y4;
    if(ab+ac==bc)    x4=x2+x3-x1,y4=y2+y3-y1;
    if(ab+bc==ac)    x4=x3+x1-x2,y4=y3+y1-y2;
    if(bc+ac==ab)    x4=x1+x2-x3,y4=y1+y2-y3;
    k++;
    a[k].x=x4,a[k].y=y4,a[k].city=a[w-1].city;
}

The rectangle is known to find two other points at two diagonal points
\ (assuming one point is (a, b) and the other is (c, d), then one point is (c, b) and the other is (a, d )

Judging whether two points of the rectangle are inside the rectangle

double minx=min(a[j].x,a[j].x1),maxx=max(a[j].x,a[j].x1);
double miny=min(a[j].y,a[j].y1),maxy=max(a[j].y,a[j].y1);
if(q>minx&&q<maxx&&w>miny&&w<maxy)	return true;
return false;

Guess you like

Origin www.cnblogs.com/iss-ue/p/12737085.html