Plane

Let (v1,v2) a  vector in the cartesian system and 
(u1,u2), (w1,w2) the new basis.

Find the coordinates of (v1,v2) in the new basis.

This is equivalent to solve the linear system
(v1,v2) = a (u1,u2) + b (w1,w2)
finding a and b.


v1 = u1 a + w1 b
v2 = u2 a + w2 b

The solution is this given by
           | u1    w1 |  | v1 |        | a |
Inverse|              |  |      |  =   |     |
           | u2    w2 |  | v2 |        | b |

(*PROGRAM TO CALCULATE THE NEW COMPONENTS IN THE PLANE    PRESS SHIFT ENTER TO ACTIVATE*)

M[u1_,u2_,w1_,w2_]:={{u1,w1},{u2,w2}}
Inv[u1_,u2_,w1_,w2_]:=Inverse[M[u1,u2,w1,w2]]

NC[u1_,u2_,w1_,w2_,v1_,v2_]:=Inv[u1,u2,w1,w2].{{v1},{v2}}

ste[u1_,u2_,w1_,w2_,v1_,v2_,xmin_,xmax_,ymin_,ymax_]:=Show[{
Plot[
{0},{x,xmin,xmax},
PlotRange->{{xmin,xmax},{ymin,ymax}},
Epilog->{
{Black,FontSize->15,
Text["Cartesian components",{(xmax+xmin)/2,ymax  0.9},{0,0}], Text[{v1,v2},{(xmax+xmin)/2,ymax  0.75},{0,0}],
Blue,Text["New components",{(xmax+xmin)/2,ymax  0.6},{0,0}], Text[{NC[u1,u2,w1,w2,v1,v2][[1]][[1]],NC[u1,u2,w1,w2,v1,v2][[2]][[1]]},{(xmax+xmin)/2,ymax  0.45},{0,0}]}
},
PlotStyle->{Blue},
 Frame->True,FrameStyle->Directive[Blue,Thick,12],Background->LightYellow,
AspectRatio->1
],
Graphics[{Blue, PointSize[Large],Point[{v1,v2}],Blue,Line[{{0,ymin},{0,ymax}}],
Blue,Arrowheads[Small],Arrow[{{0,0},{u1,u2}}],
Red,Arrowheads[Small],Arrow[{{0,0},{w1,w2}}],
 Blue,Dashed,Arrow[ {{0,0},NC[u1,u2,w1,w2,v1,v2][[1]][[1]]{u1,u2}}],
Red,Arrow[ {NC[u1,u2,w1,w2,v1,v2][[1]][[1]]{u1,u2},  NC[u1,u2,w1,w2,v1,v2][[2]][[1]]{w1,w2}+NC[u1,u2,w1,w2,v1,v2][[1]][[1]]{u1,u2}  }]
               }]
}]



Sol[u1_,u2_,w1_,w2_,v1_,v2_,xmin_,xmax_,ymin_,ymax_]:=If[Det[M[u1,u2,w1,w2]]==0,
"THE TRANSFORMATION MATRIX  IS NOT INVERTIBLE",
ste[u1,u2,w1,w2,v1,v2,xmin,xmax,ymin,ymax]
]

(* INSERT THE VALUES  AND PRESS SHIFT ENTER*)

(*VECTOR IN THE CARTESIAN BASIS *)
v1:=6
v2:=3
(* NEW BASIS *)
u1:=1
u2:=2
w1:=1
w2:=2

(* SET xmin xmax ymin ymax FOR THE PLOT *)

xmin:=-3
xmax:=7
ymin:=-4
ymax:=6



Sol[u1,u2,w1,w2,v1,v2,xmin,xmax,ymin,ymax]

(* INSERT THE VALUES  AND PRESS SHIFT ENTER*)

(*VECTOR IN THE CARTESIAN BASIS *)
v1:=6
v2:=3
(* NEW BASIS *)
u1:=1
u2:=2
w1:=1
w2:=1

(* SET xmin xmax ymin ymax FOR THE PLOT *)

xmin:=-3
xmax:=7
ymin:=-4
ymax:=6



Sol[u1,u2,w1,w2,v1,v2,xmin,xmax,ymin,ymax]

(* INSERT THE VALUES  AND PRESS SHIFT ENTER*)

