require"Object.php";
require"TestPrint.php";
require"s.php";

class Matrix extends Object
{
	function Matrix()
	{
	$this->Object();
	$this->addAction($this->MatrixAction(),"act");
	$this->compire();
	}
	function MatrixAction()
	{
	$act = new SWFAction
	("
		//二次元配列
		this.newMatrix =function(name){
		return matrix = new Array
				  (0,0,0,0,0
		         	  ,0,0,0,0,0
				  ,0,0,0,0,0
				  ,0,0,0,0,0);
		};

		this.setMatrix_array = function(self,matrix){
		this = matrix;
		};

		this.getMatrix_array = function(self){
		return self;
		};

		this.getElement = function(self,row,col){
		return self[4*row+col];
		};

		this.setElement= function(self,row,col,element){
		self[4*row+col] = element;
		};

		this.duplicateArray= function(self){
		
		matrix = newMatrix();
		
		for(i = 0;i<4;i++ )
		 for(j = 0;j<4;j++){
			matrix_temp[4*i+j] =getElement(self,i,j);
			}
		return matrix_temp;
		};
//演算

		this.multiplication= function(A,B)
		{
		matrix = newMatrix();
		temp = 0;
	      for(m = 0;m<4;m++)
		for(i=0;i<4;i++){
		  for(j=0;j<4;j++)
				{
			temp += getElement(A,m,j)*getElement(B,j,i);
				}
			setElement(matrix,m,i,temp);temp=0;
			}
		return matrix;
		};


		this.addition = function(A,B)
		{
			matrix = newMatrix();
			for(i=0;i<4;i++)
			  for(j=0;j<4;j++)
  			    {
			    this.setElement(matrix,i,j,getElement(A,i,j)+getElement(B,i,j));  
		  	    }
		};

		this.transpose = function(self)
		{
 		  matrix = newMatrix();

		  for(i = 0;i<4;i++)
			for(j = 0;j<4;j++){
			setElement(matrix,i,j,getElement(self,j,i));
			}
		};
/*
		this.rotate_x = function(A,B){

		rotate = newArray();
		rotate.setData(0,0,1);
		rotate.setData(1,1,Math.cos(kakudo));
		rotate.setData(1,2,Math.sin(kakudo));
		rotate.setData(2,1,-1*Math.sin(kakudo));
		rotate.setData(2,2,Math.cos(kakudo));
		rotate.setData(3,3,1);
		
		multiplication()
		};
*/
		this.printMatrix = function(self){
			string = '';
			for(i=0;i<4;i++){
				string+='\n';
		 	  for(j=0;j<4;j++){
				string +=getElement(self,i,j)+' '; 
		  			}}
			_root.print.text.text = string;
		};

	");
	return $act;
	}
}

ming_useSWFVersion(6);
$m = new SWFMovie();
$A = new Matrix();
$P = new TestPrint();

$m->setDimension(800, 600);
$m->addExport($A->Layer(),"matrix");
$m->writeExports();


$N = $m->add($P->Layer());
$N->setName("print");

$N = $m->add($A->Layer());
$N->setName("Matrix");

$m->nextFrame();
$m->add(
	new SWFAction
	("
var init = 1;
	 A = _root.Matrix.newMatrix();
	 B = _root.Matrix.newMatrix();
	 T = _root.Matrix.newMatrix();

this.onEnterFrame = function(){	
	
	_root.Matrix.setElement(A,0,0,1);_root.Matrix.setElement(A,0,1,1);_root.Matrix.setElement(A,0,2,1);
	_root.Matrix.setElement(A,1,0,2);_root.Matrix.setElement(A,1,1,6);_root.Matrix.setElement(A,1,2,1);

   	_root.Matrix.setElement(B,0,0,1);_root.Matrix.setElement(B,1,1,1);_root.Matrix.setElement(B,2,2,1);
	T = _root.Matrix.multiplication(A,B);
	_root.Matrix.transpose(T);
	_root.Matrix.printMatrix(A);
	 
	};

	")

);


$m->save("matrix.swf");

楽天モバイル[UNLIMITが今なら1円] ECナビでポインと Yahoo 楽天 LINEがデータ消費ゼロで月額500円〜!


無料ホームページ 無料のクレジットカード 海外格安航空券 解約手数料0円【あしたでんき】 海外旅行保険が無料! 海外ホテル