<?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: Intersection of an Ellipse and a Line in AS3</title>
	<atom:link href="http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/</link>
	<description>together at last</description>
	<lastBuildDate>Mon, 23 Jan 2012 21:45:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Nico Limpika</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-59</link>
		<dc:creator>Nico Limpika</dc:creator>
		<pubDate>Fri, 04 Jun 2010 00:55:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-59</guid>
		<description>No problem, any future users will know of this in advance from our comments. I can imagine you would kill your self creating this class. Thanks so much for saving me the hours. If you want to see an example of how I used your code check out this article: 

http://www.actionscript-flash-guru.com/blog/33-scale-around-a-point-transform-multiple-objects-actionscript-3-as3 

at the bottom of the page there is a drawing program that uses your program to detect line selections.

 Take care, Nico out! :)</description>
		<content:encoded><![CDATA[<p>No problem, any future users will know of this in advance from our comments. I can imagine you would kill your self creating this class. Thanks so much for saving me the hours. If you want to see an example of how I used your code check out this article: </p>
<p><a href="http://www.actionscript-flash-guru.com/blog/33-scale-around-a-point-transform-multiple-objects-actionscript-3-as3" rel="nofollow">http://www.actionscript-flash-guru.com/blog/33-scale-around-a-point-transform-multiple-objects-actionscript-3-as3</a> </p>
<p>at the bottom of the page there is a drawing program that uses your program to detect line selections.</p>
<p> Take care, Nico out! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean James McKenzie</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-58</link>
		<dc:creator>Sean James McKenzie</dc:creator>
		<pubDate>Thu, 03 Jun 2010 23:26:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-58</guid>
		<description>Well said. I remember running into those issues while I was trying to get all of this to work. You comment about the &quot;view and model&quot; being off is correct. I probably should have spent a little more time on this one to iron that out. Perhaps I&#039;ll revisit this one day and clean that up. Frankly I was excited to get this damn thing working that I pretty much stopped messing with it once it was working.

I&#039;m sorry if that confused anyone else who might have tried to use this class. Hopefully even with the adjustment you had to make the class still saved you some time.</description>
		<content:encoded><![CDATA[<p>Well said. I remember running into those issues while I was trying to get all of this to work. You comment about the &#8220;view and model&#8221; being off is correct. I probably should have spent a little more time on this one to iron that out. Perhaps I&#8217;ll revisit this one day and clean that up. Frankly I was excited to get this damn thing working that I pretty much stopped messing with it once it was working.</p>
<p>I&#8217;m sorry if that confused anyone else who might have tried to use this class. Hopefully even with the adjustment you had to make the class still saved you some time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nico Limpika</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-57</link>
		<dc:creator>Nico Limpika</dc:creator>
		<pubDate>Thu, 03 Jun 2010 23:16:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-57</guid>
		<description>Here is a better description of why I posted that large block of code before:

I see in your demo fla that everything seems to work.

            ellipseClip.graphics.lineStyle(1,0x000000,.2);
            ellipseClip.graphics.drawEllipse(0,0,ELLIPSE_WIDTH,ELLIPSE_HEIGHT);
            ellipseClip.x = (STAGE_WIDTH-ELLIPSE_WIDTH)/2;
            ellipseClip.y = (STAGE_HEIGHT-ELLIPSE_HEIGHT)/2;

Because you adjust the graphics drawing API to work with your data model.
The drawEllipse x and y parameters are not to be confused with your EllipseExt x and y parameters. Flash does use x and y as the top left hand corner of the bounding box, where as you use the x and y as the center. In short the view and model are not the same. You make sure they line up by transposing the ellipseClip. But, if you are doing a visualization without transposing the outer movie clip you have to adjust drawEllipse directly so that it looks like the following:

ellipseClip.graphics.drawEllipse(x-(ELLIPSE_WIDTH/2), y-(ELLIPSE_WIDTH/2), ELLIPSE_WIDTH, ELLIPSE_HEIGHT);

However in my code I get some weird stuff going on: To make the above work I have to use:

 EllipseExt(ELLIPSE_CENTER.x-(ELLIPSE_WIDTH/2), ELLIPSE_CENTER.y-(ELLIPSE_HEIGHT/2), ELLIPSE_WIDTH, ELLIPSE_HEIGHT);

Otherwise the intersection points do not match up to the ellipse. Which means there is a difference if you are doing everything in one graphics object versus transposing outer movies like you are doing. But I&#039;m a bit confuse why it would be any different. Anyways its not a problem for me. I just adjust the EllipseExt constructor accordingly. It&#039;s just peculiar observation.

Anyone else run into this?</description>
		<content:encoded><![CDATA[<p>Here is a better description of why I posted that large block of code before:</p>
<p>I see in your demo fla that everything seems to work.</p>
<p>            ellipseClip.graphics.lineStyle(1,0&#215;000000,.2);<br />
            ellipseClip.graphics.drawEllipse(0,0,ELLIPSE_WIDTH,ELLIPSE_HEIGHT);<br />
            ellipseClip.x = (STAGE_WIDTH-ELLIPSE_WIDTH)/2;<br />
            ellipseClip.y = (STAGE_HEIGHT-ELLIPSE_HEIGHT)/2;</p>
<p>Because you adjust the graphics drawing API to work with your data model.<br />
The drawEllipse x and y parameters are not to be confused with your EllipseExt x and y parameters. Flash does use x and y as the top left hand corner of the bounding box, where as you use the x and y as the center. In short the view and model are not the same. You make sure they line up by transposing the ellipseClip. But, if you are doing a visualization without transposing the outer movie clip you have to adjust drawEllipse directly so that it looks like the following:</p>
<p>ellipseClip.graphics.drawEllipse(x-(ELLIPSE_WIDTH/2), y-(ELLIPSE_WIDTH/2), ELLIPSE_WIDTH, ELLIPSE_HEIGHT);</p>
<p>However in my code I get some weird stuff going on: To make the above work I have to use:</p>
<p> EllipseExt(ELLIPSE_CENTER.x-(ELLIPSE_WIDTH/2), ELLIPSE_CENTER.y-(ELLIPSE_HEIGHT/2), ELLIPSE_WIDTH, ELLIPSE_HEIGHT);</p>
<p>Otherwise the intersection points do not match up to the ellipse. Which means there is a difference if you are doing everything in one graphics object versus transposing outer movies like you are doing. But I&#8217;m a bit confuse why it would be any different. Anyways its not a problem for me. I just adjust the EllipseExt constructor accordingly. It&#8217;s just peculiar observation.</p>
<p>Anyone else run into this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean James McKenzie</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-56</link>
		<dc:creator>Sean James McKenzie</dc:creator>
		<pubDate>Thu, 03 Jun 2010 22:51:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-56</guid>
		<description>Oh, duh. You know what I probably did some copying in pasting when I was putting that line together. I believe I copied that from the other situation where you&#039;d be calculating 2 intersections with varying values for radicand and then never went back and never swapped that out for a constant value of Math.sqrt(0).

You are correct. That was an oversight on my part. Good call. :)</description>
		<content:encoded><![CDATA[<p>Oh, duh. You know what I probably did some copying in pasting when I was putting that line together. I believe I copied that from the other situation where you&#8217;d be calculating 2 intersections with varying values for radicand and then never went back and never swapped that out for a constant value of Math.sqrt(0).</p>
<p>You are correct. That was an oversight on my part. Good call. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nico Limpika</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-55</link>
		<dc:creator>Nico Limpika</dc:creator>
		<pubDate>Thu, 03 Jun 2010 22:46:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-55</guid>
		<description>My point is more around the subject of optimization:

if(radicand == 0){
      trace( Math.sqrt(radicand) )
}

is redundant inside of an if statement that checks to make sure radicand is 0. There is no need for the Math.sqrt since the answer will always be 0. No need to run a function call if there is no need for it. :)</description>
		<content:encoded><![CDATA[<p>My point is more around the subject of optimization:</p>
<p>if(radicand == 0){<br />
      trace( Math.sqrt(radicand) )<br />
}</p>
<p>is redundant inside of an if statement that checks to make sure radicand is 0. There is no need for the Math.sqrt since the answer will always be 0. No need to run a function call if there is no need for it. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean James McKenzie</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-54</link>
		<dc:creator>Sean James McKenzie</dc:creator>
		<pubDate>Thu, 03 Jun 2010 20:42:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-54</guid>
		<description>In response to your question about line 83, when the radicand is zero we know the points of intersections are going to be the same, so we can just pick on and do one less set of calculations.

I&#039;ll have to spend some time looking at the code from your 3rd comment and get back to you.</description>
		<content:encoded><![CDATA[<p>In response to your question about line 83, when the radicand is zero we know the points of intersections are going to be the same, so we can just pick on and do one less set of calculations.</p>
<p>I&#8217;ll have to spend some time looking at the code from your 3rd comment and get back to you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nico Limpika</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-53</link>
		<dc:creator>Nico Limpika</dc:creator>
		<pubDate>Thu, 03 Jun 2010 20:34:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-53</guid>
		<description>Ok so there is something not matching up between mc.graphics.drawEllipse(x, y, 10, 10); and when I run the following function. My intersection points are not lining up. 

function isEllipseIntersectingLineSeg(linePoint1:Point, linePoint2:Point, x:Number, y:Number, width:Number, height:Number):Boolean{
			width = MathUtil.truncate(width, SS.PRECISION);
			height = MathUtil.truncate(height, SS.PRECISION);
			var ellipse:Ellipse = new Ellipse(x, y, width, height);
			var resultsArray:Array = ellipse.getIntersections(linePoint1, linePoint2);
			var isIntersecting:Boolean;
			var angle1 : Number;
			var angle2 : Number;
			
			if (resultsArray[0] != null){
				Render._debugVis.graphics.beginFill(0xff0000, .5);
				Render._debugVis.graphics.drawCircle(Point(resultsArray[0]).x, Point(resultsArray[0]).y, .5);
				Render._debugVis.graphics.endFill();
				isIntersecting = true;
			}
			if (resultsArray[1] != null){
				Render._debugVis.graphics.beginFill(0xff0000, .5);
				Render._debugVis.graphics.drawCircle(Point(resultsArray[1]).x, Point(resultsArray[1]).y, .5);
				Render._debugVis.graphics.endFill();
				isIntersecting = true;
			}
			return isIntersecting;
		}</description>
		<content:encoded><![CDATA[<p>Ok so there is something not matching up between mc.graphics.drawEllipse(x, y, 10, 10); and when I run the following function. My intersection points are not lining up. </p>
<p>function isEllipseIntersectingLineSeg(linePoint1:Point, linePoint2:Point, x:Number, y:Number, width:Number, height:Number):Boolean{<br />
			width = MathUtil.truncate(width, SS.PRECISION);<br />
			height = MathUtil.truncate(height, SS.PRECISION);<br />
			var ellipse:Ellipse = new Ellipse(x, y, width, height);<br />
			var resultsArray:Array = ellipse.getIntersections(linePoint1, linePoint2);<br />
			var isIntersecting:Boolean;<br />
			var angle1 : Number;<br />
			var angle2 : Number;</p>
<p>			if (resultsArray[0] != null){<br />
				Render._debugVis.graphics.beginFill(0xff0000, .5);<br />
				Render._debugVis.graphics.drawCircle(Point(resultsArray[0]).x, Point(resultsArray[0]).y, .5);<br />
				Render._debugVis.graphics.endFill();<br />
				isIntersecting = true;<br />
			}<br />
			if (resultsArray[1] != null){<br />
				Render._debugVis.graphics.beginFill(0xff0000, .5);<br />
				Render._debugVis.graphics.drawCircle(Point(resultsArray[1]).x, Point(resultsArray[1]).y, .5);<br />
				Render._debugVis.graphics.endFill();<br />
				isIntersecting = true;<br />
			}<br />
			return isIntersecting;<br />
		}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nico Limpika</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-52</link>
		<dc:creator>Nico Limpika</dc:creator>
		<pubDate>Thu, 03 Jun 2010 20:24:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-52</guid>
		<description>line 83 EllipseExt 

if(radicand == 0){
				// in this case both points will result in the same, so we only need to calculate one point
				p3.x = (-B-Math.sqrt(radicand))/(2*A);

why are you calculating the square root of 0?</description>
		<content:encoded><![CDATA[<p>line 83 EllipseExt </p>
<p>if(radicand == 0){<br />
				// in this case both points will result in the same, so we only need to calculate one point<br />
				p3.x = (-B-Math.sqrt(radicand))/(2*A);</p>
<p>why are you calculating the square root of 0?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean James McKenzie</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-51</link>
		<dc:creator>Sean James McKenzie</dc:creator>
		<pubDate>Thu, 03 Jun 2010 18:10:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-51</guid>
		<description>The x and y params are the center of the ellipse. Give me a shout if you have any other questions about or problems with the code. Thanks for reading :)</description>
		<content:encoded><![CDATA[<p>The x and y params are the center of the ellipse. Give me a shout if you have any other questions about or problems with the code. Thanks for reading :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nico Limpika</title>
		<link>http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/comment-page-1/#comment-50</link>
		<dc:creator>Nico Limpika</dc:creator>
		<pubDate>Thu, 03 Jun 2010 00:38:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.baconandgames.com/?p=93#comment-50</guid>
		<description>Thanks for this post. It has been a real life saver. I have a question. @param x: The horizontal position of the ellipse.
@param y: The vertical position of the ellipse.
in the constructor of Ellipse is this the center of the ellipse or the top left hand corner?</description>
		<content:encoded><![CDATA[<p>Thanks for this post. It has been a real life saver. I have a question. @param x: The horizontal position of the ellipse.<br />
@param y: The vertical position of the ellipse.<br />
in the constructor of Ellipse is this the center of the ellipse or the top left hand corner?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

