GLSharp.Util.Matrix4X4.SetRotation C# (CSharp) Method

SetRotation() public method

public SetRotation ( Vector3 rotation ) : Matrix4X4
rotation Vector3
return Matrix4X4
        public Matrix4X4 SetRotation(Vector3 rotation)
        {
            float x = rotation.Elements[0]; float y = rotation.Elements[1]; float z = rotation.Elements[2];

            float sx = Math.Sin(x);
            float cx = Math.Cos(x);
            float sy = Math.Sin(y);
            float cy = Math.Cos(y);
            float sz = Math.Sin(z);
            float cz = Math.Cos(z);

            Elements[0] = cz * cy;
            Elements[1] = sz * cy;
            Elements[2] = -sy;
            Elements[3] = 0;
            Elements[4] = -sz * cx + cz * sy * sx;
            Elements[5] = cz * cx + sz * sy * sx;
            Elements[6] = cy * sx;
            Elements[7] = 0;
            Elements[8] = sz * sx + cz * sy * cx;
            Elements[9] = cz * (-sx) + sz * sy * sx;
            Elements[10] = cy * cx;
            Elements[11] = 0;
            Elements[12] = 0;
            Elements[13] = 0;
            Elements[14] = 0;
            Elements[15] = 1;

            return this;
        }