Formula for.G02 G03 arc centre (x,y)
11 Sep 2018 08:06 #117321
by berntd
Formula for.G02 G03 arc centre (x,y) was created by berntd
I am getting rusty with the math...
So:
Can someone please give me the formulas for the x and y for a circle
based on the start x,y end x,y and radius?
I know I need to solve 2 simultaneous equations to get the answer but they are quadratic and I just can't do that anymore
So:
Can someone please give me the formulas for the x and y for a circle
based on the start x,y end x,y and radius?
I know I need to solve 2 simultaneous equations to get the answer but they are quadratic and I just can't do that anymore
Please Log in or Create an account to join the conversation.
11 Sep 2018 21:46 #117364
by berntd
Replied by berntd on topic Formula for.G02 G03 arc centre (x,y)
Hmm, thanks but it seems that calculates the arc length not the centre point coordinates.
Please Log in or Create an account to join the conversation.
12 Sep 2018 14:19 #117400
by andypugh
Replied by andypugh on topic Formula for.G02 G03 arc centre (x,y)
The equation of a circle centred on the origin is
x^2 + y^2 = r^2
For a circle not centred on the origin:
(x -a)^2 + (y - b)^2 = r^2
where (a,b) is the centre point.
We have two simultaneous equations
(Sx-Cx)^2 + (Sy-Cy)^2 = r^2
(Ex-Cx)^2 + (Ey-Cy)^2 = r^2
And by cheating, and putting this into Matlab, I got the surprisingly complicated:
Cx = (Ex^2 + Ey^2 - Sx^2 - Sy^2 - (Ey*(Ex^2*Ey + Ey*Sx^2 + Ex^2*Sy - Ey*Sy^2 - Ey^2*Sy + Sx^2*Sy + Ex*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) - Sx*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) + Ey^3 + Sy^3 - 2*Ex*Ey*Sx - 2*Ex*Sx*Sy))/(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx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ey*Sx - 2*Ex*Sx*Sy)/(2*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2))
For the other.
I checked numerically against a CAD drawing, the answers were correct.
Trigonometry based on the observation that the centre points lie on the perpendicular bisector of the line joining start to end points might give a simpler solution.
x^2 + y^2 = r^2
For a circle not centred on the origin:
(x -a)^2 + (y - b)^2 = r^2
where (a,b) is the centre point.
We have two simultaneous equations
(Sx-Cx)^2 + (Sy-Cy)^2 = r^2
(Ex-Cx)^2 + (Ey-Cy)^2 = r^2
And by cheating, and putting this into Matlab, I got the surprisingly complicated:
Cx = (Ex^2 + Ey^2 - Sx^2 - Sy^2 - (Ey*(Ex^2*Ey + Ey*Sx^2 + Ex^2*Sy - Ey*Sy^2 - Ey^2*Sy + Sx^2*Sy + Ex*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) - Sx*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) + Ey^3 + Sy^3 - 2*Ex*Ey*Sx - 2*Ex*Sx*Sy))/(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2) + (Sy*(Ex^2*Ey + Ey*Sx^2 + Ex^2*Sy - Ey*Sy^2 - Ey^2*Sy + Sx^2*Sy + Ex*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) - Sx*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^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ey + Ey*Sx^2 + Ex^2*Sy - Ey*Sy^2 - Ey^2*Sy + Sx^2*Sy - Ex*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) + Sx*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) + Ey^3 + Sy^3 - 2*Ex*Ey*Sx - 2*Ex*Sx*Sy))/(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2))/(2*Ex - 2*Sx)
Cy = (Ex^2*Ey + Ey*Sx^2 + Ex^2*Sy - Ey*Sy^2 - Ey^2*Sy + Sx^2*Sy - Ex*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) + Sx*(-(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2)*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2 - 4*r^2))^(1/2) + Ey^3 + Sy^3 - 2*Ex*Ey*Sx - 2*Ex*Sx*Sy)/(2*(Ex^2 - 2*Ex*Sx + Ey^2 - 2*Ey*Sy + Sx^2 + Sy^2))
For the other.
I checked numerically against a CAD drawing, the answers were correct.
Trigonometry based on the observation that the centre points lie on the perpendicular bisector of the line joining start to end points might give a simpler solution.
Please Log in or Create an account to join the conversation.
12 Sep 2018 19:17 #117421
by Grotius
Replied by Grotius on topic Formula for.G02 G03 arc centre (x,y)
Can Bertd make a simple drawing of his 2 simultaneous equations ? Then we can put it into Matlab and see what happens.
Please Log in or Create an account to join the conversation.
12 Sep 2018 19:32 #117424
by andypugh
The two simultaneous equations are in my post. Solve for Cx and Cy for known Sx, Sy, Ex, Ey and r.
Replied by andypugh on topic Formula for.G02 G03 arc centre (x,y)
Can Bertd make a simple drawing of his 2 simultaneous equations ? Then we can put it into Matlab and see what happens.
The two simultaneous equations are in my post. Solve for Cx and Cy for known Sx, Sy, Ex, Ey and r.
Please Log in or Create an account to join the conversation.
12 Sep 2018 21:38 - 12 Sep 2018 21:42 #117432
by berntd
Replied by berntd on topic Formula for.G02 G03 arc centre (x,y)
Haha
Yes, that is pretty good.
Bernt = me, has pages full of scribbles trying to solve exactly those 2 equations as above. That is why I had to give up as I just could (no longer) solve them.
You would never believe that Idid 5th year mathematics at University.
In those days, there was no Matlab.
But we digress...
There are 2 possible answers as 2 circles can go through the same 2 points with a give radius (also obvious from the quadratic equations).
I have since changed tack.
I am evaluating whether using the 2 circles and triangles formed by the centre to centre line and the intersecting 2 point line may help solve this problem.
I have not concluded that investigation yet.
I think you mentioned that method as well in your reply.
Lots of tutorial videos all show how simple writing G-code is but none of them show any examples of arcs that are not nicely 90 degrees. HA!
Regards
Bernt
Yes, that is pretty good.
Bernt = me, has pages full of scribbles trying to solve exactly those 2 equations as above. That is why I had to give up as I just could (no longer) solve them.
You would never believe that Idid 5th year mathematics at University.
In those days, there was no Matlab.
But we digress...
There are 2 possible answers as 2 circles can go through the same 2 points with a give radius (also obvious from the quadratic equations).
I have since changed tack.
I am evaluating whether using the 2 circles and triangles formed by the centre to centre line and the intersecting 2 point line may help solve this problem.
I have not concluded that investigation yet.
I think you mentioned that method as well in your reply.
Lots of tutorial videos all show how simple writing G-code is but none of them show any examples of arcs that are not nicely 90 degrees. HA!
Regards
Bernt
Last edit: 12 Sep 2018 21:42 by berntd.
Please Log in or Create an account to join the conversation.
14 Sep 2018 12:29 #117520
by andypugh
Replied by andypugh on topic Formula for.G02 G03 arc centre (x,y)
Out of interest, why do you need this?
If you know the centre already you can use centre-format arcs. If you know the start and end and radius required you can use radius format arcs.
If you know the centre already you can use centre-format arcs. If you know the start and end and radius required you can use radius format arcs.
Please Log in or Create an account to join the conversation.
Time to create page: 0.198 seconds