<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.intellivision.us/index.php?action=history&amp;feed=atom&amp;title=Dist_fast.asm</id>
		<title>Dist fast.asm - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.intellivision.us/index.php?action=history&amp;feed=atom&amp;title=Dist_fast.asm"/>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;action=history"/>
		<updated>2026-04-17T14:59:28Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;diff=14779&amp;oldid=prev</id>
		<title>Mr z: Protected &quot;Dist fast.asm&quot; ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite))</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;diff=14779&amp;oldid=prev"/>
				<updated>2010-12-04T08:16:50Z</updated>
		
		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/index.php/Dist_fast.asm&quot; title=&quot;Dist fast.asm&quot;&gt;Dist fast.asm&lt;/a&gt;&amp;quot; ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite))&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 08:16, 4 December 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;diff=2954&amp;oldid=prev</id>
		<title>Mr z: /* Notes */</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;diff=2954&amp;oldid=prev"/>
				<updated>2008-09-06T22:20:19Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Notes&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:20, 6 September 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l30&quot; &gt;Line 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 30:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#FF0000&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;7px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#FF0000&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;7px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#FF00FF&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;8px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#FF00FF&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;8px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/TABLE&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/TABLE&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;gt;&amp;lt;/CENTER&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;As you can see, the error stays rather proportional to the distance, and in general, DIST_FAST tends to over-estimate rather than under-estimate distance.&amp;#160; For most purposes, such as having one sprite follow another by setting velocity to (&amp;amp;Delta;X / dist, &amp;amp;Delta;Y / dist), this error will hardly be noticeable.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;As you can see, the error stays rather proportional to the distance, and in general, DIST_FAST tends to over-estimate rather than under-estimate distance.&amp;#160; For most purposes, such as having one sprite follow another by setting velocity to (&amp;amp;Delta;X / dist, &amp;amp;Delta;Y / dist), this error will hardly be noticeable.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;diff=2953&amp;oldid=prev</id>
		<title>Mr z: /* Notes */</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;diff=2953&amp;oldid=prev"/>
				<updated>2008-09-06T22:20:08Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Notes&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:20, 6 September 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l15&quot; &gt;Line 15:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 15:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Notes =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Notes =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This function is based on C code found in Graphics Gems IV.&amp;#160; The function computes an approximation of Euclidean distance, accurate to within 4%, and it does so very quickly--under 180 cycles!&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This function is based on C code found in Graphics Gems IV.&amp;#160; The function computes an approximation of Euclidean distance, accurate to within 4%, and it does so very quickly--under 180 cycles!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;The following graphs show the error characteristic for DIST_FAST. &lt;/ins&gt; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Each pixel shows the error, in absolute distance, in the distance computed to that point from (0, 0).&amp;#160; The graph on the left shows the magnitude, and the graph on the right shows the sign.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;CENTER&amp;gt;&amp;lt;TABLE BORDER&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TH&amp;gt;Error Magnitude&amp;lt;/TH&amp;gt;&amp;lt;TH COLSPAN=2&amp;gt;Key&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;&amp;amp;nbsp;&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Error Sign&amp;lt;/TH&amp;gt;&amp;lt;TH COLSPAN=2&amp;gt;Key&amp;lt;/TH&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD ROWSPAN=10&amp;gt;[[Image:Dfmag.gif|320px]]&amp;lt;/TD&amp;gt;&amp;lt;TD BGCOLOR=#000000&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;0px&amp;lt;/TD&amp;gt;&amp;lt;TD ROWSPAN=10&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD ROWSPAN=10&amp;gt;[[Image:Dfsgn.gif|320px]]&amp;lt;/TD&amp;gt;&amp;lt;TD BGCOLOR=#000000 ROWSPAN=5&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD ROWSPAN=5&amp;gt;DIST_FAST&amp;lt;BR /&amp;gt;underestimates&amp;lt;BR /&amp;gt;distance&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#0000C0&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;1px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#00C000&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;2px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#C0C000&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;3px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#C00000 ROWSPAN=2&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD ROWSPAN=2&amp;gt;4px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#FFFFFF ROWSPAN=5&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD ROWSPAN=5&amp;gt;DIST_FAST&amp;lt;br /&amp;gt;overestimates&amp;lt;br /&amp;gt;distance&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#00FF00&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;5px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#FFFF00&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;6px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#FF0000&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;7px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;TR&amp;gt;&amp;lt;TD BGCOLOR=#FF00FF&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;8px&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/TABLE&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;As you can see, the error stays rather proportional to the distance, and in general, DIST_FAST tends to over-estimate rather than under-estimate distance.&amp;#160; For most purposes, such as having one sprite follow another by setting velocity to (&amp;amp;Delta;X / dist, &amp;amp;Delta;Y / dist), this error will hardly be noticeable.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Source Code =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Source Code =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;diff=2950&amp;oldid=prev</id>
		<title>Mr z at 21:24, 6 September 2008</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Dist_fast.asm&amp;diff=2950&amp;oldid=prev"/>
				<updated>2008-09-06T21:24:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Programming]] [[Category:Library]]&lt;br /&gt;
