<?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>lithium flowers bloom &#187; matrix</title>
	<atom:link href="http://leejayxia.com/blog/tag/matrix/feed/" rel="self" type="application/rss+xml" />
	<link>http://leejayxia.com/blog</link>
	<description>the weblog</description>
	<lastBuildDate>Sat, 15 May 2010 20:52:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>I wish I know more trigs</title>
		<link>http://leejayxia.com/blog/i-wish-i-know-more-trigs/</link>
		<comments>http://leejayxia.com/blog/i-wish-i-know-more-trigs/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 06:46:10 +0000</pubDate>
		<dc:creator>L.J</dc:creator>
				<category><![CDATA[Mainstreaming Info]]></category>
		<category><![CDATA[geodata]]></category>
		<category><![CDATA[globe]]></category>
		<category><![CDATA[ITP]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[rotation]]></category>
		<category><![CDATA[Spring 2009]]></category>

		<guid isPermaLink="false">http://leejayxia.com/blog/?p=625</guid>
		<description><![CDATA[Did too much soldering today. I&#8217;ll just post some screenshots as update for the U.S. intervention history visualization. Since last the most effort regarding this project was spent on figuring out the tech details on building interaction into the spinning globe. I wish I know more about trigs! Several tips to put down for myself: [...]]]></description>
			<content:encoded><![CDATA[<p>Did too much soldering today. I&#8217;ll just post some screenshots as update for the U.S. intervention history visualization. Since last the most effort regarding this project was spent on figuring out the tech details on building interaction into the spinning globe. I wish I know more about trigs!</p>
<p>Several tips to put down for myself:</p>
<p>- move textFont() out of the loop;<br />
- do not create font on the fly if using huge font size;<br />
- screenX and screenY are your friends (while creating mouse over interaction in 3D) (Thanks Dan!);<br />
- rotation is headache, rotation in 3D is huge headache:</p>
<p>I had some rotation and translation params of a point generated by geo data. It&#8217;s easy to get params in those forms when you&#8217;re dealing with a sphere. Such point can easily be drawn with a series of rotate() and translate(), and a box() or sphere(), however I want to calculate the actual coordinates of those points in the 3D space to place attractors / draw lines / whatever.</p>
<p>I wish I paid enough attention while I learned trigs in high school, but I ended up looking into processing core source code and did something like this:</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">PVector rotation <span style="color: #339933;">=</span> getRotation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// the rotation params that i do have</span><br />
<span style="color: #000066; font-weight: bold;">float</span> offsetZ <span style="color: #339933;">=</span> <span style="color: #cc66cc;">500</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// some arbitrary number</span><br />
<br />
PMatrix3D m <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PMatrix3D<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
m.<span style="color: #006633;">rotateY</span><span style="color: #009900;">&#40;</span>rotation.<span style="color: #006633;">y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
m.<span style="color: #006633;">rotateX</span><span style="color: #009900;">&#40;</span>rotation.<span style="color: #006633;">x</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//more 3D transformation here</span><br />
<br />
m.<span style="color: #006633;">translate</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>, offsetZ<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// just do whatever I would do in normal draw loop</span><br />
PVector l <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PVector<span style="color: #009900;">&#40;</span>m.<span style="color: #006633;">m03</span>,m.<span style="color: #006633;">m13</span>,m.<span style="color: #006633;">m23</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>It&#8217;s basically just reusing the PMatrix3D class which is used internally in 3D transformation in processing, but I&#8217;m so happy not having to figure out the math myself.</p>
<p>More experiments:<br />
<a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-14.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-638" title="picture-14" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-14-300x198.png" alt="picture-14" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-13.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-637" title="picture-13" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-13-300x198.png" alt="picture-13" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-12.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-636" title="picture-12" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-12-300x198.png" alt="picture-12" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-10.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-635" title="picture-10" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-10-300x198.png" alt="picture-10" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-9.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-634" title="picture-9" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-9-300x198.png" alt="picture-9" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-8.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-633" title="picture-8" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-8-300x198.png" alt="picture-8" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-7.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-632" title="picture-7" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-7-300x198.png" alt="picture-7" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-6.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-631" title="picture-6" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-6-300x198.png" alt="picture-6" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-5.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-630" title="picture-5" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-5-300x198.png" alt="picture-5" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-4.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-629" title="picture-4" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-4-300x198.png" alt="picture-4" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-3.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-628" title="picture-3" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-3-300x198.png" alt="picture-3" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-2.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-627" title="picture-2" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-2-300x198.png" alt="picture-2" width="300" height="198" /></a><a href="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-1.png" rel="lightbox[625]"><img class="alignnone size-medium wp-image-626" title="picture-1" src="http://leejayxia.com/blog/wp-content/uploads/2009/04/picture-1-300x198.png" alt="picture-1" width="300" height="198" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://leejayxia.com/blog/i-wish-i-know-more-trigs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

