I need to get the x and y center Point for this project, however, I cannot seem to understand how to get it. I tried the following
1 2 3 4 5 6 7 8 9 10 11 12 13
//In the Struct, there are 3 x and y points stored in double x and double y.
double x1, x2, x3;
double y1, y2, y3;
Point x, y, centerX, centerY; //Point is a struct in a separate header
x.x= x1, x2, x3;
y.y = y1, y2, y3;
centerX.x = (x1+x2+x3)/3;//formula for center point x
centerY.y = (y1+y2+y3)/3;//for y
//this is where I am stuck I cant understand how to return the value
//return centerX, centerY does not work.
}
Since Point does already contain x/y you don't need it twice:
1 2 3 4 5 6
Point center; //Point is a struct in a separate header
...
center.x = (x1+x2+x3)/3;//formula for center point x
center.y = (y1+y2+y3)/3;//for y
return center;