void MATRIX::Scale(VECTOR v){ MATRIX swp; swp.Identity(); swp.m[0][0]=v.x; swp.m[1][1]=v.y; swp.m[2][2]=v.z; *this=*this*swp; }
void MATRIX::Translate(VECTOR v){ MATRIX swp; swp.Identity(); swp.m[3][0]=v.x; swp.m[3][1]=v.y; swp.m[3][2]=v.z; *this=*this*swp; }
static MATRIX RotateZ(float a){ float cosinus=cosf(a); float sinus=sinf(a); MATRIX ret; ret.Identity(); ret.m[0][0]=cosinus; ret.m[1][1]=cosinus; ret.m[0][1]=-sinus; ret.m[1][0]=sinus; return ret; }
void MATRIX::Target(VECTOR v,VECTOR c,float a){ VECTOR u(0,1,0); VECTOR z=v-c;z.Normalize(); VECTOR y=u-z*Dot(u,z);y.Normalize(); VECTOR x=Cross(y,z); MATRIX swp; swp.Identity(); swp.m[0][0]=x.x,swp.m[0][1]=y.x,swp.m[0][2]=z.x; swp.m[1][0]=x.y,swp.m[1][1]=y.y,swp.m[1][2]=z.y; swp.m[2][0]=x.z,swp.m[2][1]=y.z,swp.m[2][2]=z.z; swp.m[3][0]=-Dot(c,x); swp.m[3][1]=-Dot(c,y); swp.m[3][2]=-Dot(c,z); *this=RotateZ(-a)*swp; }