drawing an arc from 3 points

Posted on 2003-03-07
Medium Priority
Last Modified: 2007-12-19
I'm working on a cad type thing and i need to draw an arc in 2d from three points - i believe there is only one solution.

I really need a little code to help me out here, or at least fully solved eqs in terms of the 3 points, and anything in addition would be great (ie radius/sweep + centre etc)

I'm drawing in openGL / GDI - is there an easier way? not sure how to use gdi or gl to draw an arc from 3 points

Question by:_faraz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 46

Expert Comment

by:Kent Olsen
ID: 8091718

Well, I'm not sure of an API that will plot an arc given 3 points, but you could always write one.  :)

The math involved is pretty simple, mostly geometry, a little alegbra, maybe some trig.

Given the arc ABC, draw two length segments AB and BC.

Draw the perpendicular bisector at AB and BC.  Where they intersect is the center of the circle (arc), D.

Now you can draw the arc from AC with centerpoint D.

The centerpoint of AB is the point ((Ax+Bx)/2,(Ay+By)/2)
The centerpoint of BC is the point ((Bx+Cx)/2,(By+Cy)/2)

Compute the line through each of those points and calculate the intersection.


Expert Comment

ID: 8094640
see if this helps:


Expert Comment

ID: 8095081
In GDI you can use PolyBezier but it needs at least 4 points.

point 0 is the starting point
point 1 control point
point 2 control point
point 4 endpoint

You can use it to draw a complete system of points and it will use points 0-4 for the first line then points 1,2,3 for the next then 2,3,4 -- 3,4,5 for the whole line ...

BOOL PolyBezier(
  HDC hdc,            // handle to device context
  CONST POINT *lppt,  // pointer to endpoints and control points
  DWORD cPoints       // count of endpoints and control points

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 8095305
IF youre good with advanced Vector calculus then an extremely and most efficient solution would be:

someting that can be considered is using paths here. Calculate the radius of the cirlce or shape that the arc WOULD be part of and then parametrize that shape. Simply bound that parametrized shape by the two endpoints and you have a complete path function in terms of t ( ex: F(t) ) that will give you a point for every t that is plugged in. Much better than using interection, much more efficient.

Note: you might need to parametrize the path using two variables instead of just one depending on regularity of the shape. Also, you can create a vector Field from those two points and simply make a funciton known as the flowline which is the same as the path in R-space.

many vector calculus sites out there. Good luck
LVL 46

Expert Comment

by:Kent Olsen
ID: 8095324
Hi Evidence,

How do you propose calculating the radius of the arc without knowing the centerpoint?  I don't see how Calculus is going to get you there any easier or more efficiently.


Accepted Solution

DarthNemesis earned 525 total points
ID: 8133151
It's only a matter of some complicated substition to determine the center of a circle if you have 3 points on the circumference.

Given points (a,b), (c,d), and (e,f) the center (h,k) of the circle can be found at:
h = ((a*b+b*b)*(f-d) + (c*c+d*d)*(b-f) + (e*e+f*f)*(d-b)) / (2*(a*(f-d)+c*(b-f)+e*(d-b)));
k = ((a*a+b*b)*(e-c) + (c*c+d*d)*(a-e) + (e*e+f*f)*(c-a)) / (2*(b*(e-c)+d*(a-e)+f*(c-a)));
r = sqrt((a-h)*(a-h) + (b-k)*(b-k));

(Solutions taken from http://mcraefamily.com/MathHelp/GeometryConicSectionCircleEquationGivenThreePoints.htm )

Author Comment

ID: 8155389
was planning to implement this sometime last week, but found mayself recooking the architecture instead! h=, k=,r= gives me pretty much what i need to make this work - (unfortunately my vector calculus is a little lacking)


Expert Comment

ID: 8155664
Just noticed, the first b in the h= equation should be an a.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question