<?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>FuriousBlog</title>
	<atom:link href="http://www.joshuanewth.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joshuanewth.com</link>
	<description>#define if while</description>
	<lastBuildDate>Fri, 10 Aug 2012 18:53:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Deathtrap Dungeon: Automated Backtrace</title>
		<link>http://www.joshuanewth.com/2012/08/deathtrap-dungeon-automated-backtrace/</link>
		<comments>http://www.joshuanewth.com/2012/08/deathtrap-dungeon-automated-backtrace/#comments</comments>
		<pubDate>Fri, 10 Aug 2012 18:53:46 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=416</guid>
		<description><![CDATA[I guess I wasn&#8217;t quite finished with this project. It annoyed me to not have a fully automated backtrace of my deathtrap dungeon solver so I finally added it. Here&#8217;s the complete maze with the solved path highlighted: custom_complete_maze_with_solution (pdf) &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2012/08/deathtrap-dungeon-automated-backtrace/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I guess I wasn&#8217;t quite finished with this project. It annoyed me to not have a fully automated backtrace of my deathtrap dungeon solver so I finally added it. Here&#8217;s the complete maze with the solved path highlighted:<br />
<a href="http://www.joshuanewth.com/wp-content/uploads/2012/08/custom_complete_maze_with_solution.png"><img class="aligncenter size-full wp-image-424" src="http://www.joshuanewth.com/wp-content/uploads/2012/08/custom_complete_maze_with_solution.png" alt="" width="56" height="1056" /></a></p>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2012/08/custom_complete_maze_with_solution.pdf">custom_complete_maze_with_solution</a> (pdf)</p>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2012/08/complete_with_solution.txt">complete_with_solution</a> (graphviz dot file)</p>
<p>Here&#8217;s how the system works:</p>
<p>1. Solve the maze forward using breadth-first search, propagating acquired &#8220;satisfiers&#8221; forward to child nodes (ie if your parent had a given satisfier like &#8220;SHIELD&#8221; then the child node has the same satisfier). The only trimming I do at this point is making sure I don&#8217;t add any child nodes where I don&#8217;t have the satisfier required for a given edge.</p>
<p>2. Backtrace from the endpoint of the maze by only following parents that meet the &#8220;requirements&#8221; that have been discovered so far. If a transition along an edge requires something, I add that requirement, and then only add subsequent parents who have that satisfier. For example, if the final node in the maze is 399-&gt;400 and it requires &#8220;DIAMOND&#8221;, I add &#8220;DIAMOND&#8221; as a requirement. Because we are only working with the possible parents available from the forward solve (meaning, it can only be a parent if at least some path arrives at the parent node with the DIAMOND) we know that at least some parent will have the required DIAMOND. If we discover at some possible point, lets say 397-&gt;399 and 398-&gt;399 that only 397 has the DIAMOND, then we can prune 398. It turns out this is sufficient to provide a single possible path (well, when I avoid all unnecessary battles) through our maze.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2012/08/deathtrap-dungeon-automated-backtrace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Map of Deathtrap Dungeon</title>
		<link>http://www.joshuanewth.com/2012/07/a-map-of-deathtrap-dungeon/</link>
		<comments>http://www.joshuanewth.com/2012/07/a-map-of-deathtrap-dungeon/#comments</comments>
		<pubDate>Fri, 13 Jul 2012 07:09:44 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=390</guid>
		<description><![CDATA[I just found a new favorite toy called Graphviz! I used it to draw the Deathtrap Dungeon graph in its entire form (all nodes) and in its solved form (only encluding nodes encountered during backtrace). The complete map as pdf: &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2012/07/a-map-of-deathtrap-dungeon/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I just found a new favorite toy called <a title="GraphViz" href="http://www.graphviz.org/">Graphviz</a>! I used it to draw the Deathtrap Dungeon graph in its entire form (all nodes) and in its solved form (only encluding nodes encountered during backtrace).</p>
<p>The complete map as pdf: <a href="http://www.joshuanewth.com/wp-content/uploads/2012/07/deathtrap.pdf">deathtrap.pdf</a><br />
The complete map as .dot (change extension): <a href="http://www.joshuanewth.com/wp-content/uploads/2012/07/deathtrap.txt">deathtrap.txt</a><br />
The solution as pdf: <a href="http://www.joshuanewth.com/wp-content/uploads/2012/07/solution1.pdf">solution.pdf</a><br />
The solution as .dot (change extension): <a href="http://www.joshuanewth.com/wp-content/uploads/2012/07/solution1.txt">solution.txt</a></p>
<div id="attachment_403" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.joshuanewth.com/wp-content/uploads/2012/07/output_parents.png"><img class="size-full wp-image-403" src="http://www.joshuanewth.com/wp-content/uploads/2012/07/output_parents.png" alt="" width="300" height="3840" /></a><p class="wp-caption-text">Deathtrap Dungeon Solution</p></div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2012/07/a-map-of-deathtrap-dungeon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Champion of Deathtrap Dungeon</title>
		<link>http://www.joshuanewth.com/2012/07/the-champion-of-deathtrap-dungeon/</link>
		<comments>http://www.joshuanewth.com/2012/07/the-champion-of-deathtrap-dungeon/#comments</comments>
		<pubDate>Tue, 03 Jul 2012 07:39:27 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=375</guid>
		<description><![CDATA[When I was a child, I played Deathtrap Dungeon, a &#8220;Fighting Fantasy&#8221; novel by Ian Livingstone. These books were magical in their ability to give kids the sorts of agency, adventure, heroism, and excitement that videogames would later provide. The &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2012/07/the-champion-of-deathtrap-dungeon/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>When I was a child, I played <a title="Deathtrap Dungeon" href="http://en.wikipedia.org/wiki/Deathtrap_Dungeon" target="_blank">Deathtrap Dungeon</a>, a &#8220;Fighting Fantasy&#8221; novel by Ian Livingstone. These books were magical in their ability to give kids the sorts of agency, adventure, heroism, and excitement that videogames would later provide. The covers were lurid, and promised action and violence and magic, all things a healthy ten year old wanted:</p>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2012/07/DeathtrapDungeonCover.jpeg"><img class="aligncenter  wp-image-377" src="http://www.joshuanewth.com/wp-content/uploads/2012/07/DeathtrapDungeonCover.jpeg" alt="The cover of The Fighting Fantasy book &quot;Deathtrap Dungeon&quot;" width="373" height="594" /></a></p>
<p><span id="more-375"></span>They are very similar to the &#8220;Choose Your Own Adventure&#8221; books, but with some really clever extensions to that basic concept. In the Fighting Fantasy series, for example, an adventurer would encounter monsters along his journey, and the outcome of the battle was decided by dice and hitpoint (and your honesty, of course), carefully tabulated by small hands scribbling with pencils in the front page of the book.</p>
<p>Sad to say, I never finished this book. The maze is too large, there are too many fights, and I wasn&#8217;t smart enough or patient enough back then to carefully construct a map in the hopes that on repeated playthroughs I would gradually discover the correct path through the maze.</p>
<p>I can&#8217;t remember why, exactly, but sometime in 2009 I was cruising Amazon and rediscovered this book. I was trying to learn Python and decided to make a solver to figure out the path. That Python solver came to naught, but I did end up laying the foundation by encoding the book itself.</p>
<p>I first needed to encode the pages (I call them nodes), the pathways between nodes (I call them edges), and a few other details. First I wrote &#8220;nodes.txt&#8221; like this:</p>
<p>188 155 224</p>
<p>and so on, for each page of the book.</p>
<p>One of the interesting things about this book is that the maze encodes the concept of state: Only certain edges were useable (if you were playing honestly) if you had encountered items previously. For example:</p>
<p>&#8220;The tunnel starts to slope downwards and finally comes to an end at a deep pool enclosed by the tunnel wall. If you can remember the spirit girl&#8217;s poem, turn to 155. If you have not seen the spirit girl, turn to 224.&#8221; So I also had to encode the concept of &#8220;dependencies&#8221;, edges that were traversable only when you had the appropriate item in your inventory:</p>
<p>dependencies.txt:<br />
188 155 SPIRITGIRLPOEM</p>
<p>One can only travel from 188 to 155 if one had encountered the &#8220;SPIRITGIRLPOEM&#8221; at some previous point in the maze. I encoded the acquisition of the necessary items as:</p>
<p>satisfiers.txt:<br />
229 SPIRITGIRLPOEM</p>
<p>And of course there were places you really didn&#8217;t want to go, so I eventually encoded such nodes as:</p>
<p>exclude.txt:<br />
#Dont want to fight the guard dog<br />
148</p>
<p>My interest in solving this problem was rekindled through an algorithms course I took last semester. I tried to think of appropriate graph traversal algorithms on to which I could map the concept of dependencies and satisfiers. In the end, I just decided to implement a modified Breadth-First solution. Breadth-First search is well understood, but while it can handle cycles just fine, BFS can&#8217;t handle dependencies! These modifications make this an interesting problem.</p>
<p>In a straight BFS maze solver, one simply takes ALL the steps available at each opportunity. So, on round 1, if node 1 has edges to nodes 2 and 3, nodes 2 and 3 are added to an &#8220;open&#8221; list. In step 2, the open list is consulted, and the nodes there (2 and 3) are explored, and their children are now added to the open list (for example, 4 and 5 from 2, 6 and 7 from 3). In this way, all nodes are explored in the maze, and the first complete path to the end also happens to be the shortest (optimal) path. However, this approach doesn&#8217;t capture the concept of satisfiers. If one hasn&#8217;t previously encountered the spirit girl and heard her poem, how then can one add node 155 to the open list?</p>
<p>The modification is to add a satisfier set to each node. This list is initially empty for the majority, except for nodes like 229, which start with m_satisfiers = { &#8216;SPIRITGIRLPOEM&#8217; }. As the list of open nodes is expanded, any node added to the open list has its satisfiers set updated with the satisfiers of its parent(s) so that when we are attempting to expand a node that has a dependency for one of its edges it can consult its satisfier list, which reflects the satisfiers it has acquired through it parents. Now we can imagine a scenario where parent A contributes satisfier A and parent B contributes satisfier B allowing our child node to incorrectly follow an edge that requires both A and B, but it turns out this doesn&#8217;t happen in Deathtrap Dungeon. And that, in the end, was more important to me than endless algorithm tinkering. It&#8217;s just not where my passion lies.</p>
<p>The problem with all this of course is that a node will occasionally acquire more than one valid parent node. There are a couple ways to improve this: Each node could acquire a set of satisfier sets, which each satisfier set representing the contribution of a given parent. This is a pretty reasonable improvemenet, and one I would have made if required, but as it turns out, it was easier to simply modify my solver to find a valid path forward from start to finish and then enter an interactive mode where I could conduct the backtrace myself. I spent a lot of time noodling about ways to fully automate the backtrace but in the end run up against the fact that a backtrace algorithm will also have problems with cycles and dependencies. In the end I concluded the effort wasn&#8217;t worth it.</p>
<p>My final solution represents this hybrid approach (automated forward solving, manual backtracing). The tabulated files, including my solution, are attached at the bottom of this post. My solution largely matches this guy&#8217;s <a title="solution" href="http://yosemite-sam.net/Solutions/Deathtrap.htm">solution</a>, and he constructed his the &#8220;hard&#8221; way by manually exploring the maze. He also provides a link to <a title="FightingFantasy.com" href="http://www.fightingfantasy.com/">FightingFantasy.com</a> which appears to be having some sort of renaissance. I can offer you a link to <a title="Tin Man Games" href="http://tinmangames.com.au/blog/">Tin Man Games</a>, an Australian outfit bringing this type of game (and indeed, the Fighting Fantasy originals themselves) to Android and iOS.</p>
<p>Files:</p>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2012/07/Path_MinimizeCombatWithExcludeList1.txt">Solution.txt</a></p>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2012/07/deathtrap_encoding.zip">DeathtrapDungeonFiles</a> (zip)</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2012/07/the-champion-of-deathtrap-dungeon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GJK: Fast Convex Hull Collision Detection in 2D and 3D</title>
		<link>http://www.joshuanewth.com/2012/04/gjk-fast-convex-hull-collision-detection-in-2d-and-3d/</link>
		<comments>http://www.joshuanewth.com/2012/04/gjk-fast-convex-hull-collision-detection-in-2d-and-3d/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 06:01:52 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[collision detection]]></category>
		<category><![CDATA[gjk]]></category>
		<category><![CDATA[physics]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=345</guid>
		<description><![CDATA[As part of my new job and my thesis I researched and implemented a 2D version of GJK (Gilbert-Johnson-Keerthi), a useful and fast collision detection algorithm. I will attempt to explain its operation and provide a basic implementation that is &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2012/04/gjk-fast-convex-hull-collision-detection-in-2d-and-3d/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>As part of my new job and my thesis I researched and implemented a 2D version of GJK (Gilbert-Johnson-Keerthi), a useful and fast collision detection algorithm. I will attempt to explain its operation and provide a basic implementation that is consistent with the excellent presentation found at MollyRocket (link provided below) as well as providing an explanation of what one does after detecting a collision using GJK.</p>
<p><span id="more-345"></span></p>
<h1>The Minkowski Difference</h1>
<p>The basic tool of GJK is the Minkowski Difference, explained in more depth and to far greater benefit by Wikipedia and Paul Firth&#8217;s website <a href="http://www.pfirth.co.uk/minkowski.html">http://www.pfirth.co.uk/minkowski.html</a>. The Minkowski difference is an inherently graphical concept. To see it is to know it immediately; To read about it is a lot less useful. Here goes: Think of it as an object where each point is the result of a point in object A &#8211; a point in object B.</p>
<p>Minkowski (x, y) = (Ax &#8211; Bx, Ay &#8211; By)</p>
<p>For the purposes of finding collisions one can simply consider the vertices of each object, but it is important to remember that we are talking about the infinite number of points that make up the 2D area (or in 3D, the volume) of each object. It is also worth drawing out a few to get the concept fixed in your brain. Heres a screenshot of Paul Firth&#8217;s applet:</p>
<div><a href="http://www.joshuanewth.com/wp-content/uploads/2012/04/diff01.jpg"><img class="aligncenter size-full wp-image-351" src="http://www.joshuanewth.com/wp-content/uploads/2012/04/diff01.jpg" alt="Screenshot of applet at http://www.pfirth.co.uk/minkowski.html" width="316" height="282" /></a></div>
<p>The weird object is the Minkowski Difference of the triangle and heptagon. We also note that if two objects are overlapping then there exists at least one point on each object A and B are the same, so the equation becomes:</p>
<p>Minkowski point (x, y) = (Ax &#8211; Bx, Ay &#8211; By) = (0, 0)</p>
<p>This means that if two convex hulls collide, then the Minkowski Difference of the two objects contains the origin. GJK is how to implement the question: Can I draw a simplex using only points on the surface of the Minkowski Difference object that contain the origin? If so, I have detected a collision. If not, then there is no collision. In 2D, a simplex means a triangle and in 3D simplex means a tetrahedron. Both are the smallest set of points that can contain another point in 2D and 3D, respectively.</p>
<h1>The Support Function</h1>
<p>The key to using GJK is to be able to compute the point on each object A and B that lies farthest along a search direction. I said earlier that although the Minkowski object is composed of all possible combination of points, we can solve GJK using only the vertices of of our polygons. In addition, although it is mathematically perfectly reasonable to pick a point not one of the vertices of the polygon, programmatically it is more sensible to only consider the points that make up the polygon. The way we do this is with the Support function, which given a direction to search along returns the vertex on an object that is farthest in that direction. Let&#8217;s see some examples:</p>
<div><a href="http://www.joshuanewth.com/wp-content/uploads/2012/04/support-01.jpg"><img class="aligncenter size-full wp-image-358" src="http://www.joshuanewth.com/wp-content/uploads/2012/04/support-01.jpg" alt="Support function in action" width="545" height="483" /></a></div>
<p>In case one, point one is the farthest point on the object along the search direction. If you are wondering why we didn&#8217;t choose the point on the line where the arrow crosses the square, tilt your head so the arrow is pointing straight up. See? The corner really is the farthest point in that direction.</p>
<div><a href="http://www.joshuanewth.com/wp-content/uploads/2012/04/support02.jpg"><img class="aligncenter size-full wp-image-359" src="http://www.joshuanewth.com/wp-content/uploads/2012/04/support02.jpg" alt="Support function in action" width="463" height="363" /></a></div>
<p>In case two, the search direction is normal to the side so both points 3 and 4 are valid. The algorithm will work regardless of which point you pick.</p>
<p>Here&#8217;s the awesome part. Rather than explicitly compute all the points of the Minkowski object and then calling our support function on that, we can simply call the support function on each of our two simple polygonal objects and compute the appropriate Minkowski point using the relationship below. Here&#8217;s the pseudocode for my support function:</p>
<table>
<tbody>
<tr>
<td>Function DoSupport()</td>
</tr>
<tr>
<td></td>
<td>Point on Minkowski along D = (Farthese point on A in direction D) &#8211; (Farthest point on B in direction -D)</td>
</tr>
<tr>
<td></td>
<td>Return Point on Minkowski</td>
</tr>
</tbody>
</table>
<p>VERY IMPORTANT: Observe that we use &#8220;-D&#8221; in the support function for object B.</p>
<h1>Evolving the Simplex</h1>
<p>I&#8217;ve tried to write this consistent with the Molly Rocket presentation which you should really watch if you are serious about implementing this algorithm. The way it works is:</p>
<div><a href="http://www.joshuanewth.com/wp-content/uploads/2012/04/pseudo-GJK.jpg"><img class="aligncenter size-full wp-image-352" src="http://www.joshuanewth.com/wp-content/uploads/2012/04/pseudo-GJK.jpg" alt="GJK pseudocode" width="407" height="155" /></a></div>
<p>That is seriously all there is to it. Well, not quite. What does &#8220;DoSimplex&#8221; actually do? Remember, we are trying to find the set of simplex points that contains the origin. To do that, we evolve the simplex to always contain those features closest to the origin, and to pick a new direction for us to search for the next candidate point to add to the simplex. Thus our DoSimplex function examines the existing simplex and then sometimes updates the simplex (by removing a point) and always picks the next direction for us to search in. In our formulation we never call DoSimplex on a simplex of size 1, so let&#8217;s consider the 2-point simplex.</p>
<h1>Evolving the Simplex: Two Point Simplex and Voronoi Regions</h1>
<div><a href="http://www.joshuanewth.com/wp-content/uploads/2012/04/simplex-line.jpg"><img class="aligncenter size-full wp-image-356" src="http://www.joshuanewth.com/wp-content/uploads/2012/04/simplex-line.jpg" alt="Simplex line image" width="746" height="323" /></a></div>
<p>In all the pictures, we consider the point A to be the most recently added point. In this case, we picked B and then went searching in our new search direction and found A, the farthest point on the Minkowski difference in that direction. Evolving the simplex means looking for the next search direction and simplifying our simplex. The origin can be in one of the three Voronoi regions defined by this line.</p>
<p>1. The origin can&#8217;t be in region 3. If it was, there was some other point in region 3 that we would have found instead of point B, because we picked B by saying the farthest point in that direction. Thus we never examine region 3.</p>
<p>2. If we overshot the origin, it is somewhere in region 1. In 2D simply find the perpendicular to the line AB in the direction of the origin because we know the origin still lies in the plane of the line. in 3D, you need to use the triple cross product to get the perpendicular to the line AB in the direction of the origin. The test &#8220;Did we overshoot the origin is simply the dot product of vector AB with A0. If the dot product is greater than 0, then the angle between AB and A0 is less than 90 degrees, putting it in on the region 1 side of the plane divided by the dotted line at A, which could be region 1 or 3. As we know it is not region 3, it must be region 2.</p>
<p>3. If we went as far as we could in our search direction and couldn&#8217;t pass the origin, we know the origin is still somewhere farther than Point A, so it must still in region 2. We can drop B from our simplex because it is not useful and set our new search direction to be from A towards the origin.</p>
<h1>Evolving the Simplex: Three Point Simplex and Voronoi Regions</h1>
<div><a href="http://www.joshuanewth.com/wp-content/uploads/2012/04/simplex-triangle.jpg"><img class="aligncenter size-full wp-image-357" src="http://www.joshuanewth.com/wp-content/uploads/2012/04/simplex-triangle.jpg" alt="Simplex triangle image" width="466" height="529" /></a></div>
<p>This looks a lot more complicated, but it isn&#8217;t, not really. It is essentially two line simplexes with a bit of reasoning about the other regions. First, observe the white regions to the left of the drawing. We can reject those by the same reasoning we rejected the region behind B in the line simplex case: We are only considering this point A because we already decided it was more in the direction of the origin than anything on the other side of the line BC, so why would we waste work looking regions we already know are farther away from the origin?</p>
<p>We evolve our simplex in the following manner: First we check to see if the origin is on the side of the AB line away from C. If so, we can ignore everything on the C side of the AB line, and then just check to see if the origin is in the yellow part or the pink part of that side of the line. Because C can&#8217;t be part of an optimal simplex, we remove it from the simplex.<br />
In the same way, we can check the area on the side of the AC line away from B, and if it is, decide if the origin is in the blue or the pink side of that area. Because B can no longer be part of an optimal simplex, we remove it instead.</p>
<p>If the origin is not in either the yellow, blue, or pink regions, then it must be in the central green region. If it is, we have surrounded the origin, thus detecting a collision.</p>
<p>Actually, we are only done in 2D. In the 3D case the origin may still lie above the plane or below the plane. The MollyRocket video covers it but I do not. It is an obvious continuation of the simplex evolution strategy, but now using a tetrahedron (a 3D simplex).</p>
<p>One important thing to note is that the MollyRocket video and these notes use ABC to denote the triangle normal. The cross product checks that use the triangle normal need to be the vector that points to the outside of the triangle (shown in the image above). The triangle normal ABC is computed as AB x AC. Draw a couple triangles to convince yourself no matter how you assign the points A,B and C, you will compute vectors pointing &#8220;out&#8221; in this fashion.</p>
<h1>EPA: What to do after a penetration is detected</h1>
<p>The second part of a physics engine, after collision detection, is collision resolution, where we use the information about the collision to correct the velocities of the objects. This is a considerable subject in its own right, but for now, I will limit the discussion to only the problem of &#8220;How do you use GJK when you want to know the contact point and collision depth?</p>
<p>When we detect a penetration (the case where we return true in the pseudocode, region (2,3) in our triangle simplex), then we must use another algorithm to find that information. One good one is Expanding Polytope Algorithm (EPA). Another is Separating Axis Test (SAT). SAT can actually replace GJK entirely, but it is not quite as fast and doesn&#8217;t scale well to 3D objects so it is less commonly used. I will cover neither of these here but will provide a link to an example of 2D EPA.</p>
<h1>Code listing</h1>
<p>I have included a <a href="http://www.joshuanewth.com/wp-content/uploads/2012/04/gjk.txt">gjk code listing</a>. It won&#8217;t compile to anything meaningful out of the box because it uses the Havok SDK but it should be fairly readable and demonstrate the concepts shown here.</p>
<h1>References</h1>
<p>I&#8217;ve discovered a lot of great resources online while researching my own implementation of GJK. The best explanation of GJK is at the MollyRocket link, but the others also contain useful information. There is a mostly correct GJK explanation at codezealot, but the author takes a couple of shortcuts like not checking his triangle normals that will trip the unwary observer. His simplex.getA(), .getB() and .getC() methods return the appropriate vertex to preserve the orientation of the triangle normal which is an inappropriate simplification in a pedagogical exercise such as this.</p>
<h1>GJK</h1>
<div><a href="http://www.win.tue.nl/~gino/solid/jgt98convex.pdf">http://www.win.tue.nl/~gino/solid/jgt98convex.pdf</a></div>
<div><a href="http://mollyrocket.com/849">http://mollyrocket.com/849</a></div>
<div><a href="http://www.codezealot.org/archives/88">http://www.codezealot.org/archives/88</a></div>
<h1>EPA</h1>
<div><a href="http://www.codezealot.org/archives/180">http://www.codezealot.org/archives/180</a></div>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2012/04/gjk.txt">gjk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2012/04/gjk-fast-convex-hull-collision-detection-in-2d-and-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thesis!</title>
		<link>http://www.joshuanewth.com/2012/02/thesis/</link>
		<comments>http://www.joshuanewth.com/2012/02/thesis/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 06:56:09 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=334</guid>
		<description><![CDATA[I&#8217;m so busy with jobhunting and consulting that I have been neglecting my thesis work. My project is to develop the physics and graphics engines sufficient for doing realtime simulation of &#8220;The Neverhood&#8221;, a claymation videogame from the 90s. My &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2012/02/thesis/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m so busy with jobhunting and consulting that I have been neglecting my thesis work. My project is to develop the physics and graphics engines sufficient for doing realtime simulation of <a href="http://en.wikipedia.org/wiki/The_Neverhood" title="The Neverhood">&#8220;The Neverhood&#8221;</a>, a claymation videogame from the 90s. My professor said &#8220;Start with a spinning box!&#8221; so I did. It&#8217;s a humble beginning, but it means my dev environment is set up and I&#8217;m thinking about OpenGL again.</p>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2012/02/RotatingBox.jpg"><img src="http://www.joshuanewth.com/wp-content/uploads/2012/02/RotatingBox-300x183.jpg" alt="" width="300" height="183" class="aligncenter size-medium wp-image-335" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2012/02/thesis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bloom Filters, or How I Learned PHP</title>
		<link>http://www.joshuanewth.com/2012/01/bloom-filters-or-how-i-learned-php/</link>
		<comments>http://www.joshuanewth.com/2012/01/bloom-filters-or-how-i-learned-php/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 21:49:20 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=305</guid>
		<description><![CDATA[I’ve completed almost all my degree requirements at SJSU and have started my two semester thesis. I’m still trying to narrow my thesis scope, but early on I picked out a good thesis advisor. This professor is in high demand &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2012/01/bloom-filters-or-how-i-learned-php/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I’ve completed almost all my degree requirements at SJSU and have started my two semester thesis. I’m still trying to narrow my thesis scope, but early on I picked out a good thesis advisor. This professor is in high demand among the graduate students, and no wonder: He’s extremely bright, an excellent instructor, and a <a href="http://www.yioop.com">prolific developer</a> himself. He’s also extremely busy, and could take only two more graduate students. Over the Christmas break he held a coding competition with the two top submissions getting the spots.</p>
<p>The challenge was the following: Given a URL, implement (in PHP) a hashing function that produces a fixed length, approximately unique key that can still identify some of the “tokens” that created it.</p>
<p><span id="more-305"></span></p>
<p>To understand the problem, consider the following:</p>
<p>www.my-yahoo.com contains the tokens {www, my, yahoo, com}</p>
<p>So $key = hash(“www.my-yahoo.com”);<br />
contains($key, “yahoo”); should respond TRUE but<br />
contains($key, “google”); should respond FALSE</p>
<p>It might make sense to use the URL as its own hash, but it is pretty easy to find URLs that don&#8217;t work well with this approach (either too long or with lots of small tokens).</p>
<p>My solution uses a 16-byte key composed of a 4-byte preamble and a 12-byte Bloom filter. The 4-byte preamble is the first 4 bytes of the md4 digest of the entire url. I used md4 because it comes standard in PHP and is fast compared with the other standard hashes. The cryptographic aspect is irrelevant except that a good cryptographic hash will also show a very good uniform distribution over the keyspace. For my application, this means I can take a substring of the digest and still have a good uniform distribution. It would make sense to use a faster, simpler hash like FNV but as I was just starting with PHP and nervous about my poor grasp of its weak bit manipulation abilities I decided to stick with something reliable.</p>
<p>The Bloom filter is more interesting. Once again, <a href="http://en.wikipedia.org/wiki/Bloom_filter">Wikipedia</a> is your friend, but the short version is that a Bloom filter is a bitfield, populated with the outputs of a number of different hash functions on each token inserted in to the Bloom. To add a token, one computes a hash or set of independent hashes for the token and then adds them in to the bitfield. As more tokens are added and more hash functions are used the bitfield “fills up” with ones, resulting in higher false positive rates because all the bits that would be set for a given token are already set by a combination of other tokens. That becomes a design tradeoff influencing the bitfield length, the number of hash functions used, and the number of tokens stored.</p>
<p>In the end, my keys are 16 bytes long, unique over the million URLs I tested, and have a pretty low false positive rate. I note in my writeup that although the general false positive rate is low, the worst Bloom filters have high error rates so in practice it makes sense to reduce the number of tokens added. I also tried using multiple different Blooms to increase the number of tokens contained (three 4-byte filters, two tokens each). As you can imagine, each filter is less &#8220;full&#8221;, but over the whole key the false positive rate goes up. I eventually discarded it.</p>
<p>It was interesting writing in PHP, something I had never done before. It was also a challenge to write a program that would really benefit from low level bit manipulation and strong typing in a language that doesn’t really make that sort of programming easy. PHP is sweet for string manipulation, though, and I ended up with a compromise I liked well enough. This compromise actually use a character to store each nibble (for conversion back and forth from strings to bytes), so it&#8217;s underlying representation is at least 32 bytes long. It should be straightfoward to pack these nibbles smaller, obviously, but I wanted to concentrate on getting the filter to work.</p>
<p>I’ve included my hashing class, my test apparatus, and my writeup. I&#8217;ll get around to adding some relevant links below as well. Be advised: the test code takes a long time to run and consumes a ton of memory, as I made my life simpler by keeping everything in memory, rather than sorting and merging on disk.</p>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2012/01/php_bloom1.zip">php_bloom</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2012/01/bloom-filters-or-how-i-learned-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back in action!</title>
		<link>http://www.joshuanewth.com/2012/01/back-in-action/</link>
		<comments>http://www.joshuanewth.com/2012/01/back-in-action/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 19:07:29 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=286</guid>
		<description><![CDATA[If you are regular readers of this site (me, my mom, and my fiancee) then you have noticed that the site has been down for a month! It was caused by what I fear is a rather common occurence: Some &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2012/01/back-in-action/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>If you are regular readers of this site (me, my mom, and my fiancee) then you have noticed that the site has been down for a month! It was caused by what I fear is a rather common occurence: Some WordPress plugin. The delay in repairing it was caused by school!</p>
<p>Now that I&#8217;m back on the job hunt, I wanted to get my &#8220;web presence&#8221; back up so I decided to spend some time fixing the site. This involved tinkering in an ignorant and dangerous way with WordPress and then calling my hosting service where &#8220;Justin&#8221; (I didn&#8217;t quite catch his name) told me that I needed to upgrade my account to be eligible for helpdesk support and then went ahead to find and fix my problem anyhow. So, thanks Justin! And if anyone needs a bangin&#8217; web hosting (and wordpress troubleshooting) service, I am one satisfied <a href="http://www.lunarpages.com" title="Lunarpages">Lunarpages</a> customer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2012/01/back-in-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another old Halloween costume of which I am inordinately proud.</title>
		<link>http://www.joshuanewth.com/2011/09/another-old-halloween-costume-of-which-i-am-inordinately-proud/</link>
		<comments>http://www.joshuanewth.com/2011/09/another-old-halloween-costume-of-which-i-am-inordinately-proud/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 21:05:23 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=268</guid>
		<description><![CDATA[I was studying compilers and Babbage and got a bit obsessed with &#8220;Victorian Computing&#8221;. So I made a clockwork man outfit.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center"><!--[vimeo width="300" height="300"]http://vimeo.com/16322210[/vimeo]--><br />
<p><a href="http://www.joshuanewth.com/2011/09/another-old-halloween-costume-of-which-i-am-inordinately-proud/"><em>Click here to view the embedded video.</em></a></p></p>
<p>I was studying compilers and Babbage and got a bit obsessed with &#8220;Victorian Computing&#8221;. So I made a clockwork man outfit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2011/09/another-old-halloween-costume-of-which-i-am-inordinately-proud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SDL on Mac OSX in Eclipse and XCode</title>
		<link>http://www.joshuanewth.com/2011/09/using-sdl-on-mac-osx-in-eclipse/</link>
		<comments>http://www.joshuanewth.com/2011/09/using-sdl-on-mac-osx-in-eclipse/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 07:59:05 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=173</guid>
		<description><![CDATA[I spent a long time doing this recently so I am going to make it as simple as possible. The first and most important step is: IGNORE ALL THE TUTORIALS ON THE WEB. People want you to set up Eclipse &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2011/09/using-sdl-on-mac-osx-in-eclipse/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p style="text-align: left">I spent a long time doing this recently so I am going to make it as simple as possible. The first and most important step is:</p>
<p style="text-align: center">IGNORE ALL THE TUTORIALS ON THE WEB.</p>
<p style="text-align: left">People want you to set up Eclipse to look for X11 binaries, or to install stuff with MacPorts, etc, etc. TERRIBLE. Do this instead.<br />
<span id="more-173"></span> First we&#8217;ll get Xcode up and running.</p>
<ol>
<li>Go to http://www.libsdl.org/download-1.2.php</li>
<li>Download the latest Mac OSX dmg.</li>
<li>And the dev tools. (EDIT: With the recent MacOS version, the SDL group is unable to provide the dev tools for the Mac. They no longer provide the XCode projects but the Eclipse setup still works).</li>
<li>Read the READMEs of course, but the following steps will work.</li>
<li>As the SDL README says, Copy the &#8220;SDL.framework&#8221; to &#8220;/Library/Frameworks&#8221;. Note the README will help you to get it running if you don&#8217;t have admin privileges but as far as I&#8217;m concerned you&#8217;re screwed.</li>
<li>As the SDL-DEV README (more or less) says, Copy
<pre>SDL-DEV/Documentation Docs/XcodeDocSet/org.libsdl.libsdl.docset</pre>
<p>to</p>
<pre>/Library/Developer/Shared/Documentation/DocSets</pre>
</li>
<li>Copy the Xcode templates (not the containing &#8220;TemplatesForSnow&#8230;&#8221; folder) to a folder named &#8220;SDL&#8221;.</li>
<li>Copy this &#8220;SDL&#8221; folder to
<pre>/Library/Developer/Shared/Xcode/Project Templates/Application/XcodeTemplates/</pre>
</li>
<li>Open Xcode. Go to &#8220;Create new Project&#8221;, select &#8220;SDL OpenGL app&#8221; from &#8220;Other&#8221;</li>
<li>Xcode will start a project with some example code in it. Hit &#8220;Build and Run&#8221;. It should fail, complaining about &#8220;an SDK with the name 10.4&#8243;. Now do this:</li>
</ol>
<div id="attachment_195" class="wp-caption aligncenter" style="width: 480px"><a href="http://www.joshuanewth.com/wp-content/uploads/2011/09/xcode_build_err1.png"><img class="size-large wp-image-195" src="http://www.joshuanewth.com/wp-content/uploads/2011/09/xcode_build_err1-1024x519.png" alt="" width="470" height="238" /></a><p class="wp-caption-text">The initial build will fail until you select &quot;10.6&quot; in the pulldown menu</p></div>
<ol>
<li>Now hit &#8220;Build and Run&#8221;.</li>
</ol>
<p>It should run and show you some OpenGL cetaceans swimming around. Awesome!</p>
<p>Now back to work on Eclipse.</p>
<ol>
<li>Open Eclipse.</li>
<li>Create a new C/C++ Project. I named my project &#8220;SDL_Test&#8221;. The ABSOLUTE path to this location is important. My absolute path here is:
<pre>/Users/mrfurious/eclipse/SDL_Test/</pre>
</li>
<li>Right-click on the project and go to &#8220;Import&#8221;.</li>
<li>Import the SDLMain.m and SDLMain.h files from your SDL OpenGL project template or from your Xcode SDL project. These have to be included with EVERY SDL project you do. If you were following along in the first part, they are also at:
<pre>/Library/Developer/Shared/Xcode/Project Templates/Application/XcodeTemplates/SDL/SDL OpenGL Application</pre>
</li>
<li>For the purposes of this tutorial, grab all the .c and .h files as well (ie the stuff in the Atlantis folder).</li>
</ol>
<p>Apple has organized all the important stuff that can happen in computers in to Frameworks, which is just a directory that puts headers and binaries (precompiled libraries) in the same place. For SDL, you need OpenGL, GLUT, Cocoa and SDL. All this stuff comes built-in. Don&#8217;t install anything with MacPorts. Don&#8217;t go adding &#8220;/usr/X11R6&#8230;.&#8221; to your path.</p>
<ol>
<li>Right-click on the project. Select &#8220;Properties&#8221;. Go to &#8220;C/C++ Build&#8221;. Go to &#8220;Settings&#8221;.</li>
<li>At the top of the settings window where it says &#8220;Configurations:&#8221;. Set the chooser to &#8220;All Configurations&#8221;.</li>
<li>In &#8220;MacOS X C++ Linker &gt; Libraries&#8221;, add your absolute path to the &#8220;Library search path (-L)&#8221; window. For me this was:
<pre>/Users/mrfurious/eclipse/SDL_Test</pre>
</li>
<li>In the linker arguments line, write
<pre>-framework openGL -framework SDL -framework Cocoa -framework GLUT /Users/mrfurious/eclipse/SDL_Test/SDLMain.m</pre>
</li>
</ol>
<p>Here&#8217;s a picture:<a href="http://www.joshuanewth.com/wp-content/uploads/2011/09/SDL_Linker-line.png"><img class="aligncenter size-large wp-image-208" src="http://www.joshuanewth.com/wp-content/uploads/2011/09/SDL_Linker-line-1024x646.png" alt="" width="470" height="296" /></a><br />
Now your linker knows where to look for the binaries it needs at linking time. Now we tell gcc and g++ where to find the headers.</p>
<ol>
<li>Add this text to both the GCC C Compiler and the GCC C++ Compiler &#8220;Includes&#8221; window:</li>
</ol>
<pre>/Library/Frameworks/SDL.framework/Versions/A/Headers
/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
/System/Library/Frameworks/GLUT.framework/Versions/A/Headers
/System/Library/Frameworks/Cocoa.framework/Versions/A/Headers</pre>
<p>Your setup should now look like:<br />
<a href="http://www.joshuanewth.com/wp-content/uploads/2011/09/c++settings.png"><img class="aligncenter size-full wp-image-215" src="http://www.joshuanewth.com/wp-content/uploads/2011/09/c++settings.png" alt="" width="940" height="495" /></a><br />
And<br />
<a href="http://www.joshuanewth.com/wp-content/uploads/2011/09/gccsettings.png"><img class="aligncenter size-full wp-image-216" src="http://www.joshuanewth.com/wp-content/uploads/2011/09/gccsettings.png" alt="" width="873" height="490" /></a></p>
<ol>
<li>Click &#8220;Ok&#8221;.</li>
<li>Almost there! One last thing. This code is written as if the libraries were tucked away in folders called &#8220;GLUT&#8221; and &#8220;GL&#8221; and &#8220;OpenGL&#8221; so you had to include headers with directives like
<pre>#include &lt;GLUT/glut.h&gt;</pre>
<p>but with Frameworks, there is none of that. We need to clean up the source files a bit.</li>
<li>Go to atlantis.h. Add
<pre>#include &lt;gl.h&gt;</pre>
</li>
<li>Alternatively, you can add that to each of the &#8220;atlantis.c&#8221;, &#8220;whale.c&#8221;, &#8230; etc, but since they all include &#8220;atlantis.h&#8221; then adding it to that file alone will propagate the change through the codebase.</li>
<li>Go through each of the &#8220;.c&#8221; files and change instances of
<pre>#include &lt;GLUT/glut.h&gt; to #include &lt;glut.h&gt;</pre>
<p>and instances of</p>
<pre>#include &lt;OpenGL/opengl.h&gt; to #include &lt;opengl.h&gt;</pre>
</li>
<li>DO NOT CHANGE SDLMain.h.</li>
<li>Strangely enough, in SDLMain.m I had to change the &#8220;#include &#8220;SDL.h&#8221; to &#8220;#include &#8220;SDL/SDL.h&#8221;.</li>
<li>Click &#8220;Build&#8221; and then &#8220;Run&#8221;. Behold, Leviathan!</li>
</ol>
<p><a href="http://www.joshuanewth.com/wp-content/uploads/2011/09/SDL-Whales.png"><img class="aligncenter size-medium wp-image-224" src="http://www.joshuanewth.com/wp-content/uploads/2011/09/SDL-Whales-300x235.png" alt="" width="300" height="235" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2011/09/using-sdl-on-mac-osx-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Iron Gym Total Upper Body Workout (Non Extreme Edition)</title>
		<link>http://www.joshuanewth.com/2011/07/iron-gym-total-upper-body-workout-non-extreme-edition/</link>
		<comments>http://www.joshuanewth.com/2011/07/iron-gym-total-upper-body-workout-non-extreme-edition/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 18:04:32 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joshuanewth.com/?p=157</guid>
		<description><![CDATA[I recently purchased a pull up bar to get chiseled in preparation for my photo shoot in the MindTribe Christmas calendar. Tim, our director of Electrical Engineering, took a look at the contraption and concluded the load is borne solely &#8230;<p class="read-more"><a href="http://www.joshuanewth.com/2011/07/iron-gym-total-upper-body-workout-non-extreme-edition/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I recently purchased a pull up bar to get chiseled in preparation for my photo shoot in the MindTribe Christmas calendar.<br />
Tim, our director of Electrical Engineering, took a look at the contraption and concluded the load is borne solely on the door trim, a design choice of which he disapproved. This didn’t seem quite right to me, and it nagged enough to get me out of bed early Saturday morning to figure it out.</p>
<p><span id="more-157"></span>As an aside, whenever I think about the way my parents looked on the day I informed them I needed a 5<sup>th</sup> year at my very prestigious, very expensive university to complete my engineering degree I have no problem whatsoever getting out of bed early Saturday to do math. Thanks, Mom and Dad!</p>
<p>Here is a graphic showing how the <a title="Iron Gym" href="http://www.amazon.com/Iron-Total-Upper-Body-Workout/dp/B001EJMS6K/ref=sr_1_1?s=exercise-and-fitness&amp;ie=UTF8&amp;qid=1311870780&amp;sr=1-1">Iron Gym</a> hangs in a doorframe. The doorframe is rendered transparent to show the pink cross beam hanging on the internal door trim, while the yellow bar rests against the outside. You hang on to the straight section of the green &#8220;handles&#8221; to do pull ups.</p>
<div id="attachment_158" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.joshuanewth.com/wp-content/uploads/2011/07/2011-07-28_000014.png"><img class="size-medium wp-image-158 " src="http://www.joshuanewth.com/wp-content/uploads/2011/07/2011-07-28_000014-300x197.png" alt="" width="300" height="197" /></a><p class="wp-caption-text">Iron Gym Total Upper Body Workout (Non Extreme Edition)</p></div>
<p>Here is a cross section with the relevant loads and distances labeled:</p>
<div id="attachment_161" class="wp-caption aligncenter" style="width: 308px"><a href="http://www.joshuanewth.com/wp-content/uploads/2011/07/2011-07-28_0000131.png"><img class="size-medium wp-image-161 " src="http://www.joshuanewth.com/wp-content/uploads/2011/07/2011-07-28_0000131-298x300.png" alt="" width="298" height="300" /></a><p class="wp-caption-text">Iron Gym Free Body Diagram</p></div>
<p>When we sum the moments around 0 (the black dot) we see the following:</p>
<p>W*L3 – Rx*L2-Ry*L1 = 0</p>
<p>We also know Ry is the frictional force generated by the normal load Rx:</p>
<p>Ry = u*Rx</p>
<p>where u is the coefficient of friction for “rubber on wood&#8221;.</p>
<p>We also sum the forces in the Y direction to see:</p>
<p>Oy + Ry &#8211; W = 0</p>
<p>We substitute for Rx and solve the first equation for Ry:</p>
<p>Ry = W*L3 / (L1 + L2/u)</p>
<p>Plug in some rough numbers:</p>
<p>W = 1000N<br />
u = 0.5<br />
L1 = .20m<br />
L2 = .20m<br />
L3 = .25m</p>
<p>And observe that Ry is roughly 416N, or ~40% (see what I did there?) of the overall weight W. We may wish to vary the estimate for the frictional coefficient, or to include the moment from the force in the x-axis on the pink cross beam, but it turns out they don&#8217;t influence the answer very much. From this analysis we may conclude that although there is a lot of weight on the door trim, not all of it is borne there. A more useful analysis might calculate allowable loads on a residential door trim but that isn&#8217;t necessary to prove Tim wrong! I&#8217;ll stop here, then, and savor this rare moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuanewth.com/2011/07/iron-gym-total-upper-body-workout-non-extreme-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
