#include "view.h"

void setIdentityMatrix(m)
Matrix m;
{
	register int i,j;
	
	for(i=0;i<4;++i)
	for(j=i;j<4;++j){
		if(i==j) m[i][i] = 1.0;
		else 	 m[i][j] = m[j][i] = 0.0;
	}
}

void multiplyMatrix(a,b,c)
Matrix a,b,c;
{
	register int i,j,k;
	
	for(i=0;i<4;++i)
	for(j=0;j<4;++j){
		c[i][j] = 0.0;
		for(k=0;k<4;++k) c[i][j] += (a[i][k]*b[k][j]);
	}
}

void setTranslationMatrix(m,tx,ty,tz)
Matrix m;
REAL tx,ty,tz;
{
	setIdentityMatrix(m);
	m[3][0] = tx;
	m[3][1] = ty;
	m[3][2] = tz;
}

void setZRotationMatrix(m,a)
Matrix m;
REAL a;
{
	REAL cs,sn;
	
	setIdentityMatrix(m);
	cs = (REAL)cos(a);
	sn = (REAL)sin(a);
	m[0][0] = cs;
	m[1][0] = -sn;
	m[0][1] = sn;
	m[1][1] = cs;
}

void setScalingMatrix(m,sx,sy,sz)
Matrix m;
REAL sx,sy,sz;
{
	setIdentityMatrix(m);
	m[0][0] = sx;
	m[1][1] = sy;
	m[2][2] = sz;
}