(*VECTOR IN THE CARTESIAN BASIS *)
v1:=6
v2:=3
(* NEW BASIS *)
u1:=1
u2:=2
w1:=2
w2:=1

(* SET xmin xmax ymin ymax FOR THE PLOT *)

xmin:=-3
xmax:=7
ymin:=-4
ymax:=6



Sol[u1,u2,w1,w2,v1,v2,xmin,xmax,ymin,ymax]

(* INSERT THE VALUES  AND PRESS SHIFT ENTER*)

(*VECTOR IN THE CARTESIAN BASIS *)
v1:=6
v2:=3
(* NEW BASIS *)
u1:=1
u2:=2
w1:=1
w2:=-1

(* SET xmin xmax ymin ymax FOR THE PLOT *)

xmin:=-3
xmax:=7
ymin:=-4
ymax:=6



Sol[u1,u2,w1,w2,v1,v2,xmin,xmax,ymin,ymax]

(* INSERT THE VALUES  AND PRESS SHIFT ENTER*)

(*VECTOR IN THE CARTESIAN BASIS *)
v1:=6
v2:=3
(* NEW BASIS *)
u1:=1
u2:=2
w1:=1
w2:=-2

(* SET xmin xmax ymin ymax FOR THE PLOT *)

xmin:=-3
xmax:=7
ymin:=-2
ymax:=8



Sol[u1,u2,w1,w2,v1,v2,xmin,xmax,ymin,ymax]

Space

(*PROGRAM TO CALCULATE THE NEW COMPONENTS IN THE PLANE*)

MS[u1_,u2_,u3_,w1_,w2_,w3_,z1_,z2_,z3_]:={{u1,w1,z1},{u2,w2,z2},{u3,w3,z3}}
InvS[u1_,u2_,u3_,w1_,w2_,w3_,z1_,z2_,z3_]:=Inverse[MS[u1,u2,u3,w1,w2,w3,z1,z2,z3]]

NCS[u1_,u2_,u3_,w1_,w2_,w3_,z1_,z2_,z3_,v1_,v2_,v3_]:=InvS[u1,u2,u3,w1,w2,w3,z1,z2,z3].{{v1},{v2},{v3}}



SolS[u1_,u2_,u3_,w1_,w2_,w3_,z1_,z2_,z3_,v1_,v2_,v3_]:=
MatrixForm[
{
"COMPONENTS IN THE CARTESIAN BASIS",
{v1,v2,v3},
"NEW BASIS",
{MatrixForm[{{u1},{u2},{u3}}],MatrixForm[{{w1},{w2},{w3}}],MatrixForm[{{z1},{z2},{z3}}]},
"COMPONENTS IN THE NEW BASIS",
If[Det[MS[u1,u2,u3,w1,w2,w3,z1,z2,z3]]==0,
"THE TRANSFORMATION MATRIX  IS NOT INVERTIBLE",
Transpose[NCS[u1,u2,u3,w1,w2,w3,z1,z2,z3,v1,v2,v3]][[1]]]
}
]

(* INSERT THE VALUES  AND PRESS SHIFT ENTER*)

(*VECTOR IN THE CARTESIAN BASIS *)
v1:=6
v2:=3
v3:=1
(* NEW BASIS *)
u1:=1
u2:=1
u3:=1

w1:=1
w2:=1
w3:=1

z1:=1
z2:=0
z3:=1



SolS[u1,u2,u3,w1,w2,w3,z1,z2,z3,v1,v2,v3]

(* INSERT THE VALUES  AND PRESS SHIFT ENTER*)

(*VECTOR IN THE CARTESIAN BASIS *)
v1:=6
v2:=3
v3:=1
(* NEW BASIS *)
u1:=1
u2:=1
u3:=1

w1:=1
w2:=1
w3:=2

z1:=1
z2:=0
z3:=1



SolS[u1,u2,u3,w1,w2,w3,z1,z2,z3,v1,v2,v3]

(* INSERT THE VALUES  AND PRESS SHIFT ENTER*)

(*VECTOR IN THE CARTESIAN BASIS *)
v1:=6
v2:=3
v3:=1
(* NEW BASIS *)
u1:=1
u2:=2
u3:=1

w1:=1
w2:=1
w3:=2

z1:=1
z2:=0
z3:=1



SolS[u1,u2,u3,w1,w2,w3,z1,z2,z3,v1,v2,v3]