d;

kill(all)$

van=facebook.com/LearningCalculus$

d2r(θ):=%pi/180*θ$
r2d(θ):=180/%pi*θ$

      These matrices assume counterclockwise rotation is positive.

xRotate(α):=matrix([1,      0,      0, 0],
                   [0, cos(α),-sin(α), 0],
                   [0, sin(α), cos(α), 0],
                   [0,      0,      0, 1])$

yRotate(β):=matrix([ cos(β), 0, sin(β), 0],
                   [ 0,         1,   0, 0],                 
                   [-sin(β), 0, cos(β), 0],
                   [ 0,         0,   0, 1])$

zRotate(γ):=matrix([ cos(γ),-sin(γ), 0, 0],
                   [ sin(γ), cos(γ), 0, 0],
                   [ 0,          0,  1, 0],
                   [ 0,          0,  0, 1])$

Px:matrix([1],[0],[0],[0])$
Py:matrix([0],[1],[0],[0])$
Pz:matrix([0],[0],[1],[0])$
Pw:matrix([0],[0],[0],[1])$

      In a 90 degree z rotation x coordinate becomes y coordinate.
      In a 90 degree z rotation y coordinate becomes x coordinate negated.
      In a 90 degree z rotation z coordinate becomes is unchanged.

      In a 90 degree y rotation x coordinate becomes z coordinate negated.
      In a 90 degree y rotation y coordinate is unchanged.
      In a 90 degree y rotation z coordinate becomes x coordinate.

      In a 90 degree x rotation x coordinate is unchanged.
      In a 90 degree x rotation y coordinate becomes z coordinate.
      In a 90 degree x rotation z coordinate becomes y coordinate.

Px$ zRotate(d2r(90)).Px$
Py$ zRotate(d2r(90)).Py$
Pz$ zRotate(d2r(90)).Pz$

Px$ yRotate(d2r(90)).Px$
Py$ yRotate(d2r(90)).Py$
Pz$ yRotate(d2r(90)).Pz$

Px$ xRotate(d2r(90)).Px$
Py$ xRotate(d2r(90)).Py$
Pz; xRotate(d2r(90)).Pz;

Pab(t):=matrix([a*(1-t)-b*t],[b*(1-t)+a*t],[0],[0]);
Pcd(t):=matrix([c*(1-t)-d*t],[d*(1-t)+c*t],[0],[0]);
M:Pab(t);
N:Pcd(t);
[M[1][1],M[2][1]];
[N[1][1],N[2][1]];

PAB(a,b):=matrix([a],[b],[0],[0]);
PCD(c,d):=matrix([c],[d],[0],[0]);

M:zRotate(t*%pi/2).PAB(2,2);
N:zRotate(t*%pi/2).PCD(6,5);
[M[1][1],M[2][1]];
[N[1][1],N[2][1]];

M:zRotate(0*%pi/2).PAB(2,2);
N:zRotate(0*%pi/2).PCD(6,5);
[M[1][1],M[2][1]];
[N[1][1],N[2][1]];

M:zRotate(1*%pi/2).PAB(2,2);
N:zRotate(1*%pi/2).PCD(6,5);
[M[1][1],M[2][1]];
[N[1][1],N[2][1]];

M:zRotate(t*%pi/2).PAB(2,2);
N:zRotate(t*%pi/2).PCD(6,5);
[M[1][1],M[2][1]];
[N[1][1],N[2][1]];

M:zRotate(t*Pi/2).PAB(a,b);
N:zRotate(t*Pi/2).PCD(c,d);
[M[1][1],M[2][1]];
[N[1][1],N[2][1]];