Results 1 to 6 of 6

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

  1. #1
    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.

  2. #2
    Join Date
    Apr 2009
    Posts
    491

    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.

  3. #3
    Join Date
    May 2009
    Posts
    527

    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.

  4. #4
    Join Date
    Apr 2009
    Posts
    570

    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.

  5. #5
    Join Date
    May 2009
    Posts
    529

    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.
    /////*********** 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.

  6. #6
    Join Date
    May 2009
    Posts
    513

    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.

Similar Threads

  1. Replies: 8
    Last Post: 19-04-2012, 08:12 PM
  2. Replies: 1
    Last Post: 25-02-2012, 10:31 AM
  3. How to draw a circle in Excel 2007
    By Daksha90 in forum Windows Software
    Replies: 5
    Last Post: 13-06-2011, 08:20 AM
  4. Vista ultimate Language Pack for Greek language
    By ph_oratis in forum Windows Update
    Replies: 3
    Last Post: 29-11-2009, 02:15 PM
  5. How to draw a circle using TI 89
    By Bilal in forum Windows Software
    Replies: 3
    Last Post: 20-06-2009, 11:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •