Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to draw a circle from 3 points using C++ language

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 26-06-2011
Member
 
Join Date: Mar 2011
Posts: 83
How to draw a circle from 3 points using C++ language
  

I need some help for drawing a circle from 3 triangle points in C++ programming language.

Reply With Quote
  #2  
Old 26-06-2011
Member
 
Join Date: Apr 2009
Posts: 483
Re: How to draw a circle from 3 points using C++ 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.
Reply With Quote
  #3  
Old 26-06-2011
Member
 
Join Date: May 2009
Posts: 523
Re: How to draw a circle from 3 points using C++ language

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.
Reply With Quote
  #4  
Old 26-06-2011
Member
 
Join Date: Apr 2009
Posts: 567
Re: How to draw a circle from 3 points using C++ language

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.
Reply With Quote
  #5  
Old 26-06-2011
Member
 
Join Date: May 2009
Posts: 523
Re: How to draw a circle from 3 points using C++ language

I also faced this problem and then I develop the following code for draw the circle.
Quote:
/////*********** 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);
}
Try this code and it will give you correct result on the C++ language.
Reply With Quote
  #6  
Old 27-06-2011
Member
 
Join Date: May 2009
Posts: 503
Re: How to draw a circle from 3 points using C++ language

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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to draw a circle from 3 points using C++ language"
Thread Thread Starter Forum Replies Last Post
How to change “Microsoft office 2011 for Mac” language as I bought the wrong language package Naq Windows Software 8 19-04-2012 08:12 PM
Want help to draw a circle in a graph via point data and axis in Excel DEvOTeEL MS Office Support 1 25-02-2012 10:31 AM
How to draw a circle in Excel 2007 Daksha90 Windows Software 5 13-06-2011 08:20 AM
Vista ultimate Language Pack for Greek language ph_oratis Windows Update 3 29-11-2009 02:15 PM
How to draw a circle using TI 89 Bilal Windows Software 3 20-06-2009 11:55 AM


All times are GMT +5.5. The time now is 05:48 PM.