585,949 active members*
3,999 visitors online*
Register for free
Login
Results 1 to 16 of 16
  1. #1
    Join Date
    Mar 2007
    Posts
    534

    Finding the centre of an arc

    Don't know if anyone can help with this one, but working to the notion that the only dumb question is the one that is never asked...

    I'm writing a G code interpreter for an 8 bit micro. I have an algorythm that will give me next step on an arc but it needs the centre point and R².

    Easy if the arc is defined with I and J because that defines the centre and R² = I² + J²

    Unfortunately I and J are not guaranteed, I may only get a radius, the direction of rotation and a promise that the arc is not greater than 180 degrees.

    Is there an easy way to find the centre if that is all you've got to work with? So far I have got away without sines, cosines, tangents, roots and binary fractions.

    I could use a pre-processor on the host computer and replace R with I and J but that is an added complication. I could simply throw an Error and demand I and J, but is it fair to assume g-gode generating software can be switched?

    Also, I'm working in signed 24 bit numbers and my maximum useable distance is 34 feet. Plenty for x, y and z co-ordinates, but is it fair to throw a 'number too big' error if the arc radius exceeds 34 feet? There has to be a limit somewhere.

  2. #2
    Join Date
    Oct 2003
    Posts
    263
    Software For Metalworking
    http://closetolerancesoftware.com

  3. #3
    Join Date
    Mar 2008
    Posts
    25
    not sure what you're asking here. if you know the i,j values you can easily determine the radius as the i & j are are your adjacent & tangent values. therefore the hypotenus is your 'R' value. if you know the start point of the arc, simply add or subtract you i, j values to find the centre.
    hope this clarifies.

  4. #4
    Join Date
    Mar 2003
    Posts
    35538
    I think he wants the center of a G2/G3 arc using R and not I and J.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  5. #5
    Join Date
    Mar 2007
    Posts
    534
    The problem is when there are no I and J values, example

    N35 G03 X180.000 Y123.000 R1.500 F72.000

    Very easy to draw. You simply set your compass to R and then draw intersecting arcs centred on the start and end points.

    I can't believe it is a difficult, the early g-code interpreters were kinda basic, (unless the R only option came later). I think I may be missing a trick which is making something simple, complicated

  6. #6
    Join Date
    Mar 2003
    Posts
    35538
    Don't know the math off hand, but if you draw two circles with the R radius and their centers at the start and end points of the arc, they'll intersect at the center. Basic geometry.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  7. #7
    Join Date
    Mar 2003
    Posts
    35538
    Quote Originally Posted by ger21 View Post
    Don't know the math off hand, but if you draw two circles with the R radius and their centers at the start and end points of the arc, they'll intersect at the center. Basic geometry.

    http://local.wasp.uwa.edu.au/~pbourke/geometry/2circle/

    http://mathworld.wolfram.com/Circle-...ersection.html
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  8. #8
    Join Date
    Mar 2005
    Posts
    1498
    080322-1014 EST USA

    Robin:

    From your first post there is insufficient information to define the arc center.

    I will assume you know the starting point of the arc, and you said the radius was known. Thus, the center of the arc is some place on the locus of a point at a distance of R from the start point.

    In your second post you imply knowledge of the end point.

    From a knowledge of the start and end points you can create a straight line, AB, between the two points. A line drawn perpendicular to the line AB and thru its midpoint contains the arc's center. You can determine the equation for this line, the length of AB, and the length of the line from AB center to the arc center.

    The length of AB is ( (X1-X2)^2 + (Y1-Y2)^2 )^(1/2), and the center point of AB is at X2 + (X1-X2)/2 = Xcp and Y2 + (Y1-Y2)/2 = Ycp .

    Let the perpendicular line be CD, then the length of CD is ( (R)^2 - (AB/2)^2 )^(1/2).

    Whether you use this technique or trig functions your processor must be able to perform the operations.

    .

  9. #9
    Join Date
    Mar 2007
    Posts
    534
    Tried that, the line CD is a vector so it only solves it if CD happens to be horizontal or perpendicular

  10. #10
    Join Date
    Jun 2003
    Posts
    205

    Finding Arc Centers from R

    We have written a few applications that do this ... our Trig Kalculator is one.

    I believe you are trying to do this from a G code program. I hope I got that right ... if so, you need to know the START POINT and the END POINT ... you should know the start point from the last coordinate point in the G code program ... using that start point and the end point ( called out in the G2/G3 line) and other sine, cosine functions, you can find the arc center. But it takes a couple of calculations to get there.

    Real World Machine Shop Software at www.KentechInc.com

  11. #11
    Join Date
    Mar 2005
    Posts
    1498
    Robin:

    I do not understand your comment. The Pythagorean theorem does not require a relationship to a coordinate system.

    From the
    The American Heritage® Dictionary of the English Language, Fourth Edition

    "The theorem that the sum of the squares of the lengths of the sides of a right triangle is equal to the square of the length of the hypotenuse."

    Line CD and 1/2 of AB as I proposed forms a right triangle.

    What I suggested was a way to find the center of the arc from a geometric construction knowing the arc's end points. This involved straight lines and right triangles. and calculatable values.

    .

  12. #12
    Join Date
    Mar 2007
    Posts
    534
    That's how I did it when I had the benefit of a C compiler, it is a vector.

    But now I'm re-writing it in machine code. Everything is lightning fast and extremely compact. I want to keep it that way and I'm going to try and solve this for a while longer before I give up


    sep = hypot(x-xx,y-yy); // separation start to end in XY
    ang = getangle(xx,yy,x,y); // angle of line start to end
    vect = racos((sep/2)/r); // vector to center
    if(dir==CW) vect = ang-vect; // CW = turn left
    else vect = ang+vect; // CCW = turn right
    while(vect>=r360) vect-=r360;
    while(vect<0.0) vect+=r360;
    cx=xx+(cos(vect)*r); // locate arc center
    cy=yy+(sin(vect)*r);

  13. #13
    Join Date
    Mar 2005
    Posts
    1498
    080323-0735 EST USA

    Robin:

    Rereading your first post I am not sure what is your problem.

    You seem to exclude trig functions and roots. These are hard to do in a small processor. Do you also exclude squaring a value?

    I believe you are asking how to find the center of an arc given two different points on the arc and the arc radius without trig functions and roots. Is this correct?

    If so, then you can determine the slope of the straight line passing thru the arc center (edit) and the midpoint of the line between the two points on the arc(end edit). Knowing this I believe you can solve the circle equation at both end points of the arc and find the values for Xc and Yc. This should not require roots. The slope gives you the ratio of Yc to Xc.

    .

    .

  14. #14
    Join Date
    Mar 2003
    Posts
    765
    Hi Robin,

    A while back I posted a VB module that contains a bunch of geometry related functions including one that will calculate the center of an arc from start point, end point and radius. Here's a link to the thread:

    http://www.cnczone.com/forums/showthread.php?t=12783

    Scott

  15. #15
    Join Date
    Dec 2004
    Posts
    524
    First find the point midway between the two points at the ends of the arc.
    X = (x1+x2)/2, Y = (y1+y2)/2.

    Now find the point on the perpendicular bisector of this line at a distance equal to half the distance between the two points. Check if the distance from this point to the end points is more or less than the target radius. If less, step out by this distance again. Keep stepping out as necessary until you have two points; one where the radius is greater than the target, the other where the radius is less than the target. (Don't actually compute the radius; compute the square of the radius and compare those.)

    Now find the point midway between the two points that you have. Its distance will be either less than or greater than the radius. Replace one of the other points with this point and continue the process of successive halving of the distance until you are close enough. Since you have 24 bits of precision, it is clear that you will need fewer than that number of iterations.

    Around three decades ago, I was involved in writing a floating point package for an Intel 8080 processor. You might consider using such a package for parts of your application.

    Ken
    Kenneth Lerman
    55 Main Street
    Newtown, CT 06470

  16. #16
    Join Date
    Mar 2006
    Posts
    61

    Basic prog for circle passing 2 points

    Point 1 x coord = A
    POINT 1 Y COORD = B
    POINT 2 X COORD = D
    POINT 2 Y COORD = E
    CIRCLE RADIUS = F
    WHEN THE CIRCLE IS LEFT OF THE LINE FROM POINT P1 TO POINT P2 G=-1

    C=F
    H=D-A
    I=E-B
    J=v(H * H + I * I)
    K=ACS(H/J)
    IF 0>I THEN K = -K
    ACS((C*C+J*J-F*F)/2/C/J)
    M=A+C*COS(K+G*L)
    N=B+C*SIN(K+G*L)

    CIRCLE X COORD = M+ SGN M * .005

    CIRCLE Y COORD = N+ SGN N *.005

Similar Threads

  1. hub centre steering
    By spoiledbrat in forum Moldmaking
    Replies: 2
    Last Post: 09-07-2009, 11:30 AM
  2. Another Aussie Adventure in Optical Edge/Centre Finding
    By Greolt in forum Mach Software (ArtSoft software)
    Replies: 8
    Last Post: 04-01-2008, 09:48 PM
  3. Threading on a CNC turning centre
    By Leblondmakino in forum Fanuc
    Replies: 4
    Last Post: 10-24-2007, 07:32 PM
  4. Off centre turning
    By Integrex in forum MetalWork Discussion
    Replies: 0
    Last Post: 04-11-2007, 04:35 AM
  5. Kitamura My Centre 2c
    By scappini in forum Mechanical Calculations/Engineering Design
    Replies: 0
    Last Post: 07-11-2006, 01:34 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
  •