I need some help for drawing a circle from 3 triangle points in C++ programming language.
I need some help for drawing a circle from 3 triangle points in C++ programming language.
In C++ language there are so many ways to do this task. You need to write a function that help to calculate parameter of the circle. As we know that this parameter is to be center and radius. Use three triangle points as a parameter of this function. You need to use the value of this parameter and then find out the value of the radius and the center. In that write a function to calculate screen coordinates. Then pass this value to the function coordinates of the circle. The screen coordinates help to do this task easily in c++ language. This is really help to find the radius and the center of the circle. Then use this parameter and then draw that circle.
Yes, this is the right way to do this task. Using the three triangle point you can able to find the correct mean distance of the center to this three point. You need to use the specific function for doing this task. Then just use the center and the radius of that resulted function. Here radius of this circle is an similar distance near to the three point. Then use this parameter and it really work to solve the problem. This will be good for you for doing such complicated task.
To draw a circle using the three triangle points, you need to first draw two lines between the three points. These two lines, is to be help to draw the circle using the C++ language. Then use the chord lines to draw two perpendicular bisectors between these two lines. The intersection point, will be help to find the center of the desired circle. Also use the radius which is distance between center and three points. This is help to draw the circle.
I also faced this problem and then I develop the following code for draw the circle.
Try this code and it will give you correct result on the C++ language./////*********** Draw Circle Using Three Points******************///
double px,py,qx,qy,rx,ry,p1,y11,pd1,yd1,p2,y2,pd2,yd2,ox,oy,dx,yd,radius; // Variables Used and to Declared
px =firx ; py = firy; //first Point X and Y
qx =serx; qy = sery; // Second Point X and Y
rx =thix ; ry =thiy; // Third Point X and Y
////****************Following are Basic Procedure**********************///
p1 = (qx + px) / 2;
y11 = (qy + py) / 2;
yd1 = qx - px;
pd1 = -(qy - py);
***********************
p2 = (rx + qx) / 2;
y2 = (ry + qy) / 2;
yd2 = rx - qx;
pd2 = -(ry - qy);
****************************
ox = (y11 * pd1 * pd2 + p2 * pd1 * yd2 - p1 * yd1 * pd2 - y2 * pd1 * pd2)/ (pd1 * yd2 - yd1 * pd2);
oy = (ox - p1) * yd1 / pd1 + y11;
***********************************
dx = ox - px;
yd = oy - py;
radius =(int)sqrt(dx * dx + yd * yd);
************************************
for( double t_Angle = 0; t_Angle <= 360; t_Angle += 0.01 )
{
i = ox +(radius+1)*cos( 3.14*t_Angle );
j = oy +(radius+1)*sin( 3.14*t_Angle );
imagearr1[i][j] = RGB( 255,0,0);
}
The code you provided is to be useful for doing the calculation in this C++ language. This code will help to find the radius and the center of the circle. After getting the radius and the circle you need to just use this value as a parameter. Then use the graphics method of the C++ language. This language will based on Object Oriented Programming and the help option of this language will be help to provide such method. Then press F1 in this language and then use the existing method of this language. This will be help to solve the existing problem and then you can able to draw the circle.
Bookmarks