- Posts: 41
- Thank you received: 0
Formula for.G02 G03 arc centre (x,y)
- berntd
- Offline
- Senior Member
-
Less
More
8 years 1 month ago #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.
- Grotius
- Offline
- Platinum Member
-
Less
More
- Posts: 2419
- Thank you received: 2349
8 years 1 month ago #117358
by Grotius
Replied by Grotius on topic Formula for.G02 G03 arc centre (x,y)
Please Log in or Create an account to join the conversation.
- berntd
- Offline
- Senior Member
-
Less
More
- Posts: 41
- Thank you received: 0
8 years 1 month ago #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.
- andypugh
- Offline
- Moderator
-
Less
More
- Posts: 19899
- Thank you received: 4655
8 years 1 month ago #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^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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.
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 - 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- 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.
- Grotius
- Offline
- Platinum Member
-
Less
More
- Posts: 2419
- Thank you received: 2349
8 years 1 month ago #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.
- andypugh
- Offline
- Moderator
-
Less
More
- Posts: 19899
- Thank you received: 4655
8 years 1 month ago #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)
Grotius wrote: 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.
Time to create page: 0.916 seconds