<?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>DevLog &#187; math</title>
	<atom:link href="http://82.30.70.163/BlueThen/wordpress/tag/math/feed/" rel="self" type="application/rss+xml" />
	<link>http://82.30.70.163/BlueThen/wordpress</link>
	<description></description>
	<lastBuildDate>Mon, 06 Sep 2010 15:24:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Day 10</title>
		<link>http://82.30.70.163/BlueThen/wordpress/2010/01/day-10/</link>
		<comments>http://82.30.70.163/BlueThen/wordpress/2010/01/day-10/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 04:46:53 +0000</pubDate>
		<dc:creator>BlueThen</dc:creator>
				<category><![CDATA[Chase Engine]]></category>
		<category><![CDATA[Dev Log]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Chase]]></category>
		<category><![CDATA[coordinate]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[devlog]]></category>
		<category><![CDATA[geometric]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[polygon]]></category>
		<category><![CDATA[transformation]]></category>

		<guid isPermaLink="false">http://82.30.70.163/BlueThen/BlueThen/wordpress/?p=185</guid>
		<description><![CDATA[Remember yesterday, I said &#8220;If tomorrow also provides the convenience of a snow day, I&#8217;ll take advantage of that as well&#8230;&#8221;? Well, today happened to also be a snow day (woohoo!), and I did as I told you. I worked on Chase&#8217;s Engine. I&#8217;m currently at about 744 lines of code, so I&#8217;ve made some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/BlueThen/wordpress/wp-content/uploads/2010/01/flowChart.jpg"><img src="/BlueThen/wordpress/wp-content/uploads/2010/01/flowChart-300x243.jpg" alt="" title="flowChart" width="300" height="243" class="alignleft size-medium wp-image-186" /></a>
<p style="text-indent:20pt; line-height:20pt;">Remember <a href="http://82.30.70.163/BlueThen/BlueThen/wordpress/2010/01/day-9/">yesterday</a>, I said &#8220;If tomorrow also provides the convenience of a snow day, I&#8217;ll take advantage of that as well&#8230;&#8221;? Well, today happened to also be a snow day (woohoo!), and I did as I told you. I worked on Chase&#8217;s Engine. I&#8217;m currently at about 744 lines of code, so I&#8217;ve made some progress since I started the conversion. Yesterday&#8217;s version included support for handling coordinates, polygons, and models in 3D space. It also had some transformation functions (translate, dilate, and rotate) for coordinates and polygons.</p>
<p><span id="more-185"></span></p>
<p style="text-indent:20pt; line-height:20pt;">I&#8217;ll probably delete those transformation functions the next time I edit. Today I&#8217;ve nested support for adding, subtracting, dividing, and multiplying in both the polygon and coordinate function. Not only an add/sub/etc function, but operator overloading (like for +, -, or *). This will allow me to use coordinate and polygon data types, for example: </p>
<p><code>polygonA * ((coordinateA + coordinateB) / coordinateC)</code></p>
<p style="text-indent:20pt; line-height:20pt;">This will be exactly why I won&#8217;t need my transformation functions. Any sort of geometric manipulating can simply done using the nested math functions or use the coordinates/polygons in a formula. I also added in a rotation function to both classes. Another neat feature I&#8217;ve implemented is 2 and 3 dimensional support for the Coordinate and Polygon class. I was originally going to have a separate class for 2 and 3 dimensions (eg. Coord2D and Coord3D), but that won&#8217;t be necessary with the mighty convenience of <a href="http://www.codersource.net/cpp_tutorial_function_overloading.html">function overloading in C++</a>.</p>
<p style="text-indent:20pt; line-height:20pt;">The picture above shows a rough draft code flow chart of Chase&#8217;s graphic engine. I drew this on the first this month (and year!), and will probably, if not definitely, will change as I refine my concept for Chase&#8217;s engine.</p>
 <img src="http://82.30.70.163/BlueThen/wordpress/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=185" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://82.30.70.163/BlueThen/wordpress/2010/01/day-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chase</title>
		<link>http://82.30.70.163/BlueThen/wordpress/2009/12/chase/</link>
		<comments>http://82.30.70.163/BlueThen/wordpress/2009/12/chase/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 04:42:24 +0000</pubDate>
		<dc:creator>BlueThen</dc:creator>
				<category><![CDATA[Chase Engine]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[Chase]]></category>
		<category><![CDATA[formulas]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[isometric]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[mirc]]></category>
		<category><![CDATA[msl]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://bluethen.wordpress.com/?p=37</guid>
		<description><![CDATA[I&#8217;ve been working on a game for a little under a month (ever since November 21st). It started out as an idea several months earlier, in which I proceeded to work on in mSL.  I got a  wireframe isometric engine made and running fairly nice (roughly 40 fps, which was godly for such a slow language). I had [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a game for a little under a month (ever since November 21st). It started out as an idea several months earlier, in which I proceeded to work on in mSL.  I got a  wireframe isometric engine made and running fairly nice (roughly 40 fps, which was godly for such a slow language). I had some problems with mSL, however. Resources played too large of a factor, and involved having to use every little hack I could come up with to speed it up. I was literally optimizing it to the very byte. That would&#8217;ve been fine for a simple game, but I had bigger plans for my game.</p>
<p><span id="more-37"></span></p>
<p>I didn&#8217;t really want my game to be wireframe. It didn&#8217;t seem very ideal to me.  So I scripted up a simple hidden line removal algorithm, where lines being overlapped by polygons wouldn&#8217;t be displayed. mSL didn&#8217;t provide support for drawing custom polygons, and making a loop to draw each individual pixel of one would be way too slow. I went over every solution I could come up with, like storing different values that would be used in some of the frames. But I&#8217;d always run into one problem or another.</p>
<p>So I gave up on the idea all together. Later, I moved on to Processing. I made a couple of experimental apps, some being duplicates of previous scripts in mSL, and released them on<a title="BlueThen's profile on OpenProcessing" href="http://www.openprocessing.org/portal/?userID=3044"> OpenProcessing</a>. After getting a feel for the language, I started to revisit the idea of the game I wanted to make. The idea of it kept coming back to me. In my mind, it seemed completely revolutionary. Concepts that are used very little, if at all, in main stream games.</p>
<p>I love isometric rendering. Something about the diagonal lines grabs my attention, and stimulates interest into the media. Photographers and artists would tell you that diagonal lines shows action, depth, and stimulation. They convey feelings of movement, and tend to lead your eyes throughout the piece.</p>
<p>Another reason I was interested in isometric rendering was the ease of use. All that&#8217;s required is a simple formula to plug the xyz coordinates, and you&#8217;re done. No rotations, matrixes, or whatever is really required. Just a basic knowledge of 3 dimensional Cartesian coordinates.</p>
<p><a href="http://bluethen.files.wordpress.com/2009/12/isometric.gif"><img class="size-full wp-image-38 alignright" title="isometric" src="http://bluethen.files.wordpress.com/2009/12/isometric.gif" alt="" width="292" height="261" /></a></p>
<p>I began using an isometric formula I came across a number of months ago.<br />
onScreenX = (x &#8211; z) * cos(radians(30)) + width/2<br />
onScreenY = (x + z) * sin(radians(30)) &#8211; y + height/2<br />
Assentially, adding width/2 to the x, and height/2 to the y, moves the point of origin (0,0) to the center of the window. I later came across the translate() function in Processing, which allowed me to do just that: translate(width/2,height/2);<br />
onScreenX = (x &#8211; z) * cos(radians(30))<br />
onScreenY = (x + z) * sin(radians(30)) &#8211; y</p>
<p>When multiplying anything by cosine and sine, the radius of an ellipse is created. (x-z) determines the width of the ellipse, and (x+z) is the height. The x-coordinate is then calculated to be 30 degrees counter clockwise from the x axis, and the z-coordinate is calculated 30 degrees clockwise from the x axis.</p>
<p><a href="http://bluethen.files.wordpress.com/2009/12/pixels.gif"><img class="alignleft size-full wp-image-39" title="pixels" src="http://bluethen.files.wordpress.com/2009/12/pixels.gif" alt="" width="100" height="70" /></a>I was suggested to later on to use something like 33 degrees instead. Ideally to line it up so that the pixels aren&#8217;t abnormally lined up when drawn directly along the x or z axis. Instead of having 2 dots sideways, then one up, then 3 side, or whatever, it&#8217;d be a clean 2 dots to the side, then 2 dots vertical from that. I never adopted the idea, since none of my scripts ever heavily involved lines parallel to the x or z axis.</p>
<p>The isometric formula was an essential part of all my algorithms. It&#8217;d be used hundreds of thousands of times, for each coordinate involves this calculation. I later decided that it&#8217;d be a good idea to optimize it. Knowing that I&#8217;ll always be using 30 degrees for my isometric formulas, I precalculated that accordingly. 30 degrees in radians is 0.523598776,  cosine of that is roughly 0.866, and sin of our radians is conveniently 0.5.</p>
<p>Later, I rounded the 0.866 to 1. Rounding it that much seemed like it&#8217;d have a significant effect, and it sort of did. It was, however, only noticeable when placed side by side, or immediately compared, to an accurate rendering. The inaccurate rendering only appeared to be a slightly wider scaled version of the accurate rendering.  I ended up with an extremely simple formula:<br />
onScreenX = x &#8211; z<br />
onScreenY = (x + z)/2 &#8211; y</p>
<p>This, I planned to be the main component of the Chase Engine. Chase Engine is essentially going to be the name of the collective algorithms, functions, and classes in my game. I plan to make the graphical engine vector-based. Most isometric/dimetric/trimetric games are bitmap based, where images are used for every angle of every object.</p>
<p>I will render models polygon by polygon, just as if I were doing everything as if it were truely 3D. Textures would probably not be used, and if they are, they&#8217;d be procedural just as well as the rendering.</p>
<p>The isometric formula is the simple part of my game. Other, more complex and brain-tumor-inducing, things will be involved. They will involve my collective knowledge of everything I know about mathematics, programming, graphical algorithms, and plus some. I&#8217;ve thought about it for hours on end,  getting every basic concept ironed out. I knew my game inside and out before I even started, or so I assumed.</p>
<p>I started on November 21st, 2009. I&#8217;ve been dedicating entire days to the game. No less than 3 hours at a time, if you don&#8217;t count the brief breaks I take frequently to keep a fresh mind. The first thing I&#8217;ve accomplished was simple rendering. Functions that&#8217;d draw different shapes and lines in the isometric space. I then added a rough draft of the vehicle class, and of the environment class. The environment class was simply a place-holder, to test the vehicle class. In the vehicle class, featured a simple algorithm for calculating the y position of the vehicle&#8217;s corners, as they act as springs according to the wheels. This was to simulate suspension.</p>
<p>By day 2, November 22nd, I already had about 402 lines of code.  I created a model class and a function for reading files. I then wrote an algorithm to take on screen coordinates and convert them to isometric coordinates.</p>
<p>On day 3, or November 25th, the line count was cut down to 342, and the file reader was turned into a model importer. The model importer took in coordinates from a file, and loaded them into a 3D model class. I was lacking a z-buffer at that time.</p>
<p><a href="http://bluethen.files.wordpress.com/2009/12/suspensions.gif"><img class="alignright size-medium wp-image-48" title="suspensions" src="http://bluethen.files.wordpress.com/2009/12/suspensions.gif?w=288" alt="" width="288" height="300" /></a>I got a basic Scene buffer going by December 6th, 2009. There was no z-buffering yet. I also recreated the suspension algorithm for vehicles. This one was a little more dynamic, since it allowed me to change the mass, dampening, and other values with ease.</p>
<p>The algorithm I came up with for suspension was</p>
<p>newRest = rest + min ; The resting y position, is determined by a preset rest coordinate + min, or the tire&#8217;s y coordinate. This allows the resting coordinate to change as the wheel coordinate changes.</p>
<div id="_mcePaste">velocity += 0.2 * (newRest &#8211; yPos) &#8211; mass ; The velocity is adjusted. The y position of the car is subtracted from the new resting coordinate. This finds the distance between the vehicle and the resting position. It&#8217;s then multiplied by 0.2 so it the velocity isn&#8217;t significant, and mass is subtracted to simulate gravity.</div>
<div id="_mcePaste">velocity *= dampening ; velocity is multiplied by dampening (which is less than 1), to simulate friction.</div>
<div id="_mcePaste">yPos += velocity ; velocity is added to the y position.</div>
<div id="_mcePaste">constrain(yPos, newMin, maxHeight+newMin) ; the y position is constrained to withing the minimum and maximum heights.</div>
<div></div>
<div>On the 5th day, today, December 12th, 2009, I finally made a working zbuffer. I&#8217;ve probably spent over 10 hours trying to get a working zbuffer. My main problem was the syntax. The logic seemed simple. Simply sort the polygons according to their values.  sort(polygons), right? Wrong!</div>
<div></div>
<div>The sort() function doesn&#8217;t support objects, and arrays are often a pain. I eventually came across a pretty simple way of getting around this. Using comparables for sorting the objects. So I went ahead and created a polygon class for storing all the coordinates in, creating a large array of that for the buffer, then sorting it using comparable. It ended up technically being xyzBuffering, since x, y, and z are all playing a factor in the buffer. In an isometric rendering, the camera is simply at (1,1,1) pointed towards (0,0,0), so I added together the mean (average) x, y, and z of a coordinate to represent it&#8217;s depth.</p>
<div>without zbuffering (CLICK):</div>
</div>
<div><a href="http://bluethen.files.wordpress.com/2009/12/withoutzbuffer.gif"><img class="alignnone size-thumbnail wp-image-33" style="border:0 initial initial;" title="withoutZBuffer" src="http://bluethen.files.wordpress.com/2009/12/withoutzbuffer.gif?w=150" alt="" width="150" height="150" /></a></div>
<div><a href="http://bluethen.files.wordpress.com/2009/12/withoutzbuffer.gif"></a></div>
<div>With zbuffering (CLICK):</div>
<div><a href="http://bluethen.files.wordpress.com/2009/12/withzbuffer1.gif"><img class="alignnone size-thumbnail wp-image-35" title="withZBuffer" src="http://bluethen.files.wordpress.com/2009/12/withzbuffer1.gif?w=150" alt="" width="150" height="150" /></a></div>
<div></div>
<div></div>
<div></div>
<div>I have a lot more planned for the game. It&#8217;ll probably take me months, if not one or two years, to complete. I&#8217;m willing to take however long to make the game though. I will not give up, even if it takes me 10+ hours to complete a simple function, or 3+ days to get a formula to work.</div>
<div>

</div>
 <img src="http://82.30.70.163/BlueThen/wordpress/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=37" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://82.30.70.163/BlueThen/wordpress/2009/12/chase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
