Thread: in calculating the tool path
I am writing a simple hole generator in Processing because I can run it on the Mac and there is very little CAM on the Mac. So I have this generator that will generate G code snippets. However when it comes to the D shaped hole I ave hit a snag. The yellow is the hole I want to draw and the orange is the tool path. The two orange circles represent the limit of the tool path before going horizontal. The question is how do I calculate the position of these holes, given the diameter of the hole can change as can the tool diameter and the depth of the D shape. My maths isn't up to is could someone help please.
Last edited by irving2008; 26-07-2010 at 09:54 PM.
Just seen your post, but got to go. Sorry it's Wikipedia, but this might be a starter:
Also, the corners will have a radius, not be sharp as per the yellow outline. Sure you knew that . . .
Thanks but that doesn't solve the problem. I know all that maths in the link, that's how I drew the figure I posted in the first place. The problem is when it comes to creating the path at the corners. The tool (circle) has to be tangential to both the curve of the hole and the straight line. Yes the sharpness of the corners will depend on the tool size.
Assuming you have the circle radius and the distance from the circle centre to the line centre you can do it with pythagorus.
X = square root (r squared - centre to centre squared).
Your x coordinates for the line ends are then circle centre x + X, and circle centre x - X
Or have I misunderstood?
Thanks but yes you have misunderstood. It is the center of the tools position I am after when it is at the end of the straight bit. It is where the tool path for the straight bit crosses the tool path for the circular bit. Or put it another way it is the difference in the angle between the center and the bit where the straight joins the curve (which I know as that was part of defining the shape) and the angle between the tool center and the center of the hole. These angles are not the same as I first thought.
make the centre of the circle 0,0
call the tool radius t, the radius of the actual hole R and the location of the chord is y = -d
the coordinate of the holes are x = +/- (R-t)sin(arccos((d-t)/(R-t))), y = -d+t
How are you programming this, there may be an easier way
Well you just subtract the tool radius from the arc radius and add the tool radius to the line y co-ordinates before you do the pythagorus bit.
I've just been writing code to do much the same thing, decided pythagorus was a lot easier than applying the cosine rule even if it meant rotating the chord into the vertical and then back again :whistling:
Just to make it interesting I also spiral down into draft angles and hemispherical sections which is taxing my brain a bit but I'm getting there. Slowly. The G-Code is a bit whacky, I define the arc centre using I and J but the end co-ordinates are not necessarily on the same radius as the start. Dubiously G-code legal. I had to mod my mill driving code a bit before it would accept a spiral
Thanks irving, I worked out what I needed this morning on the drive in to work and I agree with you. I just got the sin and cos swapped over but that don't matter it just rotates it through 90 degrees.
It's good to have confirmation before I try and code it. I am using the free language called Processing, it runs on all platforms.
Do you think there would be any interest if I posted the final result? I am also working on a program to send a G code file to the miller. I wanted to use Replicator G but I can't get that to work reliably on my Mac, despite several email exchanges with the authors.
The above posts sound alot quicker than my solution which was:
Take the equation for a circle (x^2 + y^2 = r^2)
Take the equation for a straight line (y = mx + c)
these 2 lines are coincident when the x from the circle = x from the line, and y from the circle = y from the line, therefore substitute one equation into the other to create a quadratic equation (x^2 + mx + [c-r^2] = 0. Solve this using the quadratic formula to give x. Substitute back into either of the above to give y. This gives the 2 sets of coordinates of where the circle and line intersect.
This is a bit more generic than the solutions above, so should work for other related shapes, but is more complex!
By Jonathan in forum Gantry/Router Machines & BuildingReplies: 11Last Post: 10-12-2015, 10:32 AM
By Nemo1966 in forum Computer HardwareReplies: 5Last Post: 07-10-2013, 03:25 PM
By antsals in forum General DiscussionReplies: 2Last Post: 11-07-2011, 11:18 AM
By swarf-boy in forum Machine DiscussionReplies: 2Last Post: 21-12-2010, 11:18 PM
By Jonathan in forum Rails, Guideways & BearingsReplies: 7Last Post: 24-11-2010, 01:26 AM