<?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/category/cnc/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>With FreeSerifBoldItalic, don&#039;t ever write &quot;zj&quot;!</title>
		<link>http://www.anderswallin.net/2012/01/with-freeserifbolditalic-dont-ever-write-zj/</link>
		<comments>http://www.anderswallin.net/2012/01/with-freeserifbolditalic-dont-ever-write-zj/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 16:14:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5499</guid>
		<description><![CDATA[Update: Here is "VX" with FreeSerifItalic. There is overlap in LibreOffice also. For the most part truetypetracer produces valid and nice input data for testing openvoronoi. But sometimes I see wiggles, and now this: It is frustrating to try to track down bugs in downstream algorithms that take this as input, and assume all line-segments [...]]]></description>
			<content:encoded><![CDATA[<p>Update: Here is "VX" with FreeSerifItalic. There is overlap in LibreOffice also.<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/VX_freeserifitalic.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/VX_freeserifitalic-300x260.png" alt="" title="VX_freeserifitalic" width="300" height="260" class="alignnone size-medium wp-image-5529" /></a></p>
<p>For the most part truetypetracer produces valid and nice input data for testing openvoronoi. But sometimes I see <a href="http://www.anderswallin.net/2012/01/non-smooth-output-from-ttt/">wiggles</a>, and now this:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/zj_ttt.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/zj_ttt-260x300.png" alt="" title="zj_ttt" width="260" height="300" class="alignnone size-medium wp-image-5500" /></a></p>
<p>It is frustrating to try to track down bugs in downstream algorithms that take this as input, and assume all line-segments are non-intersecting when in fact the are not!</p>
<p>I seem to have only 13 .ttf files in my <code>/usr/share/fonts/truetype/freefont</code> folder, but maybe there are more elsewhere. I should find a font that is properly designed without wiggles and without overlaps. The other approach is to write a pre-processor that looks at input data and either rejects or cleans it. Looking for all pair-wise intersections of N line-segments is a slow N^2 algorithm - at least for a naive implementation (without bounding-boxes or binning or other tricks).</p>
<p>Unlike the wiggles, this overlap doesn't happen in Inkscape:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/zj_inkscape.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/zj_inkscape-287x300.png" alt="" title="zj_inkscape" width="287" height="300" class="alignnone size-medium wp-image-5502" /></a></p>
<p>Here is G-code generated with <a href="http://timeguy.com/cradek/01276453959">ttt-4.0</a> and drawn in LinuxCNC:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/zj2.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/zj2-300x142.png" alt="" title="zj2" width="300" height="142" class="alignnone size-medium wp-image-5506" /></a></p>
<p>Here is a screenshot from LibreOffice 3:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/zj_libreoffice.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/zj_libreoffice-300x237.png" alt="" title="zj_libreoffice" width="300" height="237" class="alignnone size-medium wp-image-5508" /></a></p>
<p>and GIMP:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/zj_gimp.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/zj_gimp-273x300.png" alt="" title="zj_gimp" width="273" height="300" class="alignnone size-medium wp-image-5510" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/with-freeserifbolditalic-dont-ever-write-zj/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>V-carving test</title>
		<link>http://www.anderswallin.net/2012/01/v-carving-test/</link>
		<comments>http://www.anderswallin.net/2012/01/v-carving-test/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 19:16:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>
		<category><![CDATA[medial axis]]></category>
		<category><![CDATA[v-carving]]></category>
		<category><![CDATA[voronoi]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5493</guid>
		<description><![CDATA[A first try at v-carving, with toolpaths produced by the ttt2medial python script.]]></description>
			<content:encoded><![CDATA[<p><iframe width="560" height="315" src="http://www.youtube.com/embed/n4P9SvT4L7g" frameborder="0" allowfullscreen></iframe></p>
<p>A first try at v-carving, with toolpaths produced by the <a href="https://github.com/aewallin/linuxcnc-scripts/blob/master/ttt2medial.py">ttt2medial</a> python script.</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/emc2_vcarve.jpg"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/emc2_vcarve-300x106.jpg" alt="" title="emc2_vcarve" width="300" height="106" class="alignnone size-medium wp-image-5494" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/v-carving-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Non-smooth output from ttt</title>
		<link>http://www.anderswallin.net/2012/01/non-smooth-output-from-ttt/</link>
		<comments>http://www.anderswallin.net/2012/01/non-smooth-output-from-ttt/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 09:45:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5480</guid>
		<description><![CDATA[I tried cranking up (10-fold) the number of line-segments that are used when approximating conics and cubics with lines. The results are mostly OK, but sometimes "wiggles" or "S-curves" appear, which cause problems for the medial-axis filter. This "P" is an example: The medial axis on the right does not look correct. If we zoom [...]]]></description>
			<content:encoded><![CDATA[<p>I tried cranking up (10-fold) the number of line-segments that are used when approximating conics and cubics with lines. The results are mostly OK, but sometimes "wiggles" or "S-curves" appear, which cause problems for the medial-axis filter. This "P" is an example:</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/p_vd_ma.png"><img class="alignnone size-medium wp-image-5481" title="p_vd_ma" src="http://www.anderswallin.net/wp-content/uploads/2012/01/p_vd_ma-300x153.png" alt="" width="300" height="153" /></a></p>
<p>The medial axis on the right does not look correct. If we zoom in it's clear that there's an "S-curve" in the input geometry, which causes a LINELINE edge (drawn in darker blue), which the medial-axis filter doesn't think should be removed:</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/p_wiggle.png"><img class="alignnone size-medium wp-image-5482" title="p_wiggle" src="http://www.anderswallin.net/wp-content/uploads/2012/01/p_wiggle-300x156.png" alt="" width="300" height="156" /></a></p>
<p>For the letters "EMC" it looks mostly OK, but there's a similar wiggle in "E"</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/emc_ma.png"><img class="alignnone size-medium wp-image-5483" title="emc_ma" src="http://www.anderswallin.net/wp-content/uploads/2012/01/emc_ma-300x147.png" alt="" width="300" height="147" /></a> <a href="http://www.anderswallin.net/wp-content/uploads/2012/01/EMC_wiggle.png"><img class="alignnone size-medium wp-image-5484" title="EMC_wiggle" src="http://www.anderswallin.net/wp-content/uploads/2012/01/EMC_wiggle-296x300.png" alt="" width="296" height="300" /></a></p>
<p>Increasing the number of line-segments further causes even stranger things. Here's a zoom-in at the top of "P" that shows both the wiggle that was visible before, but also a strange inward bulge:</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/P_top.png"><img class="alignnone size-medium wp-image-5485" title="P_top" src="http://www.anderswallin.net/wp-content/uploads/2012/01/P_top-300x292.png" alt="" width="300" height="292" /></a></p>
<p>Hopefully this is a bug in how conics/cubics are converted to line-segments in ttt, and not an issue with how FreeType fonts are represented.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/non-smooth-output-from-ttt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>EMC2 Filters</title>
		<link>http://www.anderswallin.net/2012/01/emc2-filters/</link>
		<comments>http://www.anderswallin.net/2012/01/emc2-filters/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 16:04:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EMC]]></category>
		<category><![CDATA[OpenVoronoi]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5465</guid>
		<description><![CDATA[I hacked together a few python-scripts that can be run as "filters" in EMC2. They are opened/run from AXIS and produce G-code into EMC2. The first one is ttt2ngc which simply demonstrates my C++ port of Chris Radek's truetype-tracer. The original code is a rather monolithic C-program while my C++ port is divided into smaller [...]]]></description>
			<content:encoded><![CDATA[<p>I hacked together a few python-scripts that can be run as "filters" in EMC2. They are opened/run from AXIS and produce G-code into EMC2.</p>
<p>The first one is <a href="https://github.com/aewallin/truetype-tracer/blob/master/ttt2ngc.py">ttt2ngc</a> which simply demonstrates my C++ port of <a href="http://timeguy.com/cradek/truetype">Chris Radek's truetype-tracer</a>. The original code is a rather monolithic C-program while my C++ port is divided into smaller files and offers python-bindings and more options (for example arc, cubic, conic output can be turned on/off independently).</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/tttpp.png"><img class="alignnone size-medium wp-image-5469" title="tttpp" src="http://www.anderswallin.net/wp-content/uploads/2012/01/tttpp-300x206.png" alt="" width="300" height="206" /></a></p>
<p>The seconds script is <a href="https://github.com/aewallin/openvoronoi/blob/master/python_examples/ttt2offset.py">ttt2offset</a> which takes ttt-geometry, builds a <a href="http://en.wikipedia.org/wiki/Voronoi_diagram">VD</a>, and produces offsets. By reversing the list of points from ttt either inwards or outwards offsets can be produced. Currently the toolpaths are machined in the order they are produced, i.e. in order of increasing offset value. An improvement would be to order the loops so that for e.g. pocketing the innermost loop is machined first, and rapid-traverses are minimized.</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/interior_emc2_offsets.png"><img class="alignnone size-medium wp-image-5470" title="interior_emc2_offsets" src="http://www.anderswallin.net/wp-content/uploads/2012/01/interior_emc2_offsets-300x206.png" alt="" width="300" height="206" /></a> <a href="http://www.anderswallin.net/wp-content/uploads/2012/01/exterior_emc2_offset.png"><img class="alignnone size-medium wp-image-5468" title="exterior_emc2_offset" src="http://www.anderswallin.net/wp-content/uploads/2012/01/exterior_emc2_offset-300x205.png" alt="" width="300" height="205" /></a></p>
<p>The third script is <a href="https://github.com/aewallin/openvoronoi/blob/master/python_examples/ttt2medial.py">ttt2medial</a>. Here the VD is filtered down to an (approximate) medial-axis, and the edges of the <a href="http://en.wikipedia.org/wiki/Medial_axis">medial axis</a> are chained together into a toolpath. The chaining-algorithm could probably be improved much, again to minimize rapid-traverses.</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/emc2_vcarve2.png"><img class="alignnone size-medium wp-image-5467" title="emc2_vcarve2" src="http://www.anderswallin.net/wp-content/uploads/2012/01/emc2_vcarve2-300x205.png" alt="" width="300" height="205" /></a></p>
<p>If this is run with a V-shaped cutter with a 90-degree angle we can push the cutter into the material by an amount equal to the clearance-disk radius of the edge. This is a "V-carving" toolpath which should produce a cut-out very similar to the outline of the font. For added effect choose a material with  contrasting surface and interior colors.</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/emc2_vcarve1.png"><img class="alignnone size-medium wp-image-5466" title="emc2_vcarve1" src="http://www.anderswallin.net/wp-content/uploads/2012/01/emc2_vcarve1-300x206.png" alt="" width="300" height="206" /></a></p>
<p>It would be interesting to know if this v-carving g-code is anywhere near to correct. If someone has a cutting-simulator, or is adventurous enough to run this on an actual machine, I'd be very interested in the results! (here is the g-code: <a href="http://www.anderswallin.net/wp-content/uploads/2012/01/emc2_vcarve.ngc_.zip">emc2_vcarve.ngc</a>)</p>
<p>Here is a metric version. The max depth is around -3mm, so a 10mm diameter 90-degree V-cutter should be OK. The text should be roughly 100mm long: <a href="http://www.anderswallin.net/wp-content/uploads/2012/01/emc2_vcarve_mm_ver2.ngc_.zip">emc2_vcarve_mm_ver2.ngc</a></p>
<p>Disclaimer: This is experimental code. Warnings, Errors, and Segfaults are common.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/emc2-filters/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Graph filters</title>
		<link>http://www.anderswallin.net/2012/01/graph-filters/</link>
		<comments>http://www.anderswallin.net/2012/01/graph-filters/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 18:51:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[medial axis]]></category>
		<category><![CDATA[polygon]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5452</guid>
		<description><![CDATA[I've put together two graph filters that can be applied to the VD. The first one detects the interior or exterior of a polygon. When the VD is constructed the polygon boundary must be input in CW order, and any islands inside the polygon in CCW order (or vice versa). This allows running other downstream [...]]]></description>
			<content:encoded><![CDATA[<p>I've put together two graph filters that can be applied to the <a href="http://en.wikipedia.org/wiki/Voronoi_diagram">VD</a>.</p>
<p>The first one detects the interior or exterior of a polygon. When the VD is constructed the polygon boundary must be input in CW order, and any islands inside the polygon in CCW order (or vice versa). This allows running other downstream algorithms only on the parts of the VD that pass the filter. Like these exterior and interior offsets:</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/exterrior_abc_offset.png"><img class="alignnone size-medium wp-image-5453" title="exterrior_abc_offset" src="http://www.anderswallin.net/wp-content/uploads/2012/01/exterrior_abc_offset-300x174.png" alt="" width="300" height="174" /></a> <a href="http://www.anderswallin.net/wp-content/uploads/2012/01/interior_abc_offsets.png"><img class="alignnone size-medium wp-image-5454" title="interior_abc_offsets" src="http://www.anderswallin.net/wp-content/uploads/2012/01/interior_abc_offsets-300x172.png" alt="" width="300" height="172" /></a></p>
<p>The other filter looks at the interior VD and tries to produce an approximate <a href="http://en.wikipedia.org/wiki/Medial_axis">medial axis</a>. We can start with the complete interior VD, such as this "J":</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/J_interior.png"><img class="alignnone size-medium wp-image-5455" title="J_interior" src="http://www.anderswallin.net/wp-content/uploads/2012/01/J_interior-300x294.png" alt="" width="300" height="294" /></a></p>
<p>By definition the medial axis consists of <em>"the set of all points having more than one closest point on the object's boundary". </em>The separator edges shown in purple above can clearly be eliminated, since their adjacent/defining sites are an open line-segment and the segment's endpoint. Removing separators gives us this:</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/J_no_separators.png"><img class="alignnone size-medium wp-image-5456" title="J_no_separators" src="http://www.anderswallin.net/wp-content/uploads/2012/01/J_no_separators-300x294.png" alt="" width="300" height="294" /></a></p>
<p>Now we can either finish here, or try to filter out some more edges to make it look better. Since we approximated smooth curves with line-segments we should try to detect which parts of the boundary are really distinct curves, and which are merely many consecutive line-segments approximating a single smooth curve. I've compared the dot-product (angle) between two consecutive segments, and applied an arbitrary threshold:</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/J_angle_filtered.png"><img class="alignnone size-medium wp-image-5457" title="J_angle_filtered" src="http://www.anderswallin.net/wp-content/uploads/2012/01/J_angle_filtered-300x300.png" alt="" width="300" height="300" /></a></p>
<p>For the whole alphabet it looks like this.</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/alphabet_medial_axis.png"><img class="alignnone size-medium wp-image-5458" title="alphabet_medial_axis" src="http://www.anderswallin.net/wp-content/uploads/2012/01/alphabet_medial_axis-300x190.png" alt="" width="300" height="190" /></a></p>
<p>The choice of threshold value for the angle-filtering is arbitrary. In many cases such as "x" and "m" it results in small or large left-over branches. This could probably be avoided by (1) tuning the angle-threshold, (2) approximating smooth curves with a larger number of line-segments, (3) eliminating branches below a certain length, or (4) choosing a font that's made for v-carving (are there any?).</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/x_branches.png"><img class="alignnone size-medium wp-image-5459" title="x_branches" src="http://www.anderswallin.net/wp-content/uploads/2012/01/x_branches-300x191.png" alt="" width="300" height="191" /></a> <a href="http://www.anderswallin.net/wp-content/uploads/2012/01/m_branches.png"><img class="alignnone size-medium wp-image-5460" title="m_branches" src="http://www.anderswallin.net/wp-content/uploads/2012/01/m_branches-300x190.png" alt="" width="300" height="190" /></a></p>
<p>Although it's probably not right to call it a "medial axis" , the same filter applied to the exterior VD also looks interesting. It divides the plane into organic looking shapes around each letter. It could probably be used for a lot of shape analysis. For example in a smart pocketing routine to find large areas that can be cleared with a large cutter, before a smaller cutter is required for the details. Note that in addition to the geometric shape of all the blue-ish edges the diagram also holds distance-information at each point of an edge. The distance stored is a clearance-disk radius, i.e. we can draw a circle at any point of an edge with this radius, and no input geometry (in yellow) will intersect the circle.</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/alphabet_exterior_medial_axis.png"><img class="alignnone size-medium wp-image-5461" title="alphabet_exterior_medial_axis" src="http://www.anderswallin.net/wp-content/uploads/2012/01/alphabet_exterior_medial_axis-300x191.png" alt="" width="300" height="191" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/graph-filters/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>2D Offsets</title>
		<link>http://www.anderswallin.net/2012/01/2d-offsets/</link>
		<comments>http://www.anderswallin.net/2012/01/2d-offsets/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 23:25:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>
		<category><![CDATA[offset]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5440</guid>
		<description><![CDATA[Once we have a VD it is almost trivial to calculate 2D offsets. While the VD for n line-segments takes O(n*log(n)) time to calculate, the offset-generation is a simple "march" that takes O(n) time. In this "A" example it takes 24 milliseconds to calculate the VD and less than 1 millisecond to produce all the [...]]]></description>
			<content:encoded><![CDATA[<p>Once we have a VD it is almost trivial to calculate 2D offsets. While the VD for n line-segments takes O(n*log(n)) time to calculate, the offset-generation is a simple "march" that takes O(n) time. In this "A" example it takes 24 milliseconds to calculate the VD and less than 1 millisecond to produce all the shown offsets. Input geometry in yellow, VD in blue. Offset lines in light-green and offset arcs in slightly darker green.</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/a_offset.png"><img class="alignnone size-medium wp-image-5441" title="a_offset" src="http://www.anderswallin.net/wp-content/uploads/2012/01/a_offset-300x285.png" alt="" width="300" height="285" /></a></p>
<p>Here is a larger example where VD takes 1.3 seconds, and all offsets shown take 99 milliseconds in total to produce. It would be interesting to benchmark this against <a href="https://github.com/Heeks/libarea">libarea</a> or other open-source 2D offset solutions. (here all line/arc offsets in one green color, for simplicity)</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/offset2.png"><img class="alignnone size-medium wp-image-5444" title="offset2" src="http://www.anderswallin.net/wp-content/uploads/2012/01/offset2-300x178.png" alt="" width="300" height="178" /></a></p>
<p>Here is a third picture with offsets for a single offset-distance:</p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/offset_alphabet.png"><img class="alignnone size-medium wp-image-5443" title="offset_alphabet" src="http://www.anderswallin.net/wp-content/uploads/2012/01/offset_alphabet-300x177.png" alt="" width="300" height="177" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/2d-offsets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VD Alphabet</title>
		<link>http://www.anderswallin.net/2012/01/vd-alphabet/</link>
		<comments>http://www.anderswallin.net/2012/01/vd-alphabet/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 14:29:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>
		<category><![CDATA[ttt++]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5427</guid>
		<description><![CDATA[There was an issue with handling collinear line-segments, which is hopefully now fixed. OpenVoronoi seems to deal OK with most characters from ttt now. I am still getting some Warnings about numerical instability from LLLSolver, possibly related to these high-degree vertices which don't look quite right (this is a zoom-in inside the circular dot of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.anderswallin.net/wp-content/uploads/2012/01/alphabet_vd.png"><img class="alignnone size-medium wp-image-5428" title="alphabet_vd" src="http://www.anderswallin.net/wp-content/uploads/2012/01/alphabet_vd-300x191.png" alt="" width="300" height="191" /></a></p>
<p>There was an issue with handling collinear line-segments, which is hopefully now fixed. OpenVoronoi seems to deal OK with most characters from ttt now.</p>
<p>I am still getting some Warnings about numerical instability from LLLSolver, possibly related to these high-degree vertices which don't look quite right (this is a zoom-in inside the circular dot of "j" in the picture above):<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/high_degree_vertex.png"><img class="alignnone size-medium wp-image-5429" title="high_degree_vertex" src="http://www.anderswallin.net/wp-content/uploads/2012/01/high_degree_vertex-300x193.png" alt="" width="300" height="193" /></a></p>
<p>I should write a class for extracting offsets next. Then perhaps <a href="http://en.wikipedia.org/wiki/Medial_axis">medial axis</a> (if anyone is interested in v-carving toolpaths).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/vd-alphabet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TTT++ and font-vd</title>
		<link>http://www.anderswallin.net/2012/01/ttt-and-font-vd/</link>
		<comments>http://www.anderswallin.net/2012/01/ttt-and-font-vd/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 16:31:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>
		<category><![CDATA[truetype-tracer]]></category>
		<category><![CDATA[ttt++]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5410</guid>
		<description><![CDATA[Update: Now all the capital letters work! I wanted to test my VD algorithm on font-outlines. So I ported Chris Radek's truetype-tracer to c++ and added some python bindings. Here: https://github.com/aewallin/truetype-tracer Because my VD code cannot handle circular arcs yet, I took some old code from TTT 3.0 and made converting conics and cubics, the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Now all the capital letters work!<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/capitals_vd.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/capitals_vd-300x176.png" alt="" title="capitals_vd" width="300" height="176" class="alignnone size-medium wp-image-5414" /></a></p>
<p>I wanted to test my <a href="http://en.wikipedia.org/wiki/Voronoi_diagram">VD</a> algorithm on font-outlines. So I ported <a href="http://www.timeguy.com/cradek/truetype">Chris Radek's truetype-tracer</a> to c++ and added some python bindings. Here: <a href="https://github.com/aewallin/truetype-tracer">https://github.com/aewallin/truetype-tracer</a></p>
<p>Because my VD code cannot handle circular arcs yet, I took some old code from TTT 3.0 and made converting conics and cubics, the native output of <a href="http://www.freetype.org/">FreeType</a>, as well as arcs into line-segments optional.</p>
<p>Predictably, OpenVoronoi crashes in many cases, but here is an "L" that works:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/vd_font.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/vd_font-300x297.png" alt="" title="vd_font" width="300" height="297" class="alignnone size-medium wp-image-5411" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/ttt-and-font-vd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VD for polylines and polygons</title>
		<link>http://www.anderswallin.net/2012/01/vd-for-polylines-and-polygons/</link>
		<comments>http://www.anderswallin.net/2012/01/vd-for-polylines-and-polygons/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 14:38:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>
		<category><![CDATA[null-face]]></category>
		<category><![CDATA[segment]]></category>
		<category><![CDATA[topology]]></category>
		<category><![CDATA[voronoi]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5396</guid>
		<description><![CDATA[I've been hacking away at openvoronoi, adding support for polylines and polygons. The code I had in November works with individual non-intersecting line segments, like this: Note how each vertex in the figure above is of degree three, i.e. there are three edges incident on each vertex. There's something about the number three, or triangles, [...]]]></description>
			<content:encoded><![CDATA[<p>I've been hacking away at <a href="https://github.com/aewallin/openvoronoi">openvoronoi</a>, adding support for polylines and polygons.</p>
<p>The code I had in <a href="http://www.anderswallin.net/2011/11/random-line-segment-voronoi-diagram/">November</a> works with individual non-intersecting line segments, like this:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/line_segments.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/line_segments-300x213.png" alt="" title="line_segments" width="300" height="213" class="alignnone size-medium wp-image-5397" /></a><br />
Note how each vertex in the figure above is of degree three, i.e. there are three edges incident on each vertex. There's something about the number three, or triangles, or both, that makes <a href="http://en.wikipedia.org/wiki/Planar_graph">planar graphs</a> of <a href="http://en.wikipedia.org/wiki/Degree_(graph_theory)">degree three</a> particularly nice to work with.</p>
<p>Here's the same figure with some notes describing the elements. The line-sites are drawn in yellow, and are associated with their left <strong>R(L+)</strong> and right <strong>R(L-)</strong> regions. The purple lines are called <strong>separators</strong>, and they define the region associated with the start- or end-point of a line-site. The three possible edge-types are also shown: LineEdge between two point-sites, LineEdge between two line-sites, and a Parabolic (PointLine) edge between a point-site and a line-site.<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/line_segments_text.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/line_segments_text-300x213.png" alt="" title="line_segments_text" width="300" height="213" class="alignnone size-medium wp-image-5398" /></a></p>
<p>Now, things get more complicated when we want to 'glue' two line-segments end-to-end in a polyline, or glue three or more line-segments together to form a polygon. Vertices are not necessarily of degree three any more. In fact the vertex degree is essentially unbounded, as you can start/end arbitrarily many line-segments at the same vertex. The solution I am using is to introduce what I call a <strong>null-face</strong> with zero-length <strong>null-edges</strong> around each point-site to which more than one line-segment connects. The mental picture is much like that of a key-chain, or mountaineering carabiners that are hooked-in to a loop. When we want to use the a vertex as a start/end-point for a segment we 'hook-in' to the null-face:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/key-ring.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/key-ring-300x164.png" alt="" title="key-ring" width="300" height="164" class="alignnone size-medium wp-image-5399" /></a></p>
<p>This introduces a number of new rules and associated code for how vertices should be created, removed, and moved around a null-face, but it seems to work somehow now:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/first_vd_polygon.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/first_vd_polygon-300x289.png" alt="" title="first_vd_polygon" width="300" height="289" class="alignnone size-medium wp-image-5400" /></a><br />
Note how these null-faces and the circular null-edges around each end-point result in degree three vertices, which are much nicer to deal with in the algorithm. For example, the null-face around vertex "0" is 40->85->86->41->39. Without the null-face construction this vertex would be of degree five. Here is an annotated version of the same picture:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/first_vd_polygon-text.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/first_vd_polygon-text-300x289.png" alt="" title="first_vd_polygon text" width="300" height="289" class="alignnone size-medium wp-image-5401" /></a><br />
This image shows how the diagram divides the plane into regions associated with endpoints such as <strong>R(0)</strong> and with the right/left side of a line-segment such as <strong>R(0-29)</strong> and <strong>R(29-0)</strong>. The null-edges that form null-faces around each end-point are drawn in white.</p>
<p>Of course, these null-edges are only a topological construction. Geometrically we can position each vertex on a null-face at the location of the encircled point-site. This effectively contracts away the zero-area null-faces, and the result is the diagram we want:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/polygon.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/polygon-300x287.png" alt="" title="polygon" width="300" height="287" class="alignnone size-medium wp-image-5402" /></a></p>
<p>The code now runs for a few select test-cases. To be continued...</p>
<p><strong>Update:</strong> The code now seems to work also for random polygons with a large number of vertices. Here is one with 400 vertices:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/400-vertex_random_polygon.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/400-vertex_random_polygon-300x295.png" alt="" title="400-vertex_random_polygon" width="300" height="295" class="alignnone size-medium wp-image-5406" /></a><br />
and 3200-vertices:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2012/01/3200-vertex_rpg.png"><img src="http://www.anderswallin.net/wp-content/uploads/2012/01/3200-vertex_rpg-300x294.png" alt="" title="3200-vertex_rpg" width="300" height="294" class="alignnone size-medium wp-image-5408" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2012/01/vd-for-polylines-and-polygons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Call graph</title>
		<link>http://www.anderswallin.net/2011/12/call-graph/</link>
		<comments>http://www.anderswallin.net/2011/12/call-graph/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 20:22:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenVoronoi]]></category>
		<category><![CDATA[kcachegrind]]></category>
		<category><![CDATA[optmization]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[valgrind]]></category>

		<guid isPermaLink="false">http://www.anderswallin.net/?p=5375</guid>
		<description><![CDATA[For profiling I made a small c++ program which calculates a poisson voronoi diagram. When called through valgrind like this (under valgrind the program will run roughly 50 times slower than normal) valgrind --tool=callgrind -v ./ovd_tst --n 1000 I can then use kcachegrind to draw a call graph. I thought the nearest-neighbor grid-search (grid_find_closest_face()) would [...]]]></description>
			<content:encoded><![CDATA[<p>For profiling I made a small c++ program which calculates a poisson voronoi diagram. When called through <a href="http://valgrind.org/">valgrind</a> like this (under valgrind the program will run roughly 50 times slower than normal)<br />
<code>valgrind --tool=callgrind -v ./ovd_tst --n 1000</code><br />
I can then use <a href="http://kcachegrind.sourceforge.net/html/Home.html">kcachegrind</a> to draw a call graph.</p>
<p>I thought the <a href="http://en.wikipedia.org/wiki/Nearest_neighbor_search">nearest-neighbor</a> grid-search (<strong>grid_find_closest_face()</strong>) would cost much more than it does. </p>
<p><a href="http://www.anderswallin.net/wp-content/uploads/2011/12/t3.png"><img src="http://www.anderswallin.net/wp-content/uploads/2011/12/t3-300x119.png" alt="" title="t3" width="300" height="119" class="alignnone size-medium wp-image-5376" /></a></p>
<p>The callee map may in fact better visualize where CPU time is spent:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2011/12/callee_map.png"><img src="http://www.anderswallin.net/wp-content/uploads/2011/12/callee_map-300x216.png" alt="" title="callee_map" width="300" height="216" class="alignnone size-medium wp-image-5378" /></a></p>
<p>The map changes significantly if we change the solver number type to <strong>double</strong>, which is faster but less accurate. A better strategy might be to run the fast <strong>solver(double)</strong> first, then check the quality of the solution, and run the slow <strong>solver(qd_real)</strong> only if necessary.<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2011/12/map_double.png"><img src="http://www.anderswallin.net/wp-content/uploads/2011/12/map_double-300x200.png" alt="" title="map_double" width="300" height="200" class="alignnone size-medium wp-image-5382" /></a><br />
In this map there doesn't seem to be an obvious bottleneck or 'hot spot' in immediate need of optimizing, since there are 6-8 blocks/functions each taking roughly 10% of the CPU time.</p>
<p>After some tweaking the benchmark (with the <strong>double</strong> solver) run gives these results:<br />
<a href="http://www.anderswallin.net/wp-content/uploads/2011/12/vd-bench.png"><img src="http://www.anderswallin.net/wp-content/uploads/2011/12/vd-bench-287x300.png" alt="" title="vd-bench" width="287" height="300" class="alignnone size-medium wp-image-5388" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anderswallin.net/2011/12/call-graph/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

