<?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: Euler Problem 102</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36962</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Wed, 07 Jan 2009 21:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36962</guid>
		<description>&lt;p&gt;I&#039;d figure the quickest approach would be identification first for quick results, then calculations when needed.&lt;/p&gt;
&lt;p&gt;1. If any of the points is the origin (0,0), done -- TRUE.&lt;/p&gt;
&lt;p&gt;2. Check quadrants: if either all x or all y values are all either positive or negative, then done -- FALSE.&lt;/p&gt;
&lt;p&gt;3. At this point one point must have an x value with a different sign than the other 2 points, and it&#039;s the lines between this point and each of the other 2 points that must have y intercepts on either side of the origin. Let the single point p0 (x0, y0) and the other points p1 (x1, y1) and p2 (x2, y2). The y intercepts between p0 and each of p1 and p2 are given by&lt;/p&gt;
&lt;p&gt;(y0-x0*(y1-y0)/(x1-x0))&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;(y0-x0*(y2-y0)/(x2-x0))&lt;/p&gt;
&lt;p&gt;and these must have different signs (one or the other could be exactly 0).&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;d figure the quickest approach would be identification first for quick results, then calculations when needed.</p>
<p>1. If any of the points is the origin (0,0), done &#8212; TRUE.</p>
<p>2. Check quadrants: if either all x or all y values are all either positive or negative, then done &#8212; FALSE.</p>
<p>3. At this point one point must have an x value with a different sign than the other 2 points, and it&#8217;s the lines between this point and each of the other 2 points that must have y intercepts on either side of the origin. Let the single point p0 (x0, y0) and the other points p1 (x1, y1) and p2 (x2, y2). The y intercepts between p0 and each of p1 and p2 are given by</p>
<p>(y0-x0*(y1-y0)/(x1-x0))</p>
<p>and</p>
<p>(y0-x0*(y2-y0)/(x2-x0))</p>
<p>and these must have different signs (one or the other could be exactly 0).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Harrison</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36935</link>
		<dc:creator>Dan Harrison</dc:creator>
		<pubDate>Wed, 07 Jan 2009 12:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36935</guid>
		<description>&lt;p&gt;Me and a friend established that the origin is enclosed by the triangle if and only if one of the edges crossed the Y axis at a negative Y value and another edge crossed it at a positive Y value.  Quite a simple rule that seems to make sense.&lt;/p&gt;
&lt;p&gt;Now I need to figure out the supporting maths...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Me and a friend established that the origin is enclosed by the triangle if and only if one of the edges crossed the Y axis at a negative Y value and another edge crossed it at a positive Y value.  Quite a simple rule that seems to make sense.</p>
<p>Now I need to figure out the supporting maths&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Wasserman</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36918</link>
		<dc:creator>David Wasserman</dc:creator>
		<pubDate>Wed, 07 Jan 2009 02:30:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36918</guid>
		<description>&lt;p&gt;I took a more visual (Venn diagram) approach. I created two Base Classes: Coordinates and Triangle. The Triangle base class was made up of three Coordinates properties called Vertices1 through Vertices3. Then, I created a method called InTheTriangle which received an arbitrary Coordinate as a parameter. In this case, it is always the Origin. Then, I checked to see if the Origin was either on one of the sides of the triangle or if it was on the side of the line connecting two of the Vertices as the third Vertex. Surprisingly (to me), this approach yielded the correct answer.&lt;/p&gt;