&lt;br /&gt;
= Functions Provided =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;CENTER&amp;gt;&amp;lt;TABLE BORDER&amp;gt;&amp;lt;TR&amp;gt;&amp;lt;TH&amp;gt;Entry point&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Function provided&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Notes&amp;lt;/TH&amp;gt;&amp;lt;/TR&amp;gt;&lt;br /&gt;
&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;DIST_FAST&amp;lt;/TD&amp;gt;&amp;lt;TD ROWSPAN=2&amp;gt;Find the approximate Euclidean distance between two points&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Two pairs of (x, y) coordinates passed in registers&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;br /&gt;
&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;DIST_FAST.1&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Instead of raw coordinates, abs(&amp;amp;Delta;X) and abs(&amp;amp;Delta;Y) passed in registers.&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&amp;lt;/TABLE&amp;gt;&amp;lt;/CENTER&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
See source code below for calling convention.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
(todo... please contribute!)&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
&lt;br /&gt;
This function is based on C code found in Graphics Gems IV.  The function computes an approximation of Euclidean distance, accurate to within 4%, and it does so very quickly--under 180 cycles!  &lt;br /&gt;
&lt;br /&gt;
= Source Code =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
;* ======================================================================== *;&lt;br /&gt;
;*  These routines are placed into the public domain by their author.  All  *;&lt;br /&gt;
;*  copyright rights are hereby relinquished on the routines and data in    *;&lt;br /&gt;
;*  this file.  -- Joseph Zbiciak, 2008                                     *;&lt;br /&gt;
;* ======================================================================== *;&lt;br /&gt;
&lt;br /&gt;
;; ======================================================================== ;;&lt;br /&gt;
;;  DIST_FAST Approximate the distance between two points to 4% error.      ;;&lt;br /&gt;
;;  DIST_FAST.1 Alternate entry point                                       ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  AUTHOR                                                                  ;;&lt;br /&gt;
;;      Joseph Zbiciak &amp;lt;intvnut AT gmail.com&amp;gt;                               ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  REVISION HISTORY                                                        ;;&lt;br /&gt;
;;      22-Apr-2002 Initial Revision                                        ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  INPUTS for DIST_FAST                                                    ;;&lt;br /&gt;
;;      R0    Coordinate x0                                                 ;;&lt;br /&gt;
;;      R1    Coordinate y0                                                 ;;&lt;br /&gt;
;;      R2    Coordinate x1                                                 ;;&lt;br /&gt;
;;      R3    Coordinate y1                                                 ;;&lt;br /&gt;
;;      R5    Return address                                                ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  INPUTS for DIST_FAST.1                                                  ;;&lt;br /&gt;
;;      R2    Absolute value of delta-X (eg. abs(x0 - x1))                  ;;&lt;br /&gt;
;;      R3    Absolute value of delta-Y (eg. abs(y0 - y1))                  ;;&lt;br /&gt;
;;      R5    Return address                                                ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  OUTPUTS                                                                 ;;&lt;br /&gt;
;;      R0    Unchanged                                                     ;;&lt;br /&gt;
;;      R1    Trashed                                                       ;;&lt;br /&gt;
;;      R2    Trashed                                                       ;;&lt;br /&gt;
;;      R3    Approximate Euclidean distance from (x0, y0) to (x1, y1).     ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  NOTES                                                                   ;;&lt;br /&gt;
;;      This returns a value which is approximately sqrt(dx**2 + dy**2),    ;;&lt;br /&gt;
;;      within 4%.  This should be sufficient for most applications.        ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;      The code accepts unsigned 16-bit values for the incoming            ;;&lt;br /&gt;
;;      coordinates, and should correctly calculate abs(x0 - x1)            ;;&lt;br /&gt;
;;      and abs(y0 - y1) for the full 16-bit range.                         ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;      The output should have the same dynamic range as the inputs.        ;;&lt;br /&gt;
;;      Thus, if the inputs are in an 8-bit range, so will be the           ;;&lt;br /&gt;
;;      output.  If the inputs are in a 16-bit range, so is the output.     ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;      Although the arguments list R0 and R2 as the X coordinates          ;;&lt;br /&gt;
;;      and R1 and R3 as the Y coordinates, these assignments may be        ;;&lt;br /&gt;
;;      swapped.  (eg. R1 and R3 are X coordinates, R0 and R2 are Y         ;;&lt;br /&gt;
;;      coordinates.)  Euclidean distance doesn't change when you rotate    ;;&lt;br /&gt;
;;      the page 90 degrees or flip it over.  :-)                           ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  SOURCE                                                                  ;;&lt;br /&gt;
;;      Graphics Gems IV (see C code below)                                 ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;      C code from the article                                             ;;&lt;br /&gt;
;;      &amp;quot;Fast Linear Approximations of Euclidean Distance in                ;;&lt;br /&gt;
;;      Higher Dimensions&amp;quot; by Yoshikazu Ohashi, yoshi@cognex.com            ;;&lt;br /&gt;
;;      in &amp;quot;Graphics Gems IV&amp;quot;, Academic Press, 1994                         ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;      /* 2-D Euclidean distance approximation          */                 ;;&lt;br /&gt;
;;      /* c1 = 123/128, c2 = 51/128 and max(e) = 4.0%   */                 ;;&lt;br /&gt;
;;      int veclen2 (int ix, int iy)                                        ;;&lt;br /&gt;
;;      {                                                                   ;;&lt;br /&gt;
;;          int  t;                                                         ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;          ix= (ix&amp;lt;0 ? -ix : ix);   /* absolute values */                  ;;&lt;br /&gt;
;;          iy= (iy&amp;lt;0 ? -iy : iy);                                          ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;          if(ix&amp;lt;iy)        /* swap ix and iy if (ix &amp;lt; iy) */              ;;&lt;br /&gt;
;;          {                /* See Wyvill (G1, 436)        */              ;;&lt;br /&gt;
;;              ix=ix^iy;                                                   ;;&lt;br /&gt;
;;              iy=ix^iy;                                                   ;;&lt;br /&gt;
;;              ix=ix^iy;                                                   ;;&lt;br /&gt;
;;          }                                                               ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;          t = iy + (iy&amp;gt;&amp;gt;1);                                               ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;          /* return (123 * ix + 51 * iy) / 128; */                        ;;&lt;br /&gt;
;;          return (ix - (ix&amp;gt;&amp;gt;5) - (ix&amp;gt;&amp;gt;7)  + (t&amp;gt;&amp;gt;2) + (t&amp;gt;&amp;gt;6));             ;;&lt;br /&gt;
;;      }                                                                   ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  CODESIZE                                                                ;;&lt;br /&gt;
;;      28 words                                                            ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  CYCLES                                                                  ;;&lt;br /&gt;
;;      150 to 178 cycles for DIST_FAST.                                    ;;&lt;br /&gt;
;;      124 to 140 cycles for DIST_FAST.1.                                  ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;; ======================================================================== ;;&lt;br /&gt;
&lt;br /&gt;
DIST_FAST   PROC&lt;br /&gt;
            SUBR    R0,     R2  ;   6&lt;br /&gt;
            ADCR    PC          ;   7 Skip negr if R2 was greater than R0&lt;br /&gt;
            NEGR    R2          ;   6&lt;br /&gt;
                                ;----&lt;br /&gt;
                                ;  13 best case&lt;br /&gt;
                                ;  19 worst case&lt;br /&gt;
