Sunday, June 23, 2019

Somehow I Received an A in Both 2nd Semester and 3rd Semester Algebra

It sure is not showing now!  Please identify where I went wrong.  I am trying to write gCode to excavate a half-circle in a block of aluminum.  (Really a half cylinder.)  I will advance x by 0.5" with each pass.  (It is a .5" diameter mill.)  What is the formula for z?

Circle is:
(x-h)2 = (a-k)2 = r2 
where r is radius, h,k is center of circle. Solve for z, since x is known. To simplify this I am calculating upward motion, which I will go -z for vertical position.
x2 - 2xh + k2 + z2 - 2zk +k2 = r2
-2xh +h2 + z2 -2zk +k2 = r2 - x2 
h2+ z2 - 2zk + h2 = r2 - x2 + 4xh + k2 
z2 - 2zx = r2 - x2 + 4xh + k2 
z = r2 _x2 + 4xh = k2 + 2k
But plugging in r=4.5, x=0, h=4.5, k=4.5 (the left side of the workpiece) produces an obvious error.

2 comments:

Karl said...

OK, your formula for a circle is
(x-h)² + (y-k)² = r²
This constrains your (x, y) pairs to be along a circle of radius r, since the further x gets from h, the closer y has to be to k.
In an x, y, z coordinate system, movement along the z axis is independent of what's happening with x and y. So you would excavate your circle (or your half circle, constraining either x or y to be non-negative), then lower your tool an increment of z before excavating again. And repeat until it's deep enough.

It might be easier if you can rewrite your code in polar coordinates.

Nils said...

z = sqrt(r^2 -(x-h)^2) + k