<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Srikanth Kotagiri&#039;s Blog</title>
	<atom:link href="http://skotagiri.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://skotagiri.wordpress.com</link>
	<description>My musings about software, programming, design, algorithms and WPF</description>
	<lastBuildDate>Wed, 12 Oct 2011 00:44:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='skotagiri.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Srikanth Kotagiri&#039;s Blog</title>
		<link>http://skotagiri.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://skotagiri.wordpress.com/osd.xml" title="Srikanth Kotagiri&#039;s Blog" />
	<atom:link rel='hub' href='http://skotagiri.wordpress.com/?pushpress=hub'/>
		<item>
		<title>BlueStacks + ADB = Awsome</title>
		<link>http://skotagiri.wordpress.com/2011/10/11/bluestacks-adb-awsome/</link>
		<comments>http://skotagiri.wordpress.com/2011/10/11/bluestacks-adb-awsome/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 00:44:05 +0000</pubDate>
		<dc:creator>Srikanth</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://skotagiri.wordpress.com/?p=38</guid>
		<description><![CDATA[I just found out that one of the projects that I have been anticipating released their first Alpha(link to arsTechnica article). I downloaded the application. Installation took a few tries but it installed successfully when I closed all the IE and eclipse instances. After installation, just on a lark, I tried to use ADB to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=skotagiri.wordpress.com&amp;blog=6797208&amp;post=38&amp;subd=skotagiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just found out that one of the projects that I have been anticipating released their first Alpha(<a title="Bluestacks Alpha released" href="http://arst.ch/r71">link to arsTechnica article</a>). I downloaded the application. Installation took a few tries but it installed successfully when I closed all the IE and eclipse instances.</p>
<p>After installation, just on a lark, I tried to use ADB to see if I can run my application. And surprisingly, it connected!!</p>
<p>The process I used was I ran an application and when I was running the app I issued the command in command prompt</p>
<p><code><br />
adb connect 127.0.0.1:5555<br />
</code></p>
<p>and that&#8217;s it! With adb connected, I was able to successfully use bluestacks instead of the slow as molasses(tbh when compared to Bluestacks) Emulator!</p>
<p>I know what I am using as emulator from tomorrow( until I break it.)</p>
<p>Thanks for the BlueStacks team for the great application! I just can&#8217;t wait for it to be in final release&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/skotagiri.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/skotagiri.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/skotagiri.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/skotagiri.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/skotagiri.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/skotagiri.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/skotagiri.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/skotagiri.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/skotagiri.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/skotagiri.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/skotagiri.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/skotagiri.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/skotagiri.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/skotagiri.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=skotagiri.wordpress.com&amp;blog=6797208&amp;post=38&amp;subd=skotagiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://skotagiri.wordpress.com/2011/10/11/bluestacks-adb-awsome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/28c8fbb9dc6bd12d29a688225866067c?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">srikanth</media:title>
		</media:content>
	</item>
		<item>
		<title>C# Implementation for Fitting an Ellipse for a Set of Points</title>
		<link>http://skotagiri.wordpress.com/2010/06/19/c-implementation-for-fitting-an-ellipse-for-a-set-of-points/</link>
		<comments>http://skotagiri.wordpress.com/2010/06/19/c-implementation-for-fitting-an-ellipse-for-a-set-of-points/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 22:16:39 +0000</pubDate>
		<dc:creator>Srikanth</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[Algorithm implementation]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Ellipse fitting]]></category>
		<category><![CDATA[Least squares regression]]></category>
		<category><![CDATA[Regression]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://skotagiri.wordpress.com/?p=26</guid>
		<description><![CDATA[Implementation for ellipse fitting.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=skotagiri.wordpress.com&amp;blog=6797208&amp;post=26&amp;subd=skotagiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Earlier this month, I was looking for a quick way to fit an ellipse for a set of points. I did some searching around and this <A href="http://autotrace.sourceforge.net/WSCG98.pdf">paper</A> looked most promising. The explanation looked fairly interesting.</p>
<p>The best part, however, is that the paper provides a MATLAB implementation for the algorithm that Fits an ellipse in Canonical form</p>
<p>A x<SUP>2</SUP> + Bxy + Cy<SUP>2</SUP> + Dx + Ey + F = 0</p>
<p>The program gives the estimates for parameters A..F.</p>
<p>The algorithm looks fairly straightforward to implement. The only wrinkle is the calculation of the eigenvalues and vectors for a matrix. So, in order to avoid re-inventing the wheel, I used the excellent library Meta.Numerics available at <A href="http://metanumerics.codeplex.com/">codeplex</A>.</p>
<p>So here is the class that does it all<br />
EllipseFit.cs<br />
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Meta.Numerics.Matrices;
using Meta.Numerics;

namespace FitEllipse
{
    public class EllipseFit
    {
        public Matrix Fit(PointCollection points)
        {
            int numPoints = points.Count;

            Matrix D1 = new Matrix(numPoints, 3);
            Matrix D2 = new Matrix(numPoints, 3);
            SquareMatrix S1 = new SquareMatrix(3);
            SquareMatrix S2 = new SquareMatrix(3);
            SquareMatrix S3 = new SquareMatrix(3);
            SquareMatrix T = new SquareMatrix(3);
            SquareMatrix M = new SquareMatrix(3);
            SquareMatrix C1 = new SquareMatrix(3);
            Matrix a1 = new Matrix(3, 1);
            Matrix a2 = new Matrix(3, 1);
            Matrix result = new Matrix(6, 1);
            Matrix temp;

            C1[0, 0] = 0;
            C1[0, 1] = 0;
            C1[0, 2] = 0.5;
            C1[1, 0] = 0;
            C1[1, 1] = -1;
            C1[1, 2] = 0;
            C1[2, 0] = 0.5;
            C1[2, 1] = 0;
            C1[2, 2] = 0;

            //2 D1 = [x .ˆ 2, x .* y, y .ˆ 2]; % quadratic part of the design matrix
            //3 D2 = [x, y, ones(size(x))]; % linear part of the design matrix
            for (int xx = 0; xx &lt; points.Count; xx++)
            {
                Point p = points[xx];
                D1[xx, 0] = p.X * p.X;
                D1[xx, 1] = p.X * p.Y;
                D1[xx, 2] = p.Y * p.Y;

                D2[xx, 0] = p.X;
                D2[xx, 1] = p.Y;
                D2[xx, 2] = 1;
            }

            //4 S1 = D1’ * D1; % quadratic part of the scatter matrix
            temp = D1.Transpose() * D1;
            for (int xx = 0; xx &lt; 3; xx++)
                for (int yy = 0; yy &lt; 3; yy++)
                    S1[xx, yy] = temp[xx, yy];

            //5 S2 = D1’ * D2; % combined part of the scatter matrix
            temp = D1.Transpose() * D2;
            for (int xx = 0; xx &lt; 3; xx++)
                for (int yy = 0; yy &lt; 3; yy++)
                    S2[xx, yy] = temp[xx, yy];

            //6 S3 = D2’ * D2; % linear part of the scatter matrix
            temp = D2.Transpose() * D2;
            for (int xx = 0; xx &lt; 3; xx++)
                for (int yy = 0; yy &lt; 3; yy++)
                    S3[xx, yy] = temp[xx, yy];

            //7 T = - inv(S3) * S2’; % for getting a2 from a1
            T = -1 * S3.Inverse() * S2.Transpose();
            
            //8 M = S1 + S2 * T; % reduced scatter matrix
            M = S1 + S2 * T;
            
            //9 M = [M(3, :) ./ 2; - M(2, :); M(1, :) ./ 2]; % premultiply by inv(C1)
            M = C1 * M;
            
            //10 [evec, eval] = eig(M); % solve eigensystem
            ComplexEigensystem eigenSystem = M.Eigensystem();

            //11 cond = 4 * evec(1, :) .* evec(3, :) - evec(2, :) .ˆ 2; % evaluate a’Ca
            //12 a1 = evec(:, find(cond &gt; 0)); % eigenvector for min. pos. eigenvalue
            for (int xx = 0; xx &lt; eigenSystem.Dimension; xx++)
            {
               Vector&lt;Complex&gt; vector =  eigenSystem.Eigenvector(xx);
               Complex condition = 4 * vector[0] * vector[2] - vector[1] * vector[1];
               if (condition.Im == 0 &amp;&amp; condition.Re &gt; 0)
               {
                   // Solution is found
                   Console.WriteLine(&quot;\nSolution Found!&quot;);
                   for (int yy = 0; yy &lt; vector.Count(); yy++)
                   {
                       Console.Write(&quot;{0}, &quot;, vector[yy]);
                       a1[yy, 0] = vector[yy].Re;
                   }
               }
            }
            //13 a2 = T * a1; % ellipse coefficients
            a2 = T * a1;

            //14 a = [a1; a2]; % ellipse coefficients
            result[0, 0] = a1[0, 0];
            result[1, 0] = a1[1, 0];
            result[2, 0] = a1[2, 0];
            result[3, 0] = a2[0, 0];
            result[4, 0] = a2[1, 0];
            result[5, 0] = a2[2, 0];

            return result;
        }
    }
}

</pre></p>
<p>Point.cs<br />
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FitEllipse
{
    public class Point
    {
        public double X { get; set; }
        public double Y {get; set;  }
    }

    public class PointCollection : List&lt;Point&gt;
    {
    }
}

</pre></p>
<p>The complete project is available for download here. Just download the file and rename it to zip.<br />
&nbsp;<A href="http://www.box.net/shared/rkp91gymmv">FitEllipse.zip</A></p>
<p>All code is made available under the MS-PL.<br />
Any comments to improve the execution time are always welcomed.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/skotagiri.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/skotagiri.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/skotagiri.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/skotagiri.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/skotagiri.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/skotagiri.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/skotagiri.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/skotagiri.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/skotagiri.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/skotagiri.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/skotagiri.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/skotagiri.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/skotagiri.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/skotagiri.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=skotagiri.wordpress.com&amp;blog=6797208&amp;post=26&amp;subd=skotagiri&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://skotagiri.wordpress.com/2010/06/19/c-implementation-for-fitting-an-ellipse-for-a-set-of-points/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/28c8fbb9dc6bd12d29a688225866067c?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">srikanth</media:title>
		</media:content>
	</item>
	</channel>
</rss>