&lt;p&gt;Here is the main function as well as the CalcDirection helper function:&lt;/p&gt;
&lt;p&gt;Public Function InTheTriangle(Pt As Coordinates) As Boolean&lt;br&gt;
Dim InOut As Directioning&lt;br&gt;
    InTheTriangle = False&lt;br&gt;
    m = CalcSlope(Vertices1, Vertices2): b = CalcIntercept(Vertices1, m)&lt;br&gt;
    InOut = CalcDirection(m, b, Pt)&lt;br&gt;
    If InOut = Equal Then&lt;br&gt;
        InTheTriangle = True&lt;br&gt;
    Else&lt;br&gt;
        d = CalcDirection(m, b, Vertices3)&lt;br&gt;
        If d = InOut Then&lt;br&gt;
            m = CalcSlope(Vertices2, Vertices3): b = CalcIntercept(Vertices2, m)&lt;br&gt;
            InOut = CalcDirection(m, b, Pt)&lt;br&gt;
            If InOut = Equal Then&lt;br&gt;
                InTheTriangle = True&lt;br&gt;
            Else&lt;br&gt;
                d = CalcDirection(m, b, Vertices1)&lt;br&gt;
                If d = InOut Then&lt;br&gt;
                    m = CalcSlope(Vertices3, Vertices1): b = CalcIntercept(Vertices3, m)&lt;br&gt;
                    InOut = CalcDirection(m, b, Pt)&lt;br&gt;
                    If InOut = Equal Then&lt;br&gt;
                        InTheTriangle = True&lt;br&gt;
                    Else&lt;br&gt;
                        d = CalcDirection(m, b, Vertices2)&lt;br&gt;
                        InTheTriangle = (d = InOut)&lt;br&gt;
                    End If&lt;br&gt;
                End If&lt;br&gt;
            End If&lt;br&gt;
        End If&lt;br&gt;
    End If&lt;br&gt;
End Function&lt;/p&gt;
&lt;p&gt;Private Function CalcDirection(Slope As Variant, Intercept As Double, Vertex3 As Coordinates) As Directioning&lt;br&gt;
Dim Result As Double&lt;br&gt;
    If CStr(Slope) = Infinity Then&lt;br&gt;
        Result = Vertex3.X + Intercept&lt;br&gt;
    Else&lt;br&gt;
        Result = Vertex3.Y - (Slope * Vertex3.X) - Intercept&lt;br&gt;
    End If&lt;/p&gt;
&lt;p&gt;    If Abs(Result)  0 Then&lt;br&gt;
        CalcDirection = Greater&lt;br&gt;
    Else&lt;br&gt;
        CalcDirection = Less&lt;br&gt;
    End If&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I took a more visual (Venn diagram) approach. I created two Base Classes: Coordinates and Triangle. The Triangle base class was made up of three Coordinates properties called Vertices1 through Vertices3. Then, I created a method called InTheTriangle which received an arbitrary Coordinate as a parameter. In this case, it is always the Origin. Then, I checked to see if the Origin was either on one of the sides of the triangle or if it was on the side of the line connecting two of the Vertices as the third Vertex. Surprisingly (to me), this approach yielded the correct answer.</p>
<p>Here is the main function as well as the CalcDirection helper function:</p>
<p>Public Function InTheTriangle(Pt As Coordinates) As Boolean<br />
Dim InOut As Directioning<br />
    InTheTriangle = False<br />
    m = CalcSlope(Vertices1, Vertices2): b = CalcIntercept(Vertices1, m)<br />
    InOut = CalcDirection(m, b, Pt)<br />
    If InOut = Equal Then<br />
        InTheTriangle = True<br />
    Else<br />
        d = CalcDirection(m, b, Vertices3)<br />
        If d = InOut Then<br />
            m = CalcSlope(Vertices2, Vertices3): b = CalcIntercept(Vertices2, m)<br />
            InOut = CalcDirection(m, b, Pt)<br />
            If InOut = Equal Then<br />
                InTheTriangle = True<br />
            Else<br />
                d = CalcDirection(m, b, Vertices1)<br />
                If d = InOut Then<br />
                    m = CalcSlope(Vertices3, Vertices1): b = CalcIntercept(Vertices3, m)<br />
                    InOut = CalcDirection(m, b, Pt)<br />
                    If InOut = Equal Then<br />
                        InTheTriangle = True<br />
                    Else<br />
                        d = CalcDirection(m, b, Vertices2)<br />
                        InTheTriangle = (d = InOut)<br />
                    End If<br />
                End If<br />
            End If<br />
        End If<br />
    End If<br />
