/* * PROJECT: FLARManager * http://transmote.com/flar * Copyright 2009, Eric Socolofsky * -------------------------------------------------------------------------------- * This work complements FLARToolkit, developed by Saqoosha as part of the Libspark project. * http://www.libspark.org/wiki/saqoosha/FLARToolKit * FLARToolkit is Copyright (C)2008 Saqoosha, * and is ported from NYARToolkit, which is ported from ARToolkit. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this framework; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For further information please contact: * * http://transmote.com/flar * */ package com.transmote.flar.utils { import flash.geom.Matrix3D; import org.libspark.flartoolkit.core.transmat.FLARTransMatResult; import org.libspark.flartoolkit.core.types.matrix.FLARDoubleMatrix34; /** * collection of utils used for FLAR matrix transformation / conversion. * * @author Eric Socolofsky * @url http://transmote.com/flar */ public class FLARGeomUtils { /** * convert a FLAR matrix to a Flash Matrix. */ public static function convertFLARMatrixToFlashMatrix (fm:FLARDoubleMatrix34, scale:Number=1.0) :Matrix3D { return new Matrix3D (Vector.([ fm.m00*scale, fm.m10*scale, fm.m20*scale, 0, -fm.m01*scale, -fm.m11*scale, -fm.m21*scale, 0, -fm.m02*scale, -fm.m12*scale, -fm.m22*scale, 0, fm.m03*scale, fm.m13*scale, fm.m23*scale, 1 ])); } /** * create an identity matrix as a FLARDoubleMatrix34. */ public static function createFLARIdentityMatrix () :FLARDoubleMatrix34 { var matrix:FLARDoubleMatrix34 = new FLARDoubleMatrix34(); matrix.m00 = 1; matrix.m01 = 0; matrix.m02 = 0; matrix.m03 = 0; matrix.m10 = 0; matrix.m11 = -1; matrix.m12 = 0; matrix.m13 = 0; matrix.m20 = 0; matrix.m21 = 0; matrix.m22 = -1; matrix.m23 = 0; return matrix; } /** * create an identity matrix as a FLARTransMatResult. */ public static function createFLARIdentityTransMat () :FLARTransMatResult { var matrix:FLARTransMatResult = new FLARTransMatResult(); matrix.m00 = 1; matrix.m01 = 0; matrix.m02 = 0; matrix.m03 = 0; matrix.m10 = 0; matrix.m11 = -1; matrix.m12 = 0; matrix.m13 = 0; matrix.m20 = 0; matrix.m21 = 0; matrix.m22 = -1; matrix.m23 = 0; return matrix; } /** * format a FLAR matrix as a String. */ public static function dumpFLARMatrix (fm:FLARDoubleMatrix34) :String { return (fm.m00.toFixed(4) +"\u0009"+ fm.m01.toFixed(4) +"\u0009"+ fm.m02.toFixed(4) +"\u0009"+ fm.m03.toFixed(4) +"\n"+ fm.m10.toFixed(4) +"\u0009"+ fm.m11.toFixed(4) +"\u0009"+ fm.m12.toFixed(4) +"\u0009"+ fm.m13.toFixed(4) +"\n"+ fm.m20.toFixed(4) +"\u0009"+ fm.m21.toFixed(4) +"\u0009"+ fm.m22.toFixed(4) +"\u0009"+ fm.m23.toFixed(4)); } public function FLARGeomUtils () {} } }