&lt;br /&gt;
            SUBR    R1,     R3  ;   6&lt;br /&gt;
            ADCR    PC          ;   7 Skip negr if R3 was greater than R1&lt;br /&gt;
            NEGR    R3          ;   6&lt;br /&gt;
                                ;----&lt;br /&gt;
                                ;  26 best case&lt;br /&gt;
                                ;  38 worst case&lt;br /&gt;
&lt;br /&gt;
@@1:        CMPR    R2,     R3  ;   6  Put larger value in R3&lt;br /&gt;
            BC      @@no_swap   ; 9/7 &lt;br /&gt;
            XORR    R2,     R3  ;   6 \&lt;br /&gt;
            XORR    R3,     R2  ;   6  |-- Swap R2 and R3 if necessary.&lt;br /&gt;
            XORR    R2,     R3  ;   6 /&lt;br /&gt;
                                ;----&lt;br /&gt;
                                ;  41 best case&lt;br /&gt;
                                ;  69 worst case&lt;br /&gt;
@@no_swap:&lt;br /&gt;
            MOVR    R2,     R1  ;   6&lt;br /&gt;
            SLR     R1,     1   ;   6&lt;br /&gt;
            ADDR    R1,     R2  ;   6 t = iy + (iy &amp;gt;&amp;gt; 1)&lt;br /&gt;
