Drop-Cutter in C#

I've now ported my Matlab work on Drop-Cutter to C#. It can load an ASCII STL file and then run the drop cutter algorithm. Not trying to take too much on in the beginning, here's an example of the output with only two triangles as input 🙂 not quite there yet! (who can spot what's wrong?)

I'll do some nicer demos when I've found the problem. The algorithm runs significantly faster in C# compared to Matlab - and this is without a kd-tree or bucket strategy for finding triangles under the cutter. I've also watched and read some tutorials on threading (threading wrt. to computers, not machining!). This is an algorithm that should scale well on modern multi-core processors (have a few worker-threads running drop-cutter on different regions of the model).

An STL Tux

Together with another Anders (from Sweden) I've worked a little bit on some C# code for rendering stuff in OpenGL. The idea is to put together a basic framework where CAD/CAM ideas and algorithms can be tested. Above one of the first useful screenshots where I've rendered an STL file with about 22k triangles.

The code needs to be cleaned up and made all object-oriented and nice, but after that it should not be hard to test the Drop-Cutter algorithm and generate some raster-finish paths.

I've also been reading a 2004 paper by Yau et al. which explains the drop-cutter algorithm for an APT tool. I'm not very interested in the tapered cutters - but that can be added later if needed. What's more interesting in the paper is a kd-tree approach for finding out which triangles are under the 'shadow' of the cutter.

The idea is that it's not necessary to test against all triangles, only those that are under the cutter. Since the circular cutter and the triangles are differently shaped, Yau et al. start by approximating both cutter and triangles with rectangles. So they generate rectangular bounding boxes around each triangle and also around the cutter. The task then is for a given position of the cutter to find which bounding-boxes(triangles) intersect it. I understand this is a variant of what's called an orthogonal range search in computer science.

If anyone with a good understanding of kd-trees and/or range-searching is willing to help with a C# implementation I'd be glad to send over the Yau et al. pdf!

FIN-43 finally sailing!

After fitting the sheeting-bridge for the mainsheet and drilling some holes in the booms for the sheet-hooks I was finally able to test sail the new IOM I have been building! It's going to be numbered FIN-43, but I haven't had time for details like sail-numbers or measurement bands yet. You might also notice that I'm missing the bow-bumper. The paint-job is 'Scharmer-style' for the moment...

The main worry with a new boat, besides obvious things like the rudder and sheeting systems working,  is usually water tightness. I observed something like half a table-spoon of water after maybe 20min of sailing in varying no1 rig breeze. The lid probably needs sealing, and a coat or two of paint should seal any microscopic pin-holes left in the hull laminate.

Balance on the beat was surprisingly good, only minor adjustments of the mast position should be necessary to find a good trim. Now I need to put in a lot of practice hours against other boats and in varying conditions to iron out any minor problems and find a good basic trim with all rigs. In addition to the national ranking series we still have two Scandinavian events that should provide some good sailing before the Marseille Worlds in October...

Drop cutter might work!

Here's the first indication that my drop cutter algorithms(vertex, facet, edge) might work! I'm dropping down a toroidal cutter C(0.5, 0.125) towards a model consisting of a half-sphere sitting on a plane. The CL points are in magenta with cyan lines between them. 382 triangles in total. The code has no optimizations, so at each x,y position we check against all triangles.

Here's another one with about 1800 triangles, and with the points more densely sampled in the Y-direction. (click for slightly higher resolution version)

These still pictures are not nearly as convincing as a moving animation - so I will have to do that next with a more complex model. Stay tuned...

Drop Cutter 3/3: Edge Test

The third and final test in the drop cutter algorithm is to drop the cutter down so it touches an edge. The vertex and facet tests were quite easy, but this one requires a bit of calculations. I'm following Chuang2002.
To simplify things we first translate the tool in the (x, y) plane to (0, 0), and then rotate the edge we are testing against so that it lies along the x-axis and is below the cutter (or on top of the x-axis). The distance from the edge to (0, 0) is l.

Now we imagine a vertical plane through the edge and slice the cutter with that plane. There are two cases, depending on l.

If R-r>l we are cutting with a plane (green) that results in an intersection that has two quarter ellipses at the sides and a flat part in the middle. These ellipses have centers with
xd = +/- sqrt( (R-r)^2 - l^2 )

The other case is shown with a red line: if
R-r<=l<R
the intersection of the cutter will be a half ellipse centered at xd=0.
In both cases the curved part of the intersection is described by
f(theta) = (w*cos(theta) , h*cos(theta) ) where 0<theta<pi
h and w, the height and width of the ellipse are given by

  • quarter-ellipse case:
    • h=r
    • w=sqrt(R^r - l^2) - sqrt( (R-r)^2 - l^2 )
  • half -ellipse case:
    • h=sqrt( r^2 -(l-(R-l))^2 )
    • w=sqrt(R^2-l^2)

Now that the geometry is clear we can have the edge contact the intersection. That happens at a point where the tangents("slopes") are equal. A tangent vector to the ellipse is given by
f'(theta) = (-w*sin(theta) , -h*cos(theta) )
which can be equated with the slope of the line:
w*sin(theta) / h*cos(theta) = (x1-x2)/(z1-z2)
and we find the angle theta of our CC point:
theta = atan( h*(x1-x2)/w*(z1-z2))
(z1=z2 is a trivial special case not handled here)

The CC point is now given by
xc = xd +/- abs(w*cos(theta))
which should be checked if it lies between x1 and x2. If it does we are contacting the edge, and we can calculate the z-coordinate of the CC point as:
zc = ((xc-x1)/(x2-x1))*(z2-z1) +z1
and finally that leads us to the correct cutter height
ze = zc + abs(h*sin(theta)) - r

Now I need to put all these tests together and find a way of importing STL files into matlab. That way I can begin to test if/how my drop cutter algorithm works!

There's still a lot to do before I have a set of algorithms for basic 3-axis toolpath creation: "push-cutter" a 2D version of drop cutter, 2D line/arc? offsets, zigzag paths, STL-slice with plane, z-buffer simulation of stock material, to name a few things...

Transformer test

There was something strange going on when I measured the transformer last time, and since that I've gotten a few pointers from visitors to the blog and the CAD_CAM_EDM_DRO list.

I now did a test without the inrush current-limiter, and it does make a difference. It is rated for 8 A continuous current, but apparently it limits current much before that...

Now the 'AC load' line is measured by hooking up resistive loads to the secondary windings (no rectifier or caps), and it shows a series resistance of about 0.3 Ohms, or similar to what can be measured with a multimeter over the secondary windings. So at least the transformer seems to be working.

Then I hook up the secondary to the diode bridge and the caps and connect the same set of resistive loads as before. That's the 'DC load' measurements above. There again I see a big drop in voltage at first that then levels off somewhat. For the points above 5 A current the voltage drop is around 2 V per amp, or about a 2 Ohm effective series resistance. Also, the transformer does not emit any sound at all during the AC test, but now with the rectifier and caps when I load it up there is a slight 'humm' sound(probably 50 Hz and its harmonics).

I wonder if that 2 Ohm is typical or if there still is something strange going on? (could the rectifier bridge be too small? Anything wrong with my 4x 10 000 uF 100 V electrolytic caps?)

I tested this with one bridge rectifier GBPC5004 rated at 400V/50A and another one, a GBPC5010 rated 1000V/50A, but the results are the same. Looking with an oscilloscope at 6 A load at the DC voltage there is about 1.4 V of ripple.