End Function</p>
<p>Private Function CalcDirection(Slope As Variant, Intercept As Double, Vertex3 As Coordinates) As Directioning<br />
Dim Result As Double<br />
    If CStr(Slope) = Infinity Then<br />
        Result = Vertex3.X + Intercept<br />
    Else<br />
        Result = Vertex3.Y &#8211; (Slope * Vertex3.X) &#8211; Intercept<br />
    End If</p>
<p>    If Abs(Result)  0 Then<br />
        CalcDirection = Greater<br />
    Else<br />
        CalcDirection = Less<br />
    End If<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36864</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Mon, 05 Jan 2009 21:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36864</guid>
		<description>&lt;p&gt;Michael - This blog post:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://newtonexcelbach.wordpress.com/2008/03/09/section-properties-from-coordinates/&quot; rel=&quot;nofollow&quot;&gt;http://newtonexcelbach.wordpress.com/2008/03/09/section-properties-from-coordinates/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;shows how the area calculation works for an irregular quadrilateral, but the same principle applies to a triangle (or any other polygon).  It&#039;s actually based on the trapezoid rule (area = base x average height) rather than the 1/2(base * height).&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Michael &#8211; This blog post:</p>
<p><a href="http://newtonexcelbach.wordpress.com/2008/03/09/section-properties-from-coordinates/" rel="nofollow">http://newtonexcelbach.wordpress.com/2008/03/09/section-properties-from-coordinates/</a></p>
<p>shows how the area calculation works for an irregular quadrilateral, but the same principle applies to a triangle (or any other polygon).  It&#8217;s actually based on the trapezoid rule (area = base x average height) rather than the 1/2(base * height).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36863</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Mon, 05 Jan 2009 21:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36863</guid>
		<description>&lt;p&gt;Before searching the &#039;Net, I thought of two ways to check if the origin was in the triangle.  One was to ensure that each axis was intercepted at least once.  And, since we were dealing with straight lines, there would be only 1 intercept.&lt;/p&gt;
&lt;p&gt;The other method was to ensure that the angles formed around the origin with each pair of vertices must equal 360 degrees.&lt;/p&gt;
&lt;p&gt;But, I rejected both as being sufficiently compled to compute given just the vertex coordinates that there had to be a better approach.&lt;/p&gt;
&lt;p&gt;A Google search pointed to an approach using vector products.  This would be easy to compute.&lt;/p&gt;
&lt;p&gt;In fact, the computations are sufficiently straightforward that the problem can be solved in Excel without any code support.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.tushar-mehta.com/misc_tutorials/project_euler/euler102.html&quot; rel=&quot;nofollow&quot;&gt;http://www.tushar-mehta.com/misc_tutorials/project_euler/euler102.html&lt;/a&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Before searching the &#8216;Net, I thought of two ways to check if the origin was in the triangle.  One was to ensure that each axis was intercepted at least once.  And, since we were dealing with straight lines, there would be only 1 intercept.</p>
<p>The other method was to ensure that the angles formed around the origin with each pair of vertices must equal 360 degrees.</p>
<p>But, I rejected both as being sufficiently compled to compute given just the vertex coordinates that there had to be a better approach.</p>
<p>A Google search pointed to an approach using vector products.  This would be easy to compute.</p>
<p>In fact, the computations are sufficiently straightforward that the problem can be solved in Excel without any code support.</p>
<p><a href="http://www.tushar-mehta.com/misc_tutorials/project_euler/euler102.html" rel="nofollow">http://www.tushar-mehta.com/misc_tutorials/project_euler/euler102.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36854</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 05 Jan 2009 15:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36854</guid>
		<description>&lt;p&gt;Good morning, Doug -&lt;/p&gt;
