Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 907
  • Last Modified:

drawing an arc from 3 points

Hi,
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
thanks

faraz
0
_faraz
Asked:
_faraz
1 Solution
 
Kent OlsenData Warehouse Architect / DBACommented:

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.



Kdo
0
 
tuBrodyCommented:
see if this helps:

http://www.jch.com/NURBS/
0
 
purplecabbageCommented:
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
);

J.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
evidence0001Commented:
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
0
 
Kent OlsenData Warehouse Architect / DBACommented:
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.


Kdo
0
 
DarthNemesisCommented:
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 )
0
 
_farazAuthor Commented:
thanks,
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)

faraz
0
 
DarthNemesisCommented:
Just noticed, the first b in the h= equation should be an a.
0

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now