The first one is shift to orgin

matrix MoveToOrg={1,0,0,0,

0,1,0,0,

0,0,1,0,

-x,-y,-z,1};

For rotation, to represent according to z -axis

matrix

RotatoZ={conf(anglez),sinf

sinf(anglez),conf(anglez),

0,0,1,0,

0,0,0,1};

along x-axis

RotateX={1,0,0,0,

0,conf(anglex),sinf(anglex

0,-sinf(anglex),cosf(angle

0,0,0,1};

along y-axis

RotateY={cosf(angley),0,-s

0,1,0,0,

sinf(angley),0,cosf(angley

0,0,0,1};

And then shift back from orgin

matrix MoveBack={1,0,0,0,

0,1,0,0,

0,0,1,0,

x,y,z,1};

You have to multiply all of them in order to produce a new matrix for 3D object rotation