[AS3] Isometric conversion (Mathematics), for a clueless guy ._

Hello!

I’m a guy who didn’t study to much math back in school, but I’d really like to learn a few things without taking on any major study. One of the things I’m currently curious about is the math behind 2D to Isometric conversion (as in X,Y plane conversion to X,Y,Z, and the other way round of course). During my search for some base material (Due to the fact that I don’t know much math) I found the library as3isolib (http://code.google.com/p/as3isolib/) which naturally had its own conversion functions for XY > XYZ and XYZ > XY.

Being Open Source I figure I can paste the code straight here.

[AS]
/*

as3isolib - An open-source ActionScript 3.0 Isometric Library developed to assist
in creating isometrically projected content (such as games and graphics)
targeted for the Flash player platform

http://code.google.com/p/as3isolib/

Copyright © 2006 - 2008 J.W.Opitz, All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

/
package as3isolib.geom
{
/
*
* IsoMath provides functions for converting pts back and forth between 3D isometric space and cartesian coordinates.
/
public class IsoMath
{
/
*
* Converts a given pt in cartesian coordinates to 3D isometric space.
*
* @param screenPt The pt in cartesian coordinates.
* @param createNew Flag indicating whether to affect the provided pt or to return a converted copy.
* @return pt A pt in 3D isometric space.
*/
static public function screenToIso (screenPt:Pt, createNew:Boolean = false):Pt
{
var z:Number = screenPt.z / Math.sqrt(1.25);
var y:Number = (2 * screenPt.y - screenPt.x) / 2 + screenPt.z;
var x:Number = screenPt.x + y;

		if (createNew)
			return new Pt(x, y, z);
		
		else
		{
			screenPt.x = x;
			screenPt.y = y;
			screenPt.z = z;
			
			return screenPt;
		}
	}
	
	/**
	 * Converts a given pt in 3D isometric space to cartesian coordinates.
	 * 
	 * @param isoPt The pt in 3D isometric space.
	 * @param createNew Flag indicating whether to affect the provided pt or to return a converted copy.
	 * @return pt A pt in cartesian coordinates.
	 */
	static public function isoToScreen (isoPt:Pt, createNew:Boolean = false):Pt
	{
		var z:Number = isoPt.z * Math.sqrt(1.25);
		var y:Number = 0.5 * (isoPt.x + isoPt.y) - isoPt.z;
		var x:Number = isoPt.x - isoPt.y;
		
		if (createNew)
			return new Pt(x, y, z);
		
		else
		{
			isoPt.x = x;
			isoPt.y = y;
			isoPt.z = z;
			
			return isoPt;
		}
	}
}

}
[/AS]

I found that these conversions where off by about 1% when converting from XYZ to XY, so here I am! So if anyone could literally spell it out for me how to do a conversion like this (without the 1% inaccuracy) or link me some crazy tutorial/guide/helplines I’d be very happy.

Note: I’m not asking for code! I want to understand the math.

Thanks for you time,
Matt