<?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/"
	>

<channel>
	<title>GBuffer.net</title>
	<atom:link href="http://www.gbuffer.net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gbuffer.net</link>
	<description>&#62; Sid’s data dump</description>
	<lastBuildDate>Sat, 31 Mar 2012 00:13:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Finding the distance between two lines in 3D using calculus</title>
		<link>http://www.gbuffer.net/archives/361</link>
		<comments>http://www.gbuffer.net/archives/361#comments</comments>
		<pubDate>Tue, 21 Feb 2012 16:10:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=361</guid>
		<description><![CDATA[When trying to solve problems in geometry, I tend to get stuck trying to solve these problems from a geometric perspective. While this may be easy to visualise and understand (at least for me), it may not always be the best way to approach the problem. One such problem is the distance between two lines [...]]]></description>
			<content:encoded><![CDATA[<p>When trying to solve problems in geometry, I tend to get stuck trying to solve these problems from a geometric perspective. While this may be easy to visualise and understand (at least for me), it may not always be the best way to approach the problem. One such problem is the distance between two lines ion 3D space. I recently found that by solving the same problem using calculus can lead to a much more elegant and efficient solution. Below we take a look at the problem and compare the two methods.</p>
<h3>The problem:</h3>
<p>First lets define the problem.</p>
<p>We are given four points <img src='http://s.wordpress.com/latex.php?latex=%20p_1%2C%20p_2%2C%20p_3%2C%20p_4&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt=' p_1, p_2, p_3, p_4' title=' p_1, p_2, p_3, p_4' class='latex' /><br />
Points <img src='http://s.wordpress.com/latex.php?latex=%28p_1%2C%20p_2%29%20%5Cin%20L_1%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(p_1, p_2) \in L_1 ' title='(p_1, p_2) \in L_1 ' class='latex' /> lie on line <img src='http://s.wordpress.com/latex.php?latex=L_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_1' title='L_1' class='latex' /> and points <img src='http://s.wordpress.com/latex.php?latex=%28p_3%2C%20p_4%29%20%5Cin%20L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(p_3, p_4) \in L_2' title='(p_3, p_4) \in L_2' class='latex' /> lie on line <img src='http://s.wordpress.com/latex.php?latex=L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_2' title='L_2' class='latex' /><br />
For the remaining part of this article we assume that <img src='http://s.wordpress.com/latex.php?latex=L_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_1' title='L_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_2' title='L_2' class='latex' /> are not parallel.<br />
We need to find two points <img src='http://s.wordpress.com/latex.php?latex=k%2C%20j&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='k, j' title='k, j' class='latex' /> such that<br />
<img src='http://s.wordpress.com/latex.php?latex=%20k%20%5Cin%20L_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt=' k \in L_1' title=' k \in L_1' class='latex' /> that lies on <img src='http://s.wordpress.com/latex.php?latex=L_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_1' title='L_1' class='latex' /> and<br />
<img src='http://s.wordpress.com/latex.php?latex=%20j%20%5Cin%20L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt=' j \in L_2' title=' j \in L_2' class='latex' /> that lies on <img src='http://s.wordpress.com/latex.php?latex=L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_2' title='L_2' class='latex' /> and<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cmin_%7B%7D%20g%5E2%28k%2C%20j%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\min_{} g^2(k, j)' title='\min_{} g^2(k, j)' class='latex' /> where <img src='http://s.wordpress.com/latex.php?latex=g%5E2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='g^2' title='g^2' class='latex' /> (the squared distance function) is minimised</p>
<h3>The old approach:</h3>
<p>Here is a summary of the old approach. I find this method more intuitive.</p>
<ol>
<li>Calculate a plane
<ul>
<li>Calculate the line direction vectors<br />
<img src='http://s.wordpress.com/latex.php?latex=%20%20d_%7B12%7D%20%3D%20p_2%20-%20p_1%5C%5C%20%20d_%7B34%7D%20%3D%20p_4%20-%20p_3%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  d_{12} = p_2 - p_1\\  d_{34} = p_4 - p_3  ' title='  d_{12} = p_2 - p_1\\  d_{34} = p_4 - p_3  ' class='latex' /></li>
<li>Define a plane <img src='http://s.wordpress.com/latex.php?latex=m%3D%28n%2Co%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='m=(n,o)' title='m=(n,o)' class='latex' /> from a direction and point, where<br />
<img src='http://s.wordpress.com/latex.php?latex=%20%20n%20%3D%20%5Cfrac%7B%20d_%7B12%7D%5Ctimes%20d_%7B34%7D%7D%7B%7C%7Cd_%7B12%7D%5Ctimes%20d_%7B34%7D%7C%7C%7D%20%20o%3Dn%5Ccdot%20p_1%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  n = \frac{ d_{12}\times d_{34}}{||d_{12}\times d_{34}||}  o=n\cdot p_1  ' title='  n = \frac{ d_{12}\times d_{34}}{||d_{12}\times d_{34}||}  o=n\cdot p_1  ' class='latex' /></li>
</ul>
</li>
<li>Project the points onto the plane to get two lines in 2D<br />
<img src='http://s.wordpress.com/latex.php?latex=%20%20h%28n%2Co%2Cp%29%20%3D%20n%5C%3A%28n%5Ccdot%20p%20-%20o%29%5C%5C%20%20p_%7Bj1%7D%3Dh%28n%2Co%2C%20p_1%29%5C%5C%20%20p_%7Bj2%7D%3Dh%28n%2Co%2C%20p_2%29%5C%5C%20%20p_%7Bj3%7D%3Dh%28n%2Co%2C%20p_3%29%5C%5C%20%20p_%7Bj4%7D%3Dh%28n%2Co%2C%20p_4%29%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  h(n,o,p) = n\:(n\cdot p - o)\\  p_{j1}=h(n,o, p_1)\\  p_{j2}=h(n,o, p_2)\\  p_{j3}=h(n,o, p_3)\\  p_{j4}=h(n,o, p_4)  ' title='  h(n,o,p) = n\:(n\cdot p - o)\\  p_{j1}=h(n,o, p_1)\\  p_{j2}=h(n,o, p_2)\\  p_{j3}=h(n,o, p_3)\\  p_{j4}=h(n,o, p_4)  ' class='latex' /></li>
<li>Define the two projected lines in the parametric form<br />
<img src='http://s.wordpress.com/latex.php?latex=%20%20L_%7Bj1%7D%28u_1%29%3Dp_%7Bj1%7D%2Bu_1%28p_%7Bj2%7D-p_%7Bj1%7D%29%5C%5C%20%20L_%7Bj2%7D%28u_2%29%3Dp_%7Bj3%7D%2Bu_2%28p_%7Bj4%7D-p_%7Bj3%7D%29%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  L_{j1}(u_1)=p_{j1}+u_1(p_{j2}-p_{j1})\\  L_{j2}(u_2)=p_{j3}+u_2(p_{j4}-p_{j3})  ' title='  L_{j1}(u_1)=p_{j1}+u_1(p_{j2}-p_{j1})\\  L_{j2}(u_2)=p_{j3}+u_2(p_{j4}-p_{j3})  ' class='latex' /></li>
<li>Solve for <img src='http://s.wordpress.com/latex.php?latex=u_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_1' title='u_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=u_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_2' title='u_2' class='latex' /> by calculating the point where the two lines meet i.e. solve the following equation<br />
<img src='http://s.wordpress.com/latex.php?latex=L_%7Bj1%7D%28u_1%29%3DL_%7Bj2%7D%28u_2%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_{j1}(u_1)=L_{j2}(u_2)' title='L_{j1}(u_1)=L_{j2}(u_2)' class='latex' /></li>
<li>Find the closest points <img src='http://s.wordpress.com/latex.php?latex=k%2C%20j&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='k, j' title='k, j' class='latex' /> on <img src='http://s.wordpress.com/latex.php?latex=L_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_1' title='L_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_2' title='L_2' class='latex' /> in 3D using the values of <img src='http://s.wordpress.com/latex.php?latex=u_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_1' title='u_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=u_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_2' title='u_2' class='latex' /> we just calculated<br />
<img src='http://s.wordpress.com/latex.php?latex=k%20%3D%20L_1%28u_1%29%20%3D%20p_1%20%2B%20u_1%5C%3A%28p_2-p_1%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='k = L_1(u_1) = p_1 + u_1\:(p_2-p_1)' title='k = L_1(u_1) = p_1 + u_1\:(p_2-p_1)' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=j%20%3D%20L_2%28u_2%29%20%3D%20p_3%20%2B%20u_2%5C%3A%28p_4-p_3%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='j = L_2(u_2) = p_3 + u_2\:(p_4-p_3)' title='j = L_2(u_2) = p_3 + u_2\:(p_4-p_3)' class='latex' /></li>
</ol>
<p>And finally some pseudocode. Beside each line, the number of floating point operations are listed, so we can compare the two methods later on.</p>
<pre class="brush: c++">
Vector3 d1 = p1-p2; // 3 sub
Vector3 d2 = p4-p3; // 3 sub

// Crate the plane and project the points
Plane m(d1.cross(d2), p1); // 6 mul, 6 add, 3 div, 1 sqrt
Vector3 pj1 = m.project(p1);  // (6 mul, 6 add, 1 sub) X 4
Vector3 pj2 = m.project(p2);
Vector3 pj3 = m.project(p3);
Vector3 pj4 = m.project(p4);

// Calculate line direction in 2D
Vector2 d34 = (Vector2)pj4 - (Vector2)pj3; // 2 sub x3
Vector2 d31 = (Vector2)pj1 - (Vector2)pj3;
Vector2 d12 = (Vector2)pj2 - (Vector2)pj1;

// Calculate u1, u2 in 2D
float t = 1.0 / (d34.y * d12.x - d34.x * d12.y); // 2 mul, 1 sub, 1 div
u[0] = (d12.x * d31.y - d12.y * d31.x) * t ; // 3 mul, 1 sub
u[1] = (d34.x * d31.y - d34.y * d31.x) * t;// 3 mul, 1 sub

// Total # of FP operations
// 49 additions &amp;amp; subtractions,
// 42 multiplications and divisions
// 1 expensive sqrt
</pre>
<h3>Using calculus</h3>
<ol>
<li>Define <img src='http://s.wordpress.com/latex.php?latex=L_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_1' title='L_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_2' title='L_2' class='latex' /> in the parametric form as parameters of <img src='http://s.wordpress.com/latex.php?latex=u_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_1' title='u_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=u_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_2' title='u_2' class='latex' /> respectively<br />
<img src='http://s.wordpress.com/latex.php?latex=%20%20k%20%3D%20L_1%28u_1%29%20%3D%20p_1%20%2B%20u_1%5C%3A%28p_2-p_1%29%5C%5C%20%20j%20%3D%20L_2%28u_2%29%20%3D%20p_3%20%2B%20u_2%5C%3A%28p_4-p_3%29%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  k = L_1(u_1) = p_1 + u_1\:(p_2-p_1)\\  j = L_2(u_2) = p_3 + u_2\:(p_4-p_3)  ' title='  k = L_1(u_1) = p_1 + u_1\:(p_2-p_1)\\  j = L_2(u_2) = p_3 + u_2\:(p_4-p_3)  ' class='latex' /></li>
<li>The distance between the two lines are the points where the two lines are closest to each other.<br />
So&#8230;<br />
We minimise the squared distance between the two lines<img src='http://s.wordpress.com/latex.php?latex=%20%20f%28u_1%2C%20u_2%29%20%3D%20d%5E2%20%3D%20%7C%7CL_2%28u_1%29-L_1%28u_2%29%7C%7C%5E2%20%3D%20%28p_3%20%2B%20u_2%5C%3A%28p_4%20-%20p_3%29%20-%20p_1%20-%20u_1%5C%3A%28p_2-p_1%29%5C%3A%29%5E2%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  f(u_1, u_2) = d^2 = ||L_2(u_1)-L_1(u_2)||^2 = (p_3 + u_2\:(p_4 - p_3) - p_1 - u_1\:(p_2-p_1)\:)^2  ' title='  f(u_1, u_2) = d^2 = ||L_2(u_1)-L_1(u_2)||^2 = (p_3 + u_2\:(p_4 - p_3) - p_1 - u_1\:(p_2-p_1)\:)^2  ' class='latex' /></li>
<li>To minimise <img src='http://s.wordpress.com/latex.php?latex=f%28u_1%2C%20u_2%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(u_1, u_2)' title='f(u_1, u_2)' class='latex' /> we differentiate <img src='http://s.wordpress.com/latex.php?latex=f%28u_1%2C%20u_2%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(u_1, u_2)' title='f(u_1, u_2)' class='latex' /> with respect to <img src='http://s.wordpress.com/latex.php?latex=u_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_1' title='u_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=u_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_2' title='u_2' class='latex' /> and set both equation = 0</li>
<li>We end up with two equations with two unknowns <img src='http://s.wordpress.com/latex.php?latex=u_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_1' title='u_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=u_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_2' title='u_2' class='latex' />. Solve for <img src='http://s.wordpress.com/latex.php?latex=u_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_1' title='u_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=u_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_2' title='u_2' class='latex' />.</li>
<li>Find the closest points <img src='http://s.wordpress.com/latex.php?latex=k%2C%20j&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='k, j' title='k, j' class='latex' /> on <img src='http://s.wordpress.com/latex.php?latex=L_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_1' title='L_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=L_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='L_2' title='L_2' class='latex' /> in 3D using the values of <img src='http://s.wordpress.com/latex.php?latex=u_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_1' title='u_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=u_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_2' title='u_2' class='latex' /> we just calculated<br />
<img src='http://s.wordpress.com/latex.php?latex=%20%20k%20%3D%20L_1%28u_1%29%20%3D%20p_1%20%2B%20u_1%5C%3A%28p_2-p_1%29%5C%5C%20%20j%20%3D%20L_2%28u_2%29%20%3D%20p_3%20%2B%20u_2%5C%3A%28p_4-p_3%29%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  k = L_1(u_1) = p_1 + u_1\:(p_2-p_1)\\  j = L_2(u_2) = p_3 + u_2\:(p_4-p_3)  ' title='  k = L_1(u_1) = p_1 + u_1\:(p_2-p_1)\\  j = L_2(u_2) = p_3 + u_2\:(p_4-p_3)  ' class='latex' /></li>
</ol>
<p>This may sound a lot more complicated, but after working out and simplifying the equations we end up with a much more efficient solution. This will shown below.</p>
<p style="padding-left: 30px;"><img src='http://s.wordpress.com/latex.php?latex=%20%20%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20u_1%7Df%28u_1%2C%20u_2%29%20%3D%202%28u_2%5C%3Ad_%7B21%7D%5Ccdot%20d_%7B34%7D%20-u_1%5C%3Ad_%7B21%7D%5Ccdot%20d_%7B12%7D%20%2B%20d_%7B21%7D%5Ccdot%20d_%7B13%7D%29%20%3D%200%5C%5C%20%20%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20u_2%7Df%28u_1%2C%20u_2%29%20%3D%202%28u_2%5C%3Ad_%7B34%7D%5Ccdot%20d_%7B34%7D%20-u_1%5C%3Ad_%7B34%7D%5Ccdot%20d_%7B12%7D%20%2B%20d_%7B34%7D%5Ccdot%20d_%7B13%7D%29%20%3D%200%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  \frac{\partial}{\partial u_1}f(u_1, u_2) = 2(u_2\:d_{21}\cdot d_{34} -u_1\:d_{21}\cdot d_{12} + d_{21}\cdot d_{13}) = 0\\  \frac{\partial}{\partial u_2}f(u_1, u_2) = 2(u_2\:d_{34}\cdot d_{34} -u_1\:d_{34}\cdot d_{12} + d_{34}\cdot d_{13}) = 0  ' title='  \frac{\partial}{\partial u_1}f(u_1, u_2) = 2(u_2\:d_{21}\cdot d_{34} -u_1\:d_{21}\cdot d_{12} + d_{21}\cdot d_{13}) = 0\\  \frac{\partial}{\partial u_2}f(u_1, u_2) = 2(u_2\:d_{34}\cdot d_{34} -u_1\:d_{34}\cdot d_{12} + d_{34}\cdot d_{13}) = 0  ' class='latex' /></p>
<p><span style="text-decoration: underline;">Where:</span></p>
<p style="padding-left: 30px;"><img src='http://s.wordpress.com/latex.php?latex=%20%20d_%7B21%7D%20%3D%20p_2%20-%20p_1%5C%5C%20%20d_%7B12%7D%20%3D%20p_1%20-%20p_2%20%3D%20-d_%7B21%7D%5C%5C%20%20d_%7B34%7D%20%3D%20p_4%20-%20p_3%5C%5C%20%20d_%7B13%7D%20%3D%20p_3%20-%20p_1%5C%5C%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  d_{21} = p_2 - p_1\\  d_{12} = p_1 - p_2 = -d_{21}\\  d_{34} = p_4 - p_3\\  d_{13} = p_3 - p_1\\  ' title='  d_{21} = p_2 - p_1\\  d_{12} = p_1 - p_2 = -d_{21}\\  d_{34} = p_4 - p_3\\  d_{13} = p_3 - p_1\\  ' class='latex' /></p>
<p>Replacing the value of <img src='http://s.wordpress.com/latex.php?latex=d_%7B12%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='d_{12}' title='d_{12}' class='latex' /> and rewriting the two equations above we get</p>
<p style="padding-left: 30px;"><img src='http://s.wordpress.com/latex.php?latex=%20%20%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20%20u_1%7Df%28u_1%2C%20u_2%29%20%3D%20u_2%5C%3Ad_%7B21%7D%5Ccdot%20d_%7B34%7D%20%2Bu_1%5C%3Ad_%7B21%7D%5Ccdot%20d_%7B21%7D%20%3D%20%20-d_%7B21%7D%5Ccdot%20d_%7B13%7D%20%5C%5C%20%20%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20%20u_2%7Df%28u_1%2C%20u_2%29%20%3D%20u_2%5C%3Ad_%7B34%7D%5Ccdot%20d_%7B34%7D%20%2Bu_1%5C%3Ad_%7B21%7D%5Ccdot%20d_%7B34%7D%20%3D%20%20-d_%7B34%7D%5Ccdot%20d_%7B13%7D%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  \frac{\partial}{\partial  u_1}f(u_1, u_2) = u_2\:d_{21}\cdot d_{34} +u_1\:d_{21}\cdot d_{21} =  -d_{21}\cdot d_{13} \\  \frac{\partial}{\partial  u_2}f(u_1, u_2) = u_2\:d_{34}\cdot d_{34} +u_1\:d_{21}\cdot d_{34} =  -d_{34}\cdot d_{13}  ' title='  \frac{\partial}{\partial  u_1}f(u_1, u_2) = u_2\:d_{21}\cdot d_{34} +u_1\:d_{21}\cdot d_{21} =  -d_{21}\cdot d_{13} \\  \frac{\partial}{\partial  u_2}f(u_1, u_2) = u_2\:d_{34}\cdot d_{34} +u_1\:d_{21}\cdot d_{34} =  -d_{34}\cdot d_{13}  ' class='latex' /></p>
<p>We can write this in the matrix form</p>
<p style="padding-left: 30px;"><img src='http://s.wordpress.com/latex.php?latex=%20%20%5Cbegin%7Bpmatrix%7Da%20%26%20b%5C%5C%20b%20%26%20c%20%5Cend%7Bpmatrix%7D%20%20%5Cbegin%7Bpmatrix%7Du_1%20%5C%5C%20u_2%20%5Cend%7Bpmatrix%7D%20%3D%20%20%5Cbegin%7Bpmatrix%7Dd%20%5C%5C%20e%20%5Cend%7Bpmatrix%7D%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  \begin{pmatrix}a &amp; b\\ b &amp; c \end{pmatrix}  \begin{pmatrix}u_1 \\ u_2 \end{pmatrix} =  \begin{pmatrix}d \\ e \end{pmatrix}  ' title='  \begin{pmatrix}a &amp; b\\ b &amp; c \end{pmatrix}  \begin{pmatrix}u_1 \\ u_2 \end{pmatrix} =  \begin{pmatrix}d \\ e \end{pmatrix}  ' class='latex' /></p>
<p><span style="text-decoration: underline;">Where:</span></p>
<p style="padding-left: 30px;"><img src='http://s.wordpress.com/latex.php?latex=%20%20a%20%3D%20d_%7B21%7D%5Ccdot%20d_%7B21%7D%5C%5C%20%20b%20%3D%20d_%7B21%7D%5Ccdot%20d_%7B34%7D%5C%5C%20%20c%20%3D%20d_%7B34%7D%5Ccdot%20d_%7B34%7D%5C%5C%20%20d%20%3D%20-d_%7B13%7D%5Ccdot%20d_%7B21%7D%5C%5C%20%20e%20%3D%20-d_%7B13%7D%5Ccdot%20d_%7B34%7D%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  a = d_{21}\cdot d_{21}\\  b = d_{21}\cdot d_{34}\\  c = d_{34}\cdot d_{34}\\  d = -d_{13}\cdot d_{21}\\  e = -d_{13}\cdot d_{34}  ' title='  a = d_{21}\cdot d_{21}\\  b = d_{21}\cdot d_{34}\\  c = d_{34}\cdot d_{34}\\  d = -d_{13}\cdot d_{21}\\  e = -d_{13}\cdot d_{34}  ' class='latex' /></p>
<p>Solving for <img src='http://s.wordpress.com/latex.php?latex=u_1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_1' title='u_1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=u_2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='u_2' title='u_2' class='latex' /> to get</p>
<p style="padding-left: 30px;"><img src='http://s.wordpress.com/latex.php?latex=%20%20u_1%20%3D%20%5Cfrac%7Bd%5C%3Ac-e%5C%3Ab%7D%7Bc%5C%3Aa-b%5E2%7D%5C%5C%20%20u_2%3D%5Cfrac%7Be-b%5C%3Au_1%7D%7Bc%7D%20%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='  u_1 = \frac{d\:c-e\:b}{c\:a-b^2}\\  u_2=\frac{e-b\:u_1}{c}  ' title='  u_1 = \frac{d\:c-e\:b}{c\:a-b^2}\\  u_2=\frac{e-b\:u_1}{c}  ' class='latex' /></p>
<p>Note that if <img src='http://s.wordpress.com/latex.php?latex=c%5C%3Aa-b%5E2%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='c\:a-b^2 = 0' title='c\:a-b^2 = 0' class='latex' /> the lines are parallel and then any point on one line can be projected onto the other to get the distance between the two lines. Finally here is some C++ style pseudocode and a count of all operations.</p>
<pre class="brush: c++">

Vector3 d21 = p1-p2; // 3 sub x 3
Vector3 d34 = p4-p3;
Vector3 d13 = p3-p1;

// m * u = x
float a = d21.dot(d21); // (3 mul + 3 add ) x 5
float b = d21.dot(d34);
float c = d34.dot(d34);
float d = -d13.dot(d21);
float e = -d13.dot(d34);

// Solve for u1 &amp;amp;amp;amp;amp;amp;amp;amp;amp; u2
u[0] = (d*c-e*b)/(c*a-b*b); // 4 mul, 2 sub, 1 div
u[1] = (e - b * u[0]) / c; // 1 mul, 1 sub, 1 div

// Total # of FP operations
// 22 multiplications and division
// 27 additions and subtractions
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/361/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Assigning size quotas to folders on Windows</title>
		<link>http://www.gbuffer.net/archives/343</link>
		<comments>http://www.gbuffer.net/archives/343#comments</comments>
		<pubDate>Mon, 16 May 2011 19:08:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[general computers]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=343</guid>
		<description><![CDATA[I was recently given a task where I needed to assign quotas to folders on a Windows system. Preferably without creating multiple users. This could be a very useful feature in budgeting disk space to various users or applications. Now if you do some quick searches on Google you will quickly realise that this specific [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently given a task where I needed to assign quotas to folders on a Windows system. Preferably without creating multiple users. This could be a very useful feature in budgeting disk space to various users or applications. Now if you do some quick searches on Google you will quickly realise that this specific feature is not supported by any version of Windows. Well that&#8217;s a shame! But that does not mean that there is no work around. The solution in one line is to create a virtual disk (vdisk) and mount this vdisk onto a path on the system. All applications will see this path as an ordinary folder but will be restricted by the virtual drive&#8217;s size.</p>
<h3>On Windows 7 and Windows Server 2008</h3>
<p>For those who are not sure how this can be done, the answer is a less well known command line utility called diskpart.exe. Diskpart is able to run scripts using the /s switch. Scripts are nothing but text files with a series of diskpart commands. So the script we need to create will need to do the following&#8230;</p>
<ol>
<li>Create a virtual disk</li>
<li>Create a partition on this virtual disk</li>
<li>Format the virtual disk</li>
<li>Map the virtual disk on to a path</li>
</ol>
<p>The script to do this is as follows. If you prefer, you can start diskpart and type these command in line by line.</p>
<pre class="brush: php">create vdisk file=c:\myDisk.vhd maximum=2048  type=expandable
select vdisk file=c:\myDisk.vhd
attach vdisk
create partition primary
format fs=ntfs quick
assign mount=&quot;c:\my folder&quot;</pre>
<p>A line by line explanation of the script is doing is this</p>
<p>Line 1: Creates a vdisk which will be saved as a file at c:\myDisk.vhd with a size of 2048Mb. The type=expandable part makes sure the size of file depends on the amount of data saved in your vdisk. If you skip this parameter the file will take up the entire 2048Mb of space, even if you have not saved a single byte.<br />
Line 2: makes the vdisk current. This way all future operations will target this vdisk.<br />
Line 3: So far we have only created a vdisk. Think of this command as  connecting the vdisk to your computer (virtually) just as you would connect a USB storage device to a USB port.<br />
Line 4: Creates a partition on the vdisk<br />
Line 5: Format the new partition using NTFS<br />
Line 6: Map the vdisk on to a folder. In this case it is c:\my folder, but you can change this to whatever you like.</p>
<p>So that&#8217;s it. I have made a small batch to automate the process for Windows 7. Get it from the link below.</p>
<p>[<a href="http://dl.dropbox.com/u/757277/www/gbuffer/niknaks/quota.bat"><img title="compress" src="/wp-content/uploads/page_white_script.png" alt="compress" width="16" height="16" /><strong> Download quota.bat</strong></a>]</p>
<h3>On older versions of Windows</h3>
<p>If you are using something older than XP, then I&#8217;m afraid you need to WAKE UP and realise we are in 2011. The stuff mentioned in this section will work only on Windows XP and newer versions.</p>
<p>The problem on older versions of Windows is that diskpart does not support virtual disks. We just need to use different tools to do the same thing, so if you skipped the previous section I suggest you go back and read it again. The bad news is that you will need to download some additional software. The good news is that all these tools are free. These are the tools you will need&#8230;</p>
<ol>
<li>vhdtool.exe (<a href="http://archive.msdn.microsoft.com/vhdtool">From here</a>)</li>
<li>vhdmount by installing <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=bc49c7c8-4840-4e67-8dc4-1e6e218acce4">Microsoft Virtual Server 2005</a>. <span style="text-decoration: underline;">Note</span>: When installing use the custom install option and only select vhdmount from the list. The other components are not needed unless you want to play with them.</li>
</ol>
<p>As mentioned previously, the process is the same one as we did for Windows 7. The step by step process is as follows.</p>
<p><strong>Step 1:</strong> Create a vdisk using vhdtool.exe using the following command line.<br />
VhdTool.exe /create c:\myDisk.vhd 2147483648<br />
There are two differences here. 1 &#8211; The size we enetered here is in bytes, so we need to multiply the number of bytes we want with 1048576 and 2- We don&#8217;t have the option of creating an expandable drive. So the vdisk file will take up all the space requested regardless of how much is actually stored in it.</p>
<p><strong>Step 2:</strong> Connect the vdisk (only virtually of course) using vhdmount.exe<br />
vhdmount.exe /p /f c:\myDisk.vhd</p>
<p><strong>Step 3:</strong> Create a partition on the drive using diskpart. But before we do this, we must first start diskpart<br />
1. Identify the disk number using the diskpart LIST command<br />
LIST DISK<br />
Make a note of the disk number. In my case it is 1.<br />
2. Select the disk using the command<br />
SELECT DISK 1<br />
3. Create the partition like we did before using the CREATE command<br />
CREATE PARTITION PRIMARY</p>
<p><strong>Step 4: </strong> Unfortunately old versions of diskpart don&#8217;t have a format command, so we must do this using the good old format.com. But format.exe only works on drive letters, so that is what we need to do using the ASSIGN command<br />
ASSIGN letter=x<br />
Now, you will need to exit diskpart temporarily using the EXIT command and format the drive using good old format.com. If you have never done this or have gotn&#8217; used to the GUI, this is how it is done from the command line&#8230;<br />
format.com x: /Q /FS:NTFS</p>
<p><strong>Step 5</strong>: Now if you don&#8217;t mind using the drive, you can stop here. Otherwise head back into diskpart to un-mount the volume. Unfortunately since we exited diskpart, we need to reselect the right volume. Get a list of volume using the LIST command as follows<br />
LIST volume<br />
Make a note of the volume number.  It will have the drive letter mentioned under the Ltr column. In this case it is x. Then select it using&#8230;<br />
SELECT volume 2<br />
Then remove the drive letter mapping using the REMOVE command as follows<br />
REMOVE letter=x<br />
And finally map it on to your folder using&#8230;<br />
ASSIGN mount=&#8221;c:\my folder&#8221;</p>
<p>And so that is it. Although you may be able to automate the process using a combination of batch files and grep, I successfully implemented a command line PHP script to automate the process on Windows XP as well. You can also probably use a VB script, but that is not something I am very familiar with. The problem is identifying the disk number in step 3 and volume number in step 5. I used the following process to determine the disk number automatically.</p>
<ol>
<li>Make a list of disks before plugging in the vdisk in step 2.</li>
<li>Use a regex pattern match and extract a list of disk numbers.</li>
<li>Mount the vdisk.</li>
<li>Make another list of disks. This time, the list will have the vdisk that you just mounted.</li>
<li>Identify the disk that is in the second list but not in the first one.</li>
</ol>
<p>Identifying the volume number in step 5 if much simpler. Just use a regex pattern to identify the line which has the drive letter x. The number to the left of it will be the volume number.</p>
<p>There are a lot of other cool things you can do using diskpart that is not available via a GUI. If you don&#8217;t mind getting your hands dirty using the command line, then <a href="http://support.microsoft.com/kb/300415">this is a good place to get started</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/343/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New demo on spherical harmonic lighting</title>
		<link>http://www.gbuffer.net/archives/317</link>
		<comments>http://www.gbuffer.net/archives/317#comments</comments>
		<pubDate>Sat, 08 Jan 2011 00:13:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[demos]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=317</guid>
		<description><![CDATA[Looks like this blog is now being updated bi-annually. The last year or so has been quite a busy time for me. I&#8217;ve been updating my core skills. One of my main targets was to get my head round to understanding a global illumination technique that everyone seems to love so much these days &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Looks like this blog is now being updated bi-annually. The last year or so has been quite a busy time for me. I&#8217;ve been updating my core skills. One of my main targets was to get my head round to understanding a global illumination technique that everyone seems to love so much these days &#8211; spherical harmonic lighting. It took some time for me to get my head around the math, and even more time for me to find the spare time to make an implementation. <a href="/shlighting">Click here to go to the page</a> with details on the implementation and a link to the full source code. As with a lot of things, once I understood what was being done, it all looked quite simple and straight forward. With that being said, I must say I still can&#8217;t claim to be an expert on the subject, but as I time goes by I hope to continue to improve upon it as the need arises.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/317/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A different way to find a point on a hyperplane closest to a given point</title>
		<link>http://www.gbuffer.net/archives/193</link>
		<comments>http://www.gbuffer.net/archives/193#comments</comments>
		<pubDate>Sat, 12 Jun 2010 21:59:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[maths]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=193</guid>
		<description><![CDATA[As a graphics programmer, I often need to find a point on a hyperplane (line or plane) closest to a given point. So far my understanding of the problem has been based on trigonometric concepts that is probably the simplest way of approaching the problem. I&#8217;m not going to explain the boring trigonometric approach to [...]]]></description>
			<content:encoded><![CDATA[<p>As a graphics programmer, I often need to find a point on a hyperplane (line or plane) closest to a given point. So far my understanding of the problem has been based on trigonometric concepts that is probably the simplest way of approaching the problem. I&#8217;m not going to explain the boring trigonometric approach to the problem here. You can find that on some other website using <a href="http://www.google.co.uk/search?q=point%20on%20a%20line%20closest%20to%20a%20given%20point">Google</a>.</p>
<p>A few weeks back I came across a new concept in maths called Lagrange multipliers. In addition to the problem that I was addressing at the time, I was interested in seeing if it could be applied to find a point on a hyperplane closest to a given point.</p>
<p>If you are not familiar with Lagrange multipliers then just go to the <a href="http://en.wikipedia.org/wiki/Lagrange_multipliers">Wikipedia</a> page that explains it all. I think they give a better explanation of the problem than I ever will. Ok, so if you haven&#8217;t already figured out how we are going to approach this problem, read on.</p>
<p>Lets work in 2 dimensions with  a line of the form<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Calpha%20x%2B%5Cbeta%20y%2B%5Cgamma%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\alpha x+\beta y+\gamma = 0' title='\alpha x+\beta y+\gamma = 0' class='latex' /><br />
Lets try and visualize this&#8230;<br />
The vector <img src='http://s.wordpress.com/latex.php?latex=%28%5Calpha%2C%5Cbeta%29%5ET&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(\alpha,\beta)^T' title='(\alpha,\beta)^T' class='latex' /> represents the normal to the line<br />
The constant <img src='http://s.wordpress.com/latex.php?latex=%5Cgamma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\gamma' title='\gamma' class='latex' /> is the distance to closest point on the line to the origin.<br />
If you are used to only seeing the line in the slope intercept form as <img src='http://s.wordpress.com/latex.php?latex=y%3Dmx%20%2B%20b&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='y=mx + b' title='y=mx + b' class='latex' /><br />
then we can simply assume that<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Calpha%20%3D%20m&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\alpha = m' title='\alpha = m' class='latex' />, <img src='http://s.wordpress.com/latex.php?latex=%5Cbeta%20%3D%20-1&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\beta = -1' title='\beta = -1' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=%5Cgamma%20%3D%20b&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\gamma = b' title='\gamma = b' class='latex' />.</p>
<p>Now lets take our point <img src='http://s.wordpress.com/latex.php?latex=P%3D%28x_p%2C%20y_p%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='P=(x_p, y_p)' title='P=(x_p, y_p)' class='latex' /> in space. Now we would like to do is minimise the Euclidean distance to this point.  The Euclidean distance is calculated using the equation<br />
<img src='http://s.wordpress.com/latex.php?latex=f%28x%2C%20y%29%20%3D%20%5Csqrt%7B%28x-x_%7Bp%7D%29%5E2%2B%28y-y_%7Bp%7D%29%5E2%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(x, y) = \sqrt{(x-x_{p})^2+(y-y_{p})^2}' title='f(x, y) = \sqrt{(x-x_{p})^2+(y-y_{p})^2}' class='latex' /><br />
Minimizing this problem is dead simple. The closest point to a point is the point it self. But now we would like to add a constraint such that the closest point must lie of the line, whose equation is<br />
<img src='http://s.wordpress.com/latex.php?latex=g%28x%2Cy%29%20%3D%20%5Calpha%20x%20%2B%20%5Cbeta%20y%20%2B%20%5Cgamma%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='g(x,y) = \alpha x + \beta y + \gamma = 0' title='g(x,y) = \alpha x + \beta y + \gamma = 0' class='latex' /><br />
We approach this problem using a simple form of the Lagrange multiplier where we minimize the function <img src='http://s.wordpress.com/latex.php?latex=f%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(x,y)' title='f(x,y)' class='latex' /> subject to the constraint <img src='http://s.wordpress.com/latex.php?latex=g%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='g(x,y)' title='g(x,y)' class='latex' />. The best way to show that this works is with an example so&#8230;</p>
<h3>Lets try this with an example</h3>
<p>Lets assume we have a line of the form<br />
<img src='http://s.wordpress.com/latex.php?latex=y%3D0.5%20x%20%2B%201&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='y=0.5 x + 1' title='y=0.5 x + 1' class='latex' /> and we would like to find a point on this line that is closest to a given point <img src='http://s.wordpress.com/latex.php?latex=P%20%3D%20%283%2C2%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='P = (3,2)' title='P = (3,2)' class='latex' /></p>
<p>We know the general form of the Lagrange multiplier which states that<br />
<img src='http://s.wordpress.com/latex.php?latex=f%28x%2Cy%29%20%3D%20-%5Clambda%5C%3A%20g%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(x,y) = -\lambda\: g(x,y)' title='f(x,y) = -\lambda\: g(x,y)' class='latex' /><br />
In English this simply means the that we need to find a point <img src='http://s.wordpress.com/latex.php?latex=X%20%3D%20%28x%2C%20y%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='X = (x, y)' title='X = (x, y)' class='latex' /> where the functions <img src='http://s.wordpress.com/latex.php?latex=f%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(x,y)' title='f(x,y)' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=g%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='g(x,y)' title='g(x,y)' class='latex' /> give us vectors that point in the same direction. By multiplying one of the vectors with a constant <img src='http://s.wordpress.com/latex.php?latex=-%5Clambda&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='-\lambda' title='-\lambda' class='latex' /> we make both  vectors equal in length and direction. We could also write the equation above as<br />
<img src='http://s.wordpress.com/latex.php?latex=%5CLambda%28x%2Cy%2C%5Clambda%29%20%3D%20f%28x%2Cy%29%2B%5Clambda%5C%3A%20g%28x%2Cy%29%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Lambda(x,y,\lambda) = f(x,y)+\lambda\: g(x,y) = 0' title='\Lambda(x,y,\lambda) = f(x,y)+\lambda\: g(x,y) = 0' class='latex' /></p>
<p>Before we start we change our distance function to a squared distance function. So in this case <img src='http://s.wordpress.com/latex.php?latex=f%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(x,y)' title='f(x,y)' class='latex' /> would become<br />
<img src='http://s.wordpress.com/latex.php?latex=f%28x%2Cy%29%20%3D%20%28x-3%29%5E2%2B%28y-2%29%5E2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(x,y) = (x-3)^2+(y-2)^2' title='f(x,y) = (x-3)^2+(y-2)^2' class='latex' /><br />
We can do this because <img src='http://s.wordpress.com/latex.php?latex=f%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f(x,y)' title='f(x,y)' class='latex' /> is just a function that needs to be minimised and for us it does not make a difference if we minimise the distance or the squared distance. We make this change as differentiating the squared distance function is much simpler and results in a system of linear equations. The function <img src='http://s.wordpress.com/latex.php?latex=g%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='g(x,y)' title='g(x,y)' class='latex' /> remains the same.</p>
<p>So now we need to find<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cnabla_%7Bx%2Cy%2C%5Clambda%7D%5CLambda%28x%2Cy%2C%5Clambda%29%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\nabla_{x,y,\lambda}\Lambda(x,y,\lambda) = 0' title='\nabla_{x,y,\lambda}\Lambda(x,y,\lambda) = 0' class='latex' /><br />
In this case<br />
<img src='http://s.wordpress.com/latex.php?latex=%5CLambda%28x%2Cy%2C%5Clambda%29%20%3D%20%28x-3%29%5E2%20%2B%20%28y-2%29%5E2%20%2B%20%5Clambda%5C%3A%280.5x-y%2B1%29%3D0&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Lambda(x,y,\lambda) = (x-3)^2 + (y-2)^2 + \lambda\:(0.5x-y+1)=0' title='\Lambda(x,y,\lambda) = (x-3)^2 + (y-2)^2 + \lambda\:(0.5x-y+1)=0' class='latex' /><br />
We now need to find<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%5Cdisplaystyle%5Cpartial%7D%7B%5Cdisplaystyle%5Cpartial%20x%7D%5CLambda%28x%2Cy%2C%5Clambda%29%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{\displaystyle\partial}{\displaystyle\partial x}\Lambda(x,y,\lambda) = 0' title='\frac{\displaystyle\partial}{\displaystyle\partial x}\Lambda(x,y,\lambda) = 0' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%5Cdisplaystyle%5Cpartial%7D%7B%5Cdisplaystyle%5Cpartial%20y%7D%5CLambda%28x%2Cy%2C%5Clambda%29%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{\displaystyle\partial}{\displaystyle\partial y}\Lambda(x,y,\lambda) = 0' title='\frac{\displaystyle\partial}{\displaystyle\partial y}\Lambda(x,y,\lambda) = 0' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%5Cdisplaystyle%5Cpartial%7D%7B%5Cdisplaystyle%20%5Cpartial%20%5Clambda%7D%5CLambda%28x%2Cy%5Clambda%29%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{\displaystyle\partial}{\displaystyle \partial \lambda}\Lambda(x,y\lambda) = 0' title='\frac{\displaystyle\partial}{\displaystyle \partial \lambda}\Lambda(x,y\lambda) = 0' class='latex' /><br />
After doing all the hairy math, we get<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%5Cdisplaystyle%20%5Cpartial%7D%7B%5Cdisplaystyle%20%5Cpartial%20x%7D%5CLambda%28x%2Cy%2C%5Clambda%29%20%3D%200.5%5Clambda%2B2x-6%3D0&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{\displaystyle \partial}{\displaystyle \partial x}\Lambda(x,y,\lambda) = 0.5\lambda+2x-6=0' title='\frac{\displaystyle \partial}{\displaystyle \partial x}\Lambda(x,y,\lambda) = 0.5\lambda+2x-6=0' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%5Cdisplaystyle%5Cpartial%7D%7B%5Cdisplaystyle%5Cpartial%20y%7D%5CLambda%28x%2Cy%2C%5Clambda%29%20%3D%20-%5Clambda%20%2B%202y%20-4%3D0&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{\displaystyle\partial}{\displaystyle\partial y}\Lambda(x,y,\lambda) = -\lambda + 2y -4=0' title='\frac{\displaystyle\partial}{\displaystyle\partial y}\Lambda(x,y,\lambda) = -\lambda + 2y -4=0' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%5Cdisplaystyle%5Cpartial%7D%7B%5Cdisplaystyle%5Cpartial%20%5Clambda%20%7D%20%5CLambda%28x%2Cy%2C%5Clambda%29%20%3D0.5x-y%2B1%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{\displaystyle\partial}{\displaystyle\partial \lambda } \Lambda(x,y,\lambda) =0.5x-y+1= 0' title='\frac{\displaystyle\partial}{\displaystyle\partial \lambda } \Lambda(x,y,\lambda) =0.5x-y+1= 0' class='latex' /><br />
We now have a system of three linear equations with three unknowns. This should be fairly easy to solve using a number of methods. If we had used the distance function instead of the squared distance, we would have ended up with a system of non-linear equations which would not been so easy to solve.</p>
<p>Ok so after solving for <img src='http://s.wordpress.com/latex.php?latex=x%2Cy%2C%5Clambda&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='x,y,\lambda' title='x,y,\lambda' class='latex' /> we get<br />
<img src='http://s.wordpress.com/latex.php?latex=x%3D%5Cfrac%7B14%7D%7B5%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='x=\frac{14}{5}' title='x=\frac{14}{5}' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=y%3D%5Cfrac%7B12%7D%7B5%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='y=\frac{12}{5}' title='y=\frac{12}{5}' class='latex' /><br />
We are not really interested in <img src='http://s.wordpress.com/latex.php?latex=%5Clambda&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\lambda' title='\lambda' class='latex' /> anymore, so we shall leave that out. So the point on the line is<br />
<img src='http://s.wordpress.com/latex.php?latex=X%3D%5Cleft%20%28%5Cfrac%7B14%7D%7B5%7D%2C%20%5Cfrac%7B12%7D%7B5%7D%20%5Cright%20%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='X=\left (\frac{14}{5}, \frac{12}{5} \right )' title='X=\left (\frac{14}{5}, \frac{12}{5} \right )' class='latex' /></p>
<p>We can use several different methods to verify if this answer is correct. We can solve for the same point using the trigonometric method or we can check if the vectors <img src='http://s.wordpress.com/latex.php?latex=%5Coverrightarrow%7BPX%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\overrightarrow{PX}' title='\overrightarrow{PX}' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=%5Coverrightarrow%7BAX%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\overrightarrow{AX}' title='\overrightarrow{AX}' class='latex' /> are orthonormal to each other. Here <img src='http://s.wordpress.com/latex.php?latex=A&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='A' title='A' class='latex' /> is just another point on our line. We shall use the latter method to verify our results. We already have<br />
<img src='http://s.wordpress.com/latex.php?latex=P%3D%283%2C%202%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='P=(3, 2)' title='P=(3, 2)' class='latex' />, <img src='http://s.wordpress.com/latex.php?latex=X%3D%5Cleft%28%5Cfrac%7B14%7D%7B5%7D%2C%20%5Cfrac%7B12%7D%7B5%7D%5Cright%20%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='X=\left(\frac{14}{5}, \frac{12}{5}\right )' title='X=\left(\frac{14}{5}, \frac{12}{5}\right )' class='latex' />. We can find <img src='http://s.wordpress.com/latex.php?latex=A&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='A' title='A' class='latex' /> by just setting <img src='http://s.wordpress.com/latex.php?latex=x%3D0&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='x=0' title='x=0' class='latex' /> in line equation. So we get<br />
<img src='http://s.wordpress.com/latex.php?latex=A%3D%280%2C%201%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='A=(0, 1)' title='A=(0, 1)' class='latex' /><br />
So we get<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Coverrightarrow%7BAX%7D%20%3D%20%5Cleft%20%28%20-%5Cfrac%7B14%7D%7B5%7D%2C%20-%5Cfrac%7B7%7D%7B5%7D%20%5Cright%20%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\overrightarrow{AX} = \left ( -\frac{14}{5}, -\frac{7}{5} \right )' title='\overrightarrow{AX} = \left ( -\frac{14}{5}, -\frac{7}{5} \right )' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=%5Coverrightarrow%7BPX%7D%20%3D%20%5Cleft%20%28%20%5Cfrac%7B1%7D%7B5%7D%2C%20-%5Cfrac%7B2%7D%7B5%7D%20%5Cright%20%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\overrightarrow{PX} = \left ( \frac{1}{5}, -\frac{2}{5} \right )' title='\overrightarrow{PX} = \left ( \frac{1}{5}, -\frac{2}{5} \right )' class='latex' /><br />
and&#8230;<br />
<img src='http://s.wordpress.com/latex.php?latex=%5Clangle%5Coverrightarrow%7BAX%7D%2C%5Coverrightarrow%7BPX%7D%5Crangle%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\langle\overrightarrow{AX},\overrightarrow{PX}\rangle= 0' title='\langle\overrightarrow{AX},\overrightarrow{PX}\rangle= 0' class='latex' /><br />
<strong><br />
&#8230;or in plain English: IT WORKS!!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/193/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Key Xchanger &#8211; The bluetooth enabled password manager</title>
		<link>http://www.gbuffer.net/archives/185</link>
		<comments>http://www.gbuffer.net/archives/185#comments</comments>
		<pubDate>Mon, 22 Mar 2010 19:39:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=185</guid>
		<description><![CDATA[If I was going to put all my passwords in to one database, it better be protected by a good password - a very good one, one which I would not be able to remember. Of course this does not mean I do something stupid like write it on a piece of paper.Duh!]]></description>
			<content:encoded><![CDATA[<p>A while back I was looking for a good way to create a <strong>very</strong> strong password for my <a href="http://keepass.info/">KeePass Password Safe</a>. If I was going to put all my passwords in to one database, it better be protected by a good password &#8211; a very good one, one which I would not be able to remember. Of course this does not mean I do something stupid like write it on a piece of paper. Duh!</p>
<ul>
<li>A USB stick? Ah too simple.</li>
<li><a href="http://yubico.com/home/index/">YubiKey</a>? Sounded very cool initially, but only can work with one password at a time and another device to take care of. And it was USB &#8211; too much friction if I had to enter the password 5-10 times a day.</li>
<li>My phone: Ah perfect, it&#8217;s very personal. I never leave anywhere without it. WHich means it won&#8217;t be forgotten in my USB port when I&#8217;m out. And yeah, it&#8217;s got bluetooth (no shoving stuff in to usb ports).</li>
</ul>
<p>So I set out to make a bluetooth app that could exchange keys with KeePass. Head on to the <a href="/kxch">KeyXchanger </a>page to get more info and download it.</p>
<h3><strong>The stand alone password exchanger</strong></h3>
<p>Even if you do not use KeePass, you can still use Key Xchanger. The download contains a stand alone application that allows your computer to exchange passwords with your phone. Some features of Key Xchanger are&#8230;</p>
<ul>
<li>All passwords are stored on your phone encrypted.</li>
<li>Passwords on the phone are encrypted and can only be decrypted by an authorized computer</li>
<li>Your password is not compromised even if you loose your phone, since one needs to attack both your phone and computer. This is extremely unlikely to happen.</li>
<li>Passwords are never stored on the PC and are discarded immediately after being used.</li>
<li>You can enter passwords in to almost any application on windows</li>
</ul>
<p><strong>Due to the large number of phones out there I would appreciate it if you could tell me if the application worked for you.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/185/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keyboard remap &#8211; Change, disable or remap keys on Windows</title>
		<link>http://www.gbuffer.net/archives/163</link>
		<comments>http://www.gbuffer.net/archives/163#comments</comments>
		<pubDate>Wed, 10 Jun 2009 06:45:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[general computers]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=163</guid>
		<description><![CDATA[Very often you need to disable or remap keys to new characters on your keyboard. This post explains how I did this without the need for any additional software running in background and a small guide on how you can do this on your own with software that is available free on the internet.]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;">The problem</span>: For a long time I have tried various methods to disable the worst key on the keyboard &#8211; the CAPS lock. In my opinion, it provides no real function and yet is placed in a position where it can be easily be pressed.</p>
<h3><a href="http://www.autohotkey.com/">AutoHotKey</a></h3>
<p><span style="text-decoration: underline;">Attempt 1</span>: Initially I disabled this key using an <strong><a href="http://www.autohotkey.com/">AutoHotKey</a></strong> script. But for some reason, the script would stop working and I would still find CAPS LOCK ON just when I was entering that password or something. Besides every new computer I went to needed to have AutoHotKey or a compiled .exe just for this purpose. Since I am fanatical about keeping 24&#215;7 background apps to a minimal, this was a big no no. And finally, even though I think AutoHotKey is a very useful app, I doubt it can be used as a full scale keyboard  remapper.</p>
<h3><a href="http://webpages.charter.net/krumsick/">KeyTweak</a></h3>
<p><span style="text-decoration: underline;">Attempt 2</span>: After being pushed over the edge with AutoHotKey&#8217;s incompetence in this area, my hunt for a new application continued. After some modified google search terms and fresh hope for luck, I came across <strong><a href="http://webpages.charter.net/krumsick/">KeyTweak</a></strong>, among others which included plain old <strong><a href="http://www.microsoft.com/whdc/archive/w2kscan-map.mspx">registry hacking</a></strong> and several incarnations or AutoHotKey. KeyTweak did just what I wanted. Once initial the configuration was made, it would do all the dirty registry hacing for me and I did not need any software to running in the background.</p>
<p>But now I was faced with a new problem, and this time it was caused due to personal circumstances. I had recently moved to a new country and this meant getting used to a whole new keyboard layout just for one new charecter &#8211; £. I think you know which country I am talking about. Initially I resisted by opening &#8216;Character Map&#8217; and copying the £ symbol from the table. But soon I realized that this was happening more often than not and I needed another solution.</p>
<p>Secondly even if I did give in and decide to get used to a new keyboard layout, I&#8217;d still be stuck with a US keyboard on my laptop. Changing that would be a fairly expensive affair and if I didn&#8217;t it would mean different keyboard layouts on different computers which can get very very irritating. I say this out of experience.</p>
<p>AutoHotKey &#8211; Although this could do the job, I was still against having an app running in the background just so that it could type the £ for me. But until I found a better solution, this was going to be the answer to the problem.<br />
KeyTweak &#8211; Although this could remap keys to others, somehow it was not able to find the £ character for me.</p>
<h3><a href="http://msdn.microsoft.com/en-gb/goglobal/bb964665.aspx">Microsoft Keyboard Layout Creator</a></h3>
<p><span style="text-decoration: underline;">Attempt 3</span>: So once again it was back to google. That is when I found &#8216;<strong><a href="http://msdn.microsoft.com/en-gb/goglobal/bb964665.aspx">Microsoft Keyboard Layout Creator</a></strong>&#8216;. From the depths of Microsoft&#8217;s lair lies this little known app that can do pretty much anything and everything you wanted. Basically you create a whole new keyboard layout, just like the professionals do.</p>
<p><img class="size-medium wp-image-164 alignnone" title="msklc" src="http://www.gbuffer.net/wp-content/uploads/msklc-300x146.png" alt="msklc" width="300" height="146" /></p>
<p><strong>A quick guide to using <a href="http://msdn.microsoft.com/en-gb/goglobal/bb964665.aspx">Microsoft Keyboard Layout Creator</a></strong></p>
<ol>
<li>So once you have done the obvious download and install, run the application.</li>
<li>If you are like me and want to remap change a few keys, then load your current keyboard layout by going to<br />
<strong>File </strong>&gt; <strong>Load existing keyboard</strong></li>
<li>If you are not sure which keyboard layout you are using, you can find this by going to<br />
<strong>Control Panel</strong> &gt; <strong>Regional and Language Options</strong> &gt; <strong>Languages</strong> (tab) &gt; <strong>Details</strong> (button)</li>
<li>Reconfigure the keys to the way you like it</li>
<li>Create a new installation package by going to<br />
<strong>Project</strong> &gt; <strong>Build DLL and Setup Package<br />
</strong>Follow the instructions and create a installation package. Remember to give it a name that you can identify later.</li>
<li>Install the new layout using the installation package</li>
<li>Go to<br />
<strong>Control Panel</strong> &gt; <strong>Regional and Language Options</strong> &gt; <strong>Languages</strong> (tab) &gt; <strong>Details</strong> (button)<br />
Beside the tree view, click <strong>Add&#8230;</strong> and select the new keyboard layout that you just created.</li>
<li>Activate it by selecting the new layout from the drop down menu where is says<br />
&#8216;<strong>Default input language</strong>&#8216;<br />
Alternatively, you can switch between this layout and your old layout by enabling the language bar.</li>
</ol>
<p>I hope this guide helps you get the most out of your keyboard.</p>
<p><em>All links are verified to be valid at the time of writing this post. If any of the links in this article or anywhere else on my blog are broken, let me know via the comments and I shall do my best to fix it.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/163/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TerminateApp: Close, don&#8217;t kill that app</title>
		<link>http://www.gbuffer.net/archives/152</link>
		<comments>http://www.gbuffer.net/archives/152#comments</comments>
		<pubDate>Mon, 11 May 2009 19:38:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=152</guid>
		<description><![CDATA[Recently when automating certain tasks, I came across the need for a command line app that would close windows applications in a clean way. After a lot of searching I was surprised not to find something to do this simple task. Yes there a lot of tools to kill an application, but that was not [...]]]></description>
			<content:encoded><![CDATA[<p>Recently when automating certain tasks, I came across the need for a command line app that would close windows applications in a clean way. After a lot of searching I was surprised not to find something to do this simple task. Yes there a lot of tools to kill an application, but that was not what I was looking for.</p>
<p><span style="text-decoration: underline;">Why?</span><br />
Well, a lot of applications perform a lot of important tasks before they close. These range from saving settings, asking you to save files, releasing hooks. Whatever the task may be, if you killing an application stop it dead in it&#8217;s tracks and the app does not have a chance to perform these tasks.</p>
<p>So TerminateApp is the result of this necessity.<br />
You can specify the process by it&#8217;s name or by it&#8217;s process ID. If you really are impatient, you can even kill the application if the application refuses to terminate within a given amount of time.</p>
<p><span style="text-decoration: underline;">How does it work?<br />
</span>TerminateApp sends a WM_QUIT message to all window handles within a specified process. So it will only work for applications that process the WM_QUIT message. This worked fine for the several applications I tested it on, but I cannot guarantee it works on all the apps out there. This would depend on the way the app has been written.</p>
<p>[<a href="https://files.getdropbox.com/u/757277/www/gbuffer/niknaks/ta/TerminateApp.zip"><img class="alignnone size-full wp-image-153" title="compress" src="http://www.gbuffer.net/wp-content/uploads/compress.png" alt="compress" width="16" height="16" /><strong> Download TerminateApp</strong></a>]<br />
[<a title="Source code" href="https://files.getdropbox.com/u/757277/www/gbuffer/niknaks/ta/TerminateAppSrc.zip"><img class="alignnone size-full wp-image-154" title="page_white_cplusplus" src="http://www.gbuffer.net/wp-content/uploads/page_white_cplusplus.png" alt="page_white_cplusplus" width="16" height="16" /> Download Source Code</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/152/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vector Texture v1</title>
		<link>http://www.gbuffer.net/archives/136</link>
		<comments>http://www.gbuffer.net/archives/136#comments</comments>
		<pubDate>Fri, 27 Mar 2009 14:06:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[demos]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=136</guid>
		<description><![CDATA[It&#8217;s been some time since anything technical has been posted here. Been spending my time building up a stronger base since the top seemed a little wobbly. Got a new demo out today. It&#8217;s something that some people (including me) call vector textures. A very interesting technique that uses the existing texture resizing methods implemented [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been some time since anything technical has been posted here. Been spending my time building up a stronger base since the top seemed a little wobbly.</p>
<p>Got a new demo out today. It&#8217;s something that some people (including me) call vector textures. A very interesting technique that uses the existing texture resizing methods implemented on the GPU. These days it&#8217;s hard to find graphics techniques that manage really makes use of everything the GPU provides us with. What&#8217;s even nicer is that this technique could improve existing methods of rendering things like text and could even be extended to rendering blades of grass or leaves on a tree where the possibility of zooming in to a leaf is very real.</p>
<p>Go ahead, <a href="/vector-textures">read more about it and download the demo here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/136/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chamrajpet Charles</title>
		<link>http://www.gbuffer.net/archives/113</link>
		<comments>http://www.gbuffer.net/archives/113#comments</comments>
		<pubDate>Wed, 10 Dec 2008 22:44:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[leisure]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=113</guid>
		<description><![CDATA[Hey, What you doing child&#8230; Loafing around the internet like a college boy outside a girl&#8217;s college. For those of you who don&#8217;t know who Chamrajpet Charles is, I&#8217;ll forgive you. If you have not heard of him, I seriously doubt you will be able to fully appreciate this post For the rest, you will [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Hey, What you doing child&#8230;</strong><br />
Loafing around the internet like a college boy outside a girl&#8217;s college.</p>
<p>For those of you who don&#8217;t know who Chamrajpet Charles is, I&#8217;ll forgive you. If you have not heard of him, I seriously doubt you will be able to fully appreciate this post</p>
<p>For the rest, you will get some upper cuts on your kidneys if you lie only. So for all CC fans out there, here are some rips that will make you feel at home, where ever you are</p>
<p>He makes me laugh no matter what my mood. Feel free to download them to your computer. And now for my track collection&#8230;</p>
<p><span id="more-113"></span></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="7%">20 20</td>
<td width="300"></td>
<td><a href="http://www.gbuffer.net/wp-content/audio/cc/2020.mp3">Download</a></td>
</tr>
<tr>
<td width="7%">Accountant</td>
<td width="300"></td>
<td><a href="http://www.gbuffer.net/wp-content/audio/cc/Accountatnt.mp3">Download</a></td>
</tr>
<tr>
<td width="7%">Cricket Fever</td>
<td width="300"></td>
<td><a href="http://www.gbuffer.net/wp-content/audio/cc/CricketFever.mp3">Download</a></td>
</tr>
<tr>
<td width="7%">Mobile Ban</td>
<td width="300"></td>
<td><a href="http://www.gbuffer.net/wp-content/audio/cc/MobileBan.mp3">Download</a></td>
</tr>
<tr>
<td width="7%">Petrol Strike</td>
<td width="300"></td>
<td><a href="http://www.gbuffer.net/wp-content/audio/cc/PetrolStrike.mp3">Download</a></td>
</tr>
<tr>
<td width="7%">President Rule</td>
<td width="300"></td>
<td><a href="http://www.gbuffer.net/wp-content/audio/cc/PresidentRule.mp3">Download</a></td>
</tr>
<tr>
<td width="7%">Metro Fever</td>
<td width="300"></td>
<td><a href="http://www.gbuffer.net/wp-content/audio/cc/MetroFever.mp3">Download</a></td>
</tr>
<tr>
<td width="7%">Yellow Fever</td>
<td width="300"></td>
<td><a href="http://www.gbuffer.net/wp-content/audio/cc/YellowFever.mp3">Download</a></td>
</tr>
</tbody>
</table>
<p>I wish I was still in Bangalore. I would have recorded many more from the radio. Hey all you buggers out there in Bangalore, if anyone has any more links / recordings, send them to me or leave a comment below. Or else I will have to give two cracks on your elbows.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/113/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://www.gbuffer.net/wp-content/audio/cc/2020.mp3" length="559300" type="audio/mpeg" />
<enclosure url="http://www.gbuffer.net/wp-content/audio/cc/Accountatnt.mp3" length="521626" type="audio/mpeg" />
<enclosure url="http://www.gbuffer.net/wp-content/audio/cc/CricketFever.mp3" length="497420" type="audio/mpeg" />
<enclosure url="http://www.gbuffer.net/wp-content/audio/cc/MobileBan.mp3" length="610988" type="audio/mpeg" />
<enclosure url="http://www.gbuffer.net/wp-content/audio/cc/PetrolStrike.mp3" length="440272" type="audio/mpeg" />
<enclosure url="http://www.gbuffer.net/wp-content/audio/cc/PresidentRule.mp3" length="525266" type="audio/mpeg" />
<enclosure url="http://www.gbuffer.net/wp-content/audio/cc/MetroFever.mp3" length="496692" type="audio/mpeg" />
<enclosure url="http://www.gbuffer.net/wp-content/audio/cc/YellowFever.mp3" length="344540" type="audio/mpeg" />
		</item>
		<item>
		<title>Water you can swim in</title>
		<link>http://www.gbuffer.net/archives/93</link>
		<comments>http://www.gbuffer.net/archives/93#comments</comments>
		<pubDate>Sun, 19 Oct 2008 09:47:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[demos]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=93</guid>
		<description><![CDATA[Water you can swim in&#8230; Well only virtually This is my very first graphical demo built on a excellent open source framework called G3D. Demo is based on two chapters in the ShaderX book. &#8220;Rendering Ocean Water&#8221; by John Isidoro, Alex Vlachos, Chris Brennan And &#8220;Rippling Refractive and Reflective Water&#8221; by Alex Vlachos, John Isidoro [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gbuffer.net/demos"><img alt="Water!!!" src="http://www.gbuffer.net/files/G3D/demos/water/small.jpg" title="Water Demo" width="225" height="176" /></a> Water you can swim in&#8230; Well only virtually <img src='http://www.gbuffer.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  This is my very first graphical demo built on a excellent open source <a href="http://g3d-cpp.sourceforge.net/">framework called G3D</a>.</p>
<p>Demo is based on two chapters in the <a href="http://www.shaderx.com/">ShaderX</a> book.<br />
&#8220;Rendering Ocean Water&#8221;<br />
by John Isidoro, Alex Vlachos, Chris Brennan<br />
And<br />
&#8220;Rippling Refractive and Reflective Water&#8221;<br />
by Alex Vlachos, John Isidoro and Chris Oat</p>
<p>Features include</p>
<ol>
<li>Realtime vertex displacement</li>
<li>Full control over speed, wave direction, amplitude and frequency</li>
<li>Additional detailing via two normal maps</li>
<li>Fake refractions that look real</li>
<li>Real time reflections or reflections via environment maps</li>
<li>Fully configurable water color via texture maps</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/93/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

