<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: A quick note on line and segment intersection (as3)</title>
	<atom:link href="http://blog.controul.com/2009/05/line-segment-intersection/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.controul.com/2009/05/line-segment-intersection/</link>
	<description>Elaborations on flash.</description>
	<lastBuildDate>Fri, 23 Sep 2011 08:04:26 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: James</title>
		<link>http://blog.controul.com/2009/05/line-segment-intersection/comment-page-1/#comment-273</link>
		<dc:creator>James</dc:creator>
		<pubDate>Mon, 07 Feb 2011 07:07:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.controul.com/?p=292#comment-273</guid>
		<description>I have done some performance tests on the original, this version, and the version below. I can&#039;t remember where I found this code, but it seems to be slightly more efficient than Keith&#039;s one when an intersection is found. If no intersection is found, it&#039;s more than twice as fast.

public function intersectsLine(A:Point, B:Point, E:Point, F:Point):Point
		{
			var bx:int = B.x - A.x; 
			var by:int = B.y - A.y; 
			var dx:int = F.x - E.x; 
			var dy:int = F.y - E.y;
			var b_dot_d_perp:Number = bx * dy - by * dx;
			if(b_dot_d_perp == 0) {
				return null;
			}
			var cx:int = E.x - A.x;
			var cy:int = E.y - A.y;
			var t:Number = (cx * dy - cy * dx) / b_dot_d_perp;
			if(t  1) {
				return null;
			}
			var u:Number = (cx * by - cy * bx) / b_dot_d_perp;
			if(u  1) { 
				return null;
			}
			return new Point(A.x+t*bx, A.y+t*by);
		}</description>
		<content:encoded><![CDATA[<p>I have done some performance tests on the original, this version, and the version below. I can&#8217;t remember where I found this code, but it seems to be slightly more efficient than Keith&#8217;s one when an intersection is found. If no intersection is found, it&#8217;s more than twice as fast.</p>
<p>public function intersectsLine(A:Point, B:Point, E:Point, F:Point):Point<br />
		{<br />
			var bx:int = B.x &#8211; A.x;<br />
			var by:int = B.y &#8211; A.y;<br />
			var dx:int = F.x &#8211; E.x;<br />
			var dy:int = F.y &#8211; E.y;<br />
			var b_dot_d_perp:Number = bx * dy &#8211; by * dx;<br />
			if(b_dot_d_perp == 0) {<br />
				return null;<br />
			}<br />
			var cx:int = E.x &#8211; A.x;<br />
			var cy:int = E.y &#8211; A.y;<br />
			var t:Number = (cx * dy &#8211; cy * dx) / b_dot_d_perp;<br />
			if(t  1) {<br />
				return null;<br />
			}<br />
			var u:Number = (cx * by &#8211; cy * bx) / b_dot_d_perp;<br />
			if(u  1) {<br />
				return null;<br />
			}<br />
			return new Point(A.x+t*bx, A.y+t*by);<br />
		}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: basics in generative art 7 : USEFUL TOOLS &#171; HIDIHO!</title>
		<link>http://blog.controul.com/2009/05/line-segment-intersection/comment-page-1/#comment-267</link>
		<dc:creator>basics in generative art 7 : USEFUL TOOLS &#171; HIDIHO!</dc:creator>
		<pubDate>Wed, 29 Dec 2010 22:31:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.controul.com/?p=292#comment-267</guid>
		<description>[...] I found it and/or who wrote it, I usually mention it. anyway, at least Keith Peters, Keith Hair and Hristo Dachev have to be [...]</description>
		<content:encoded><![CDATA[<p>[...] I found it and/or who wrote it, I usually mention it. anyway, at least Keith Peters, Keith Hair and Hristo Dachev have to be [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: basics in generative art 5 : join the dots &#171; HIDIHO!</title>
		<link>http://blog.controul.com/2009/05/line-segment-intersection/comment-page-1/#comment-266</link>
		<dc:creator>basics in generative art 5 : join the dots &#171; HIDIHO!</dc:creator>
		<pubDate>Mon, 27 Dec 2010 17:21:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.controul.com/?p=292#comment-266</guid>
		<description>[...] the intersection method was done by Keith Hair and improved by Hristo Dachev. [...]</description>
		<content:encoded><![CDATA[<p>[...] the intersection method was done by Keith Hair and improved by Hristo Dachev. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hristo</title>
		<link>http://blog.controul.com/2009/05/line-segment-intersection/comment-page-1/#comment-230</link>
		<dc:creator>hristo</dc:creator>
		<pubDate>Thu, 17 Jun 2010 10:28:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.controul.com/?p=292#comment-230</guid>
		<description>Hey Jack,
I see your point - I&#039;ll look into it when I have some time, but sounds like bigtime rounding errors.
What sort of app runs into this kind of trouble ???? :)
Thanks for the comment</description>
		<content:encoded><![CDATA[<p>Hey Jack,<br />
I see your point &#8211; I&#8217;ll look into it when I have some time, but sounds like bigtime rounding errors.<br />
What sort of app runs into this kind of trouble ???? :)<br />
Thanks for the comment</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack</title>
		<link>http://blog.controul.com/2009/05/line-segment-intersection/comment-page-1/#comment-202</link>
		<dc:creator>Jack</dc:creator>
		<pubDate>Fri, 28 May 2010 05:25:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.controul.com/?p=292#comment-202</guid>
		<description>nice function! I&#039;ve used it in my application, and found a small bug with (almost) horizontal and vertical line segments:

where
A = (3.0999999999999996, 3.1499999999999995)
B = (5, 3.15)

E = (3.1499999999999995, 5.8500000000000005)
F = (3.1499999999999995, 3.0999999999999996)

and
ip = (3.1499999999999995, 3.149999999999999)

this line executes and returns null:
if ( ( A.y &lt; B.y ) ? ip.y &lt;A&gt; B.y : ip.y &gt; A.y &#124;&#124; ip.y &lt;B&gt; A.y</description>
		<content:encoded><![CDATA[<p>nice function! I&#8217;ve used it in my application, and found a small bug with (almost) horizontal and vertical line segments:</p>
<p>where<br />
A = (3.0999999999999996, 3.1499999999999995)<br />
B = (5, 3.15)</p>
<p>E = (3.1499999999999995, 5.8500000000000005)<br />
F = (3.1499999999999995, 3.0999999999999996)</p>
<p>and<br />
ip = (3.1499999999999995, 3.149999999999999)</p>
<p>this line executes and returns null:<br />
if ( ( A.y &lt; B.y ) ? ip.y <a> B.y : ip.y &gt; A.y || ip.y <b> A.y</b></a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathieu Gosselin</title>
		<link>http://blog.controul.com/2009/05/line-segment-intersection/comment-page-1/#comment-98</link>
		<dc:creator>Mathieu Gosselin</dc:creator>
		<pubDate>Sun, 06 Sep 2009 11:27:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.controul.com/?p=292#comment-98</guid>
		<description>Great!
You can&#039;t know how useful it is to me! ;-)</description>
		<content:encoded><![CDATA[<p>Great!<br />
You can&#8217;t know how useful it is to me! ;-)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

