math problem distance along an arc

Mar 12, 2009 14 Replies

I need help with math and geometry theory. I need to know how to calculate the distance along an arc given the start point, end point, and arc center. (A full circle is 2*pi*r) I also need to find the point on an arc that is X distance away.



So far, I have a messy solution involving sines and cosines with IF statements for which quadrant. There must be an elegant solution.



Background on what I'm doing: I'm writing a custom Gcode for my CNC control to read the Z distance on a laser displacement sensor every given increment along the arc.


When you say "start point and end point" do you mean the length of the chord? Do you know the angle?

Start point is an X, Y coordinate End point is a second X, Y coordinate Arc center is a third X, Y coordinate.

You can find the angle to a point on the arc by Arcsine(deltaX/radius). radius is the distance between either start point or end point and arc center.

Karl

This was my basic approach. But the sine function gives the angle within a given quadrant. Then, i had to test each angle for which quadrant to know how many 90 degrees to add. The result is a total mess. I'm hoping for a more elegant approach.

Karl

s=r*angle in radians YOu have the x,y of each point. Assume the lowest pt in y is at 0 degrees (to the right of the center) The angle can be deduced from : Dy (height, or y distance) = r * sin(angle), so angle = 1/arcsin (Dy) -You'll need trig tables or a sci. calculator.

Distance along arc, then, is r*angle (degrees/57.3) Now, distance along the arc is not the same as distance away. Dx^2 + Dy^2 = h^2, where h is the distance away. So, square up the increment in x, same in y, add 'em together then take the sqrt of that number. And it's not 7am here yet, so I could be all screwed up / mark

I cannot see how this is hard, as written.

You know the radius - it's distance between one end and the centre. You want to know what angle from that line will give you X along the arc, right? That's X over 2*pi*radius in radians - do the math and convert to degrees.

The above from memory of grade-school trig some decades ago; contents may have settled/become dis-ordered.

Hello,

Try???:

If current x & y is at 12 oclock on your circle,

h=3Dr-(sqrt(4r**-c**))/2

r is radius h is your new y pos move c/2 is your new x pos move

plus or minus depending on direction G2 or G3

HTH PaulS

Don't know if this is what you're looking for, but it worked for me. My situation is that I had to calculate the actual distance of curbing along both sides of a 2,000 long street. The distance is going to be different along the outside of the street and the inside of the street. Both distances were going to be different than a straight line from start to end of street. It didn't mean a lot of difference mathematically, but my boss was impressed that I figured out how to calculate it so accurately. (Google was not mentioned, just that I worked hard at achieving the results.)

BTW, sagitta is a word that comes in there somewhere.

Play with it and see. It allows you to enter variables that spits out the unknown.

formatting link
HTH

Steve

Arc length when you know the chord length and the radius:

Chord Length = SQRT( (X0-X1)^2 + (Y0-Y1)^2 )

Angle in Radians = 2 * ARCSIN( (Chord Length) / (2 * Arc Radius) )

Arc Length = Arc Radius * Angle in Radians

This is harder than anyone thinks because the system may be rotated.

It will work to "change coordinates" (*) to put the arc center at (0,0), and the start point at some (x,0). Then the coordinates of the end point will be at a known angle by an inverse trig function of the second point's coordinates. Divide the angle by 2pi radians to get the fraction of the circumference of the given radius.

You can also calculate the angle directly with vector arithmetic.

The book _Graphics Gems_ is a cookbook for this stuff:

formatting link
(*) Change coordinates = that stuff you never learned in algebra class because short skirts were in style.

I'm glad somebody thought it wasn't that easy. I got a good solution by brute force, but don't know the theory behind it. I made 12 equal spaced radii at 30 degree intervals around the circle. For each point, I recorded the sine ratio, sin result from the computer, cosine ratio, cosine result from the computer. (Tan gives divide by 0 errors)

By inspection I can see: IF delta Y (point-arc center) >=0 then cos(deltaX/radius) gives the result

IF delta Y

I don't know what programming language you're using but look for a two argument arctangent function in the list of available math functions.

In C, it's atan2(y,x).

These functions will return the proper angle/quadrant, regardless of the signs of the arguments, x and y. Some examples...

atan2(1,0) = 90 degrees atan2(0,-1) = 180 atan2(-1,0) = 270 atan2(-1,-1) = 225

...

Shoot, I knew there was an easy way. My control language doesn't have this function. It has the ability to call a small C function that you write. Now that I'm nearly done, it would be more work to do this.

Thanks for the tip.

Karl

There is a wiki page for that too:

formatting link
May give you some info to muse over...

"Karl Townsend" wrote in news:49b90b33$0$35421$ snipped-for-privacy@auth.newsreader.octanews.com:

formatting link
Ken

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required