Hello guys,
I've been trying to solve a linear transformation of R^3 in wolfram mathematica, but i find it difficult to initialize the transformation. Here is the code that i've been trying but it doesn't work. Any suggestions?
Off[General::spell1]
$TextStyle = {FontFamily -> "Courier-Bold", FontSize -> 18};
ThreeDLinearTransform[M_] := ThreeDLinearTransform[M, {{-2.2, 2.2}, {-2.2, 2.2}, {-2.2, 2.2}}]
ThreeDLinearTransform[M_, plotrange_] := Module[{hpairs, vpairs, dpairs, hlines, vlines, dlines, Mhlines,Mvlines, Mdlines, k, n, domain, range},
hpairs = Table[{{0.`, k, n}, {1.`, k, n}}, {k, 0, 1, 0.1`}, {n, 0,1, 0.1`}];
vpairs = Table[{{k, 0.`, n}, {k, 1.`, n}}, {k, 0, 1, 0.1`}, {n, 0, 1, 0.1`}];
dpairs = Table[{{k, n, 0.`}, {k, n, 1.`}}, {k, 0, 1, 0.1`}, {n, 0, 1, 0.1`}];
hlines = {RGBColor[0, 0, 1], Thickness[0.006`], Line /@ hpairs};
vlines = {RGBColor[1, 0, 0], Thickness[0.006`], Line /@ vpairs};
dlines = {RGBColor[0, 1, 0], Thickness[0.006`], Line /@ dpairs};
domain = Show[Graphics[hlines], Graphics[vlines], Graphics[dlines], AspectRatio -> Automatic, PlotRange -> plotrange, Axes -> True,
Ticks -> {Range[Ceiling[plotrange[[1, 1]]],Floor[plotrange[[1, 2]]]], Range[Ceiling[plotrange[[2, 1]]], Floor[plotrange[[2, 2]]]]},DisplayFunction -> Identity];
Mhlines = {RGBColor[0, 0, 1], Thickness[0.006`], Line /@ ({M.#1[[1]], M.#1[[2]]} &) /@ hpairs};
Mvlines = {RGBColor[1, 0, 0], Thickness[0.006`], Line /@ ({M.#1[[1]], M.#1[[2]]} &) /@ vpairs};
Mdlines = {RGBColor[0, 1, 0], Thickness[0.006`],Line /@ ({M.#1[[1]], M.#1[[2]]} &) /@ dpairs};
range = Show[Graphics[Mhlines], Graphics[Mvlines], AspectRatio -> Automatic, PlotRange -> plotrange, Axes -> True,
Ticks -> {Range[Ceiling[plotrange[[1, 1]]], Floor[plotrange[[1, 2]]]], Range[Ceiling[plotrange[[2, 1]]], Floor[plotrange[[2, 2]]]]}, DisplayFunction -> Identity];
Show[GraphicsRow[{domain, range}], DisplayFunction -> $DisplayFunction, ImageSize -> {640, 480}]]
and here is the rotation of 45 degrees that I'm trying to do:
A = (1/2) {{Sqrt[2], -Sqrt[2], Sqrt[2] }, {Sqrt[2], -Sqrt[2], Sqrt[2]}, {Sqrt[2], -Sqrt[2], Sqrt[2]}};
MatrixForm[A]
ThreeDLinearTransform[A]