&lt;br /&gt;
            MOVR    R3,     R1  ;   6&lt;br /&gt;
            SLR     R1,     2   ;   8&lt;br /&gt;
            SLR     R1,     2   ;   8&lt;br /&gt;
            SLR     R1,     1   ;   6 R1 = ix &amp;gt;&amp;gt; 5&lt;br /&gt;
            SUBR    R1,     R3  ;   6 R3 = ix - (ix&amp;gt;&amp;gt;5)&lt;br /&gt;
            SLR     R1,     2   ;   8 R1 = ix &amp;gt;&amp;gt; 7&lt;br /&gt;
            SUBR    R1,     R3  ;   6 R3 = ix - (ix&amp;gt;&amp;gt;5) - (ix&amp;gt;&amp;gt;7)&lt;br /&gt;
            SLR     R2,     2   ;   8 R2 = t &amp;gt;&amp;gt; 2&lt;br /&gt;
            ADDR    R2,     R3  ;   6 R3 = ix - (ix&amp;gt;&amp;gt;5) - (ix&amp;gt;&amp;gt;7) + (t&amp;gt;&amp;gt;2)&lt;br /&gt;
            SLR     R2,     2   ;   8&lt;br /&gt;
            SLR     R2,     2   ;   8 R2 = t &amp;gt;&amp;gt; 6&lt;br /&gt;
            ADDR    R2,     R3  ;   6 R3 = ix - (ix&amp;gt;&amp;gt;5) - (ix&amp;gt;&amp;gt;7) + (t&amp;gt;&amp;gt;2) + (t&amp;gt;&amp;gt;6)&lt;br /&gt;
                                ;----&lt;br /&gt;
                                ; 143 best case&lt;br /&gt;
                                ; 171 worst case&lt;br /&gt;
&lt;br /&gt;
            JR      R5          ;   7&lt;br /&gt;
                                ;----&lt;br /&gt;
                                ; 150 best case&lt;br /&gt;
                                ; 178 worst case&lt;br /&gt;
            ENDP&lt;br /&gt;
&lt;br /&gt;
;; ======================================================================== ;;&lt;br /&gt;
;;  End of File:  dist_fast.asm                                             ;;&lt;br /&gt;
;; ======================================================================== ;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	</feed>