&lt;p&gt;I like it when you&#039;re workin&#039;.  I take it you used 1/2(base*height), and while I think I see 1/2 in there, I can&#039;t vision the area computation loop.  Could I impose upon you to talk thru one of the XDiff and YSum/2 loops?  I do see how you employed the mindiff concept.  Thanks for that.&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Good morning, Doug -</p>
<p>I like it when you&#8217;re workin&#8217;.  I take it you used 1/2(base*height), and while I think I see 1/2 in there, I can&#8217;t vision the area computation loop.  Could I impose upon you to talk thru one of the XDiff and YSum/2 loops?  I do see how you employed the mindiff concept.  Thanks for that.</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36845</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Mon, 05 Jan 2009 08:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36845</guid>
		<description>&lt;p&gt;Having said I was more interested in the total workin time than in shaving a few milliseconds of the computer time, I decided to see if I could shave a few milliseconds the computer time.&lt;/p&gt;
&lt;p&gt;The function below uses the area method, but finds the areas without finding the side lengths, thus saving a lot of squaring and square rooting.  On my machine it runs in 7.8 milliseconds, compared with about 15 milliseconds for the routine potsed by Michael.&lt;/p&gt;
&lt;p&gt;Replace .LT. with the Less Than symbol, and enter as an array function in two adjacent cells to get the solution time as well as the result.&lt;/p&gt;
&lt;p&gt;Function Triangles2(Coords As Variant) As Variant&lt;br&gt;
Dim NumTri As Long, i As Long, j As Long, Area1 As Double, Area2 As Double&lt;br&gt;
Dim XDiff(1 To 3) As Double, Ysum(1 To 3) As Double, Area2inc As Double&lt;br&gt;
Dim count As Long, ResA(1 To 1, 1 To 2) As Double&lt;/p&gt;
&lt;p&gt;Const MinDiff As Double = 0.0000000001&lt;/p&gt;
&lt;p&gt;ResA(1, 2) = Timer&lt;br&gt;
Coords = Coords.Value2&lt;/p&gt;
&lt;p&gt;NumTri = UBound(Coords)&lt;/p&gt;
&lt;p&gt;For i = 1 To NumTri&lt;br&gt;
Area1 = 0&lt;br&gt;
Area2 = 0&lt;br&gt;
Area2inc = 0&lt;/p&gt;
&lt;p&gt;XDiff(1) = Coords(i, 3) - Coords(i, 1)&lt;br&gt;
XDiff(2) = Coords(i, 5) - Coords(i, 3)&lt;br&gt;
XDiff(3) = Coords(i, 1) - Coords(i, 5)&lt;/p&gt;
&lt;p&gt;Ysum(1) = (Coords(i, 2) + Coords(i, 4)) / 2&lt;br&gt;
Ysum(2) = (Coords(i, 4) + Coords(i, 6)) / 2&lt;br&gt;
Ysum(3) = (Coords(i, 6) + Coords(i, 2)) / 2&lt;/p&gt;
&lt;p&gt;For j = 1 To 3&lt;br&gt;
Area1 = Area1 + XDiff(j) * Ysum(j)&lt;br&gt;
Next j&lt;br&gt;
Area1 = Abs(Area1)&lt;/p&gt;
&lt;p&gt;XDiff(2) = -Coords(i, 3)&lt;br&gt;
XDiff(3) = Coords(i, 1)&lt;/p&gt;
&lt;p&gt;Ysum(2) = (Coords(i, 4)) / 2&lt;br&gt;
Ysum(3) = (Coords(i, 2)) / 2&lt;/p&gt;
&lt;p&gt;For j = 1 To 3&lt;br&gt;
Area2inc = Area2inc + XDiff(j) * Ysum(j)&lt;br&gt;
Next j&lt;/p&gt;
&lt;p&gt;Area2 = Abs(Area2inc)&lt;/p&gt;
&lt;p&gt;XDiff(1) = Coords(i, 3)&lt;br&gt;
XDiff(2) = Coords(i, 5) - Coords(i, 3)&lt;br&gt;
XDiff(3) = -Coords(i, 5)&lt;/p&gt;
&lt;p&gt;Ysum(1) = (Coords(i, 4)) / 2&lt;br&gt;
Ysum(2) = (Coords(i, 4) + Coords(i, 6)) / 2&lt;br&gt;
Ysum(3) = (Coords(i, 6)) / 2&lt;/p&gt;
&lt;p&gt;Area2inc = 0&lt;br&gt;
For j = 1 To 3&lt;br&gt;
Area2inc = Area2inc + XDiff(j) * Ysum(j)&lt;br&gt;
Next j&lt;/p&gt;
&lt;p&gt;Area2 = Area2 + Abs(Area2inc)&lt;/p&gt;
&lt;p&gt;XDiff(1) = -Coords(i, 1)&lt;br&gt;
XDiff(2) = Coords(i, 5)&lt;br&gt;
XDiff(3) = Coords(i, 1) - Coords(i, 5)&lt;/p&gt;
&lt;p&gt;Ysum(1) = (Coords(i, 2)) / 2&lt;br&gt;
Ysum(2) = (Coords(i, 6)) / 2&lt;br&gt;
Ysum(3) = (Coords(i, 6) + Coords(i, 2)) / 2&lt;/p&gt;
&lt;p&gt;Area2inc = 0&lt;br&gt;
For j = 1 To 3&lt;br&gt;
Area2inc = Area2inc + XDiff(j) * Ysum(j)&lt;br&gt;
Next j&lt;/p&gt;
&lt;p&gt;Area2 = Area2 + Abs(Area2inc)&lt;/p&gt;
&lt;p&gt;If Abs(Area2 - Area1) .LT. MinDiff Then count = count + 1&lt;/p&gt;
&lt;p&gt;Next i&lt;/p&gt;
&lt;p&gt;ResA(1, 1) = count&lt;br&gt;
ResA(1, 2) = Timer - ResA(1, 2)&lt;/p&gt;
&lt;p&gt;Triangles2 = ResA&lt;/p&gt;
&lt;p&gt;End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Having said I was more interested in the total workin time than in shaving a few milliseconds of the computer time, I decided to see if I could shave a few milliseconds the computer time.</p>
<p>The function below uses the area method, but finds the areas without finding the side lengths, thus saving a lot of squaring and square rooting.  On my machine it runs in 7.8 milliseconds, compared with about 15 milliseconds for the routine potsed by Michael.</p>
<p>Replace .LT. with the Less Than symbol, and enter as an array function in two adjacent cells to get the solution time as well as the result.</p>
<p>Function Triangles2(Coords As Variant) As Variant<br />
Dim NumTri As Long, i As Long, j As Long, Area1 As Double, Area2 As Double<br />
Dim XDiff(1 To 3) As Double, Ysum(1 To 3) As Double, Area2inc As Double<br />
Dim count As Long, ResA(1 To 1, 1 To 2) As Double</p>
<p>Const MinDiff As Double = 0.0000000001</p>
<p>ResA(1, 2) = Timer<br />
Coords = Coords.Value2</p>
<p>NumTri = UBound(Coords)</p>
<p>For i = 1 To NumTri<br />
Area1 = 0<br />
Area2 = 0<br />
Area2inc = 0</p>
<p>XDiff(1) = Coords(i, 3) &#8211; Coords(i, 1)<br />
XDiff(2) = Coords(i, 5) &#8211; Coords(i, 3)<br />
XDiff(3) = Coords(i, 1) &#8211; Coords(i, 5)</p>
<p>Ysum(1) = (Coords(i, 2) + Coords(i, 4)) / 2<br />
Ysum(2) = (Coords(i, 4) + Coords(i, 6)) / 2<br />
Ysum(3) = (Coords(i, 6) + Coords(i, 2)) / 2</p>
<p>For j = 1 To 3<br />
Area1 = Area1 + XDiff(j) * Ysum(j)<br />
Next j<br />
Area1 = Abs(Area1)</p>
<p>XDiff(2) = -Coords(i, 3)<br />
XDiff(3) = Coords(i, 1)</p>
<p>Ysum(2) = (Coords(i, 4)) / 2<br />
Ysum(3) = (Coords(i, 2)) / 2</p>
<p>For j = 1 To 3<br />
Area2inc = Area2inc + XDiff(j) * Ysum(j)<br />
Next j</p>
<p>Area2 = Abs(Area2inc)</p>
<p>XDiff(1) = Coords(i, 3)<br />
XDiff(2) = Coords(i, 5) &#8211; Coords(i, 3)<br />
XDiff(3) = -Coords(i, 5)</p>
<p>Ysum(1) = (Coords(i, 4)) / 2<br />
Ysum(2) = (Coords(i, 4) + Coords(i, 6)) / 2<br />
Ysum(3) = (Coords(i, 6)) / 2</p>
<p>Area2inc = 0<br />
For j = 1 To 3<br />
Area2inc = Area2inc + XDiff(j) * Ysum(j)<br />
Next j</p>
<p>Area2 = Area2 + Abs(Area2inc)</p>
<p>XDiff(1) = -Coords(i, 1)<br />
XDiff(2) = Coords(i, 5)<br />
XDiff(3) = Coords(i, 1) &#8211; Coords(i, 5)</p>
<p>Ysum(1) = (Coords(i, 2)) / 2<br />
Ysum(2) = (Coords(i, 6)) / 2<br />
Ysum(3) = (Coords(i, 6) + Coords(i, 2)) / 2</p>
<p>Area2inc = 0<br />
For j = 1 To 3<br />
Area2inc = Area2inc + XDiff(j) * Ysum(j)<br />
Next j</p>
<p>Area2 = Area2 + Abs(Area2inc)</p>
<p>If Abs(Area2 &#8211; Area1) .LT. MinDiff Then count = count + 1</p>
<p>Next i</p>
<p>ResA(1, 1) = count<br />
ResA(1, 2) = Timer &#8211; ResA(1, 2)</p>
<p>Triangles2 = ResA</p>
<p>End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36839</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Mon, 05 Jan 2009 03:48:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36839</guid>
		<description>&lt;p&gt;&quot;I found out I didn&#039;t know how to write one&quot;&lt;/p&gt;
&lt;p&gt;It&#039;s one of those things that is harder than it looks.&lt;/p&gt;
&lt;p&gt;Probably the easiest way (which I used) is to project a horizontal line from the point you are checking to infinity and count how many times it crosses the boundary of the shape.&lt;/p&gt;
&lt;p&gt;An odd number of crossings indicates inside, and zero or an even number indicates outside.&lt;/p&gt;
&lt;p&gt;But you get situations like intersecting a corner, or a segment of the shape exactly overlying the projected line from the point, so you have to have a consistent way of dealing with those things.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>&#8220;I found out I didn&#8217;t know how to write one&#8221;</p>
<p>It&#8217;s one of those things that is harder than it looks.</p>
<p>Probably the easiest way (which I used) is to project a horizontal line from the point you are checking to infinity and count how many times it crosses the boundary of the shape.</p>
<p>An odd number of crossings indicates inside, and zero or an even number indicates outside.</p>
<p>But you get situations like intersecting a corner, or a segment of the shape exactly overlying the projected line from the point, so you have to have a consistent way of dealing with those things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36838</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 05 Jan 2009 03:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36838</guid>
		<description>&lt;p&gt;Hi Doug -&lt;/p&gt;
&lt;p&gt;Thank you two times.  I&#039;ll go get your routine.  I found out I didn&#039;t know how to write one.&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Doug -</p>
<p>Thank you two times.  I&#8217;ll go get your routine.  I found out I didn&#8217;t know how to write one.</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/04/euler-problem-102/#comment-36835</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Mon, 05 Jan 2009 00:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1934#comment-36835</guid>
		<description>&lt;p&gt;Michael - if you calculate two &quot;equal&quot; values by two different methods the last figure in the results is likely to be different due to rounding errors.  You can subtract the results and check that the absolute value of the difference is less than some very small number (like 1e-12), or you can round them to some lower precision and check that the rounded values are equal, which is effectively what you did by converting from double to single.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Michael &#8211; if you calculate two &#8220;equal&#8221; values by two different methods the last figure in the results is likely to be different due to rounding errors.  You can subtract the results and check that the absolute value of the difference is less than some very small number (like 1e-12), or you can round them to some lower precision and check that the rounded values are equal, which is effectively what you did by converting from double to single.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

