Circle is:
(x-h)2 = (a-k)2 = r2where 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 + 2kBut plugging in r=4.5, x=0, h=4.5, k=4.5 (the left side of the workpiece) produces an obvious error.
OK, your formula for a circle is
ReplyDelete(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.
z = sqrt(r^2 -(x-h)^2) + k
ReplyDelete