You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Questions regarding the algorithm of depth() implementation #445
Hi! Im very interested in the algorithm used in the depth method of conic and spheroid sweep, and Im trying to work on expanding shape support. I understand how the equation of epsilon * beta^2 + gamma * beta + rho = 0 works, but I cannot figure out how exactly are the value of epsilon, gamma and rho is determined. I assume this might be some well-established algorithm, so I wonder if there is any blog or paper or article that explains how this algorithm works? I tried to do some research on my own but I failed to find such resource. Or maybe you can point me at some keyword or direction regarding this topic? Thank you very much
It's a custom algorithm I developed in 2011. There is no public documentation on this algorithm that I know of. All I have is the code and some very old notes. It uses the Marching Cubes algorithm. Then, rather than compute the sweep of the tool shape directly, it computes if a given point is inside the sweep or not. Answering this question is easier than computing the exact sweep. The computations are very dependent on the shape. You could however describe pretty much any tool shape by combining various cones, cylinders and spheres. This is something I've not yet go around to implementing. The speed and accuracy of the algorithm could be improved and it could also be extended to handle 5-axis simulation.
Thank you so much for the response. No wonder I could not find anything about it. I am able to comprehend how the equation can anwser whether a point is just in contact with the surface of the tool at some location along the path and I think this is a very clever way to determine if the point needs to be removed. I am currently trying to implement a corner radius endmill by combining conical sweep along the path and spheroid sweep along two offseted paths. While shapes can be achieved by combining basic shapes, I believe if it comes to more complicated ones, it would be hard without a complete understanding of the algorithm. However, right now I am in the state that I know how the quadratic equation of is gonna get the results, but unaware of how the value of each coeffecient make sense (likely since I havent touched geometry in a couple years so I have no instinct for these values). For example, epsilon in spheroid sweep is distance squared of tool path, but in conical sweep the last item is - sqr(Tm * (Bz - Az)), and I cannot figure out why it is minus and why multiply by slope. If it would not be too much trouble for you, can you please provide a little more details about the mathmetical significance about the value of each coefficient? Thank you!
These equations come for more elaborate equations that exist somewhere buried in my notes. The equations in the code have been simplified using Wolfram Alpha. They have been split in to separate calculations so that we can test for divide by zero situations. Sorry I don't have a better explanation. It's been a long time since I worked on this.
I think I have it mostly figured out. Essentially we are trying to determine for a point P, whether there exist a point Q on toolpath AB such that horizontal distance between Q and P is smaller than or equal to radius of the tool at height h = Pz - Qz. We can omit the smaller than part, substitute values in and thus get an equation that would eventualy simplify to epsilon * beta^2 + gamma * beta + rho = 0. I am currently trying to extend the algorithm to other shapes
What other shapes are you interested in? Can you tell me what you are working on and if you will contribute your findings back to the project? Please take note of the Open-Source licensing requirements.
With respect to 3 axis CNC machining the only other really useful shape, in my opinion, is the toroid. You can combine cones, cylinders, spheres and toroids with offsets along the central axis to approximate any tool shape to arbitrary accuracy. The toroid is more difficult because it's a concave shape.
Note, that the equations in CAMotics take advantage of the fact that with 3 axis machining the tool is always oriented parallel to the z-axis. You could consider other orientations simply by rotating your frame of reference but if the tool orientation changes throughout the sweep or the sweep is not a straight line, you either need to estimate the path with short linear segments, at the cost of more computation, or develop more flexible equations.
Another very important part of the algorithm is the use of an oct-tree to reduce the number of sweep evaluations required for each point. In other words, we don't evaluate the sweep equation for P for all the moves in the program, just the moves that are close enough to the tool to possible collide with it.
I am trying to implement bullnose/radius corner mill, and then extend to other shape (like user_defined mill in siemens NX). It is for an internal project in my company, and essentially I am just trying to recreate and extend camotics's"cut" algorithm in our environment. If I do succeed, I think the addition would work for camotics as well. However, while I personally am willing to contribute to open source, I will need to consult with my boss to see if it would got me into any trouble.
Yes, a bullnose tool is a toroid on the end of a cylinder.
Note, that if you use this algorithm or source code in a closed-source project and also sell or make the the product available to another entity without contributing your contributions back to CAMotics then you will be in violation of our license. If you only use the code internally and not part of a machine or software that you distribute externally, then it's not a problem. Please explain this to your boss.
Yes but instead of implementing toroid (which has a hole that complicated the program), I am trying to make the calculation with the tool as a hole (so combined shape of cylinder and toroid)
Ture, I have currently expended the equation to a quartic equation, which does not really make sense since logically beta should only have no more than two solution. I am checking my math to see if I made a mistake somewhere
Activity
jcoffland commentedon Dec 4, 2025
It's a custom algorithm I developed in 2011. There is no public documentation on this algorithm that I know of. All I have is the code and some very old notes. It uses the Marching Cubes algorithm. Then, rather than compute the sweep of the tool shape directly, it computes if a given point is inside the sweep or not. Answering this question is easier than computing the exact sweep. The computations are very dependent on the shape. You could however describe pretty much any tool shape by combining various cones, cylinders and spheres. This is something I've not yet go around to implementing. The speed and accuracy of the algorithm could be improved and it could also be extended to handle 5-axis simulation.
kiraliu7 commentedon Dec 5, 2025
Thank you so much for the response. No wonder I could not find anything about it. I am able to comprehend how the equation can anwser whether a point is just in contact with the surface of the tool at some location along the path and I think this is a very clever way to determine if the point needs to be removed. I am currently trying to implement a corner radius endmill by combining conical sweep along the path and spheroid sweep along two offseted paths. While shapes can be achieved by combining basic shapes, I believe if it comes to more complicated ones, it would be hard without a complete understanding of the algorithm. However, right now I am in the state that I know how the quadratic equation of is gonna get the results, but unaware of how the value of each coeffecient make sense (likely since I havent touched geometry in a couple years so I have no instinct for these values). For example, epsilon in spheroid sweep is distance squared of tool path, but in conical sweep the last item is - sqr(Tm * (Bz - Az)), and I cannot figure out why it is minus and why multiply by slope. If it would not be too much trouble for you, can you please provide a little more details about the mathmetical significance about the value of each coefficient? Thank you!
jcoffland commentedon Dec 9, 2025
These equations come for more elaborate equations that exist somewhere buried in my notes. The equations in the code have been simplified using Wolfram Alpha. They have been split in to separate calculations so that we can test for divide by zero situations. Sorry I don't have a better explanation. It's been a long time since I worked on this.
kiraliu7 commentedon Dec 10, 2025
I think I have it mostly figured out. Essentially we are trying to determine for a point P, whether there exist a point Q on toolpath AB such that horizontal distance between Q and P is smaller than or equal to radius of the tool at height h = Pz - Qz. We can omit the smaller than part, substitute values in and thus get an equation that would eventualy simplify to epsilon * beta^2 + gamma * beta + rho = 0. I am currently trying to extend the algorithm to other shapes
jcoffland commentedon Dec 10, 2025
Yes. That sounds correct.
What other shapes are you interested in? Can you tell me what you are working on and if you will contribute your findings back to the project? Please take note of the Open-Source licensing requirements.
With respect to 3 axis CNC machining the only other really useful shape, in my opinion, is the toroid. You can combine cones, cylinders, spheres and toroids with offsets along the central axis to approximate any tool shape to arbitrary accuracy. The toroid is more difficult because it's a concave shape.
Note, that the equations in CAMotics take advantage of the fact that with 3 axis machining the tool is always oriented parallel to the z-axis. You could consider other orientations simply by rotating your frame of reference but if the tool orientation changes throughout the sweep or the sweep is not a straight line, you either need to estimate the path with short linear segments, at the cost of more computation, or develop more flexible equations.
Another very important part of the algorithm is the use of an oct-tree to reduce the number of sweep evaluations required for each point. In other words, we don't evaluate the sweep equation for P for all the moves in the program, just the moves that are close enough to the tool to possible collide with it.
kiraliu7 commentedon Dec 10, 2025
I am trying to implement bullnose/radius corner mill, and then extend to other shape (like user_defined mill in siemens NX). It is for an internal project in my company, and essentially I am just trying to recreate and extend camotics's"cut" algorithm in our environment. If I do succeed, I think the addition would work for camotics as well. However, while I personally am willing to contribute to open source, I will need to consult with my boss to see if it would got me into any trouble.
jcoffland commentedon Dec 10, 2025
Yes, a bullnose tool is a toroid on the end of a cylinder.
Note, that if you use this algorithm or source code in a closed-source project and also sell or make the the product available to another entity without contributing your contributions back to CAMotics then you will be in violation of our license. If you only use the code internally and not part of a machine or software that you distribute externally, then it's not a problem. Please explain this to your boss.
kiraliu7 commentedon Dec 10, 2025
Thank you for the notice.
Yes but instead of implementing toroid (which has a hole that complicated the program), I am trying to make the calculation with the tool as a hole (so combined shape of cylinder and toroid)
jcoffland commentedon Dec 10, 2025
But you still have a concave part which is just as difficult in my opinion.
kiraliu7 commentedon Dec 11, 2025
Ture, I have currently expended the equation to a quartic equation, which does not really make sense since logically beta should only have no more than two solution. I am checking my math to see if I made a mistake somewhere