, Visual C#


- 9


{

sin1 = -A / d1; cos1 = C / d1;

}

d2 = (float)Math.Sqrt(A * A + B * B + C * C);

if (d2 != 0)

{

sin2 = B / d2; cos2 = d1 / d2;

}

// y,

// y-z :

MatrixIdentity(ref M2);

// d1 = 0,

// y y-z :

if (d1 != 0)

{

M2[1, 1] = cos1; M2[1, 3] = -sin1;

M2[3, 1] = sin1; M2[3, 3] = cos1;

}

// x,

// z:

MatrixIdentity(ref M3);

// d2 = 0,

// .

// :

if (d2 != 0)

{

M3[2, 2] = cos2; M3[2, 3] = sin2;

M3[3, 2] = -sin2; M3[3, 3] = cos2;

}

// UP:

up1[1] = ux; up1[2] = uy; up1[3] = uz;

up1[4] = 1;

MatrixApply(ref up1, ref M2, ref up2);

MatrixApply(ref up2, ref M3, ref up1);

// z,

// UP y-z :

d3 = (float)Math.Sqrt(up1[1] * up1[1] +

up1[2] * up1[2]);

MatrixIdentity(ref M4);

// d3 = 0, UP :

if (d3 != 0)

{

sin3 = up1[1] / d3; cos3 = up1[2] / d3;

M4[1, 1] = cos3; M4[1, 2] = sin3;

M4[2, 1] = -sin3; M4[2, 2] = cos3;

}

//:

if (type_of_projection == PerspectiveProjection)

MatrixPerspectiveXZ(ref M5, d2);

else

MatrixIdentity(ref M5);

if (d2 != 0)

MatrixPerspectiveXZ(ref M5, d2);

else

MatrixIdentity(ref M5);

// :

m3MatMultiply(ref M12, ref M1, ref M2);

m3MatMultiply(ref M34, ref M3, ref M4);

m3MatMultiply(ref M1234, ref M12, ref M34);

if (type_of_projection == PerspectiveProjection)

m3MatMultiplyFull(ref M, ref M1234, ref M5);

else

m3MatMultiply(ref M, ref M1234, ref M5);




- -  - -  - -