Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have to manipulate a matrix and graphics in one big Manipulate-Block.

This way:

Manipulate[Matrixform[mat],Graphics3D[]]

How can I achieve that?

Ok, here my Code:

Manipulate[
 Graphics3D[
  {
   Switch[x, 
    "Streckung", {GraphicsComplex[streckung[a, b, c], Polygon[i]]}, 
    "Verschiebung", {GraphicsComplex[
      wuerfel[a, b, c, verschiebung, k], Polygon[i]]}, 
    "Parallelprojektion", {GraphicsComplex[
      wuerfel[a, b, c, verschiebung, k], Polygon[i]], Green, Polygon[
      Transpose [
        ReplacePart[
         Transpose[
          wuerfel[a, b, c, verschiebung, 
            k].{{1, 0, 0}, {0, 1, 0}, {0, 0, 0}}], {{_, 2}, {_, 
            4}, {_, 6}, {_, 8}} :> Sequence[]]][[{1, 2, 4, 3}, All]]],
      Blue, Polygon[
      Transpose [
        ReplacePart[
         Transpose[
          wuerfel[a, b, c, verschiebung, 
            k].{{1, 0, 0}, {0, 0, 0}, {0, 0, 1}}], {{_, 3}, {_, 
            4}, {_, 7}, {_, 8}} :> Sequence[]]][[{1, 2, 4, 3}, 
        All]]], Red, Polygon[
      Transpose [
        ReplacePart[
         Transpose[
          wuerfel[a, b, c, verschiebung, 
            k].{{0, 0, 0}, {0, 1, 0}, {0, 0, 1}}], {{_, 5}, {_, 
            6}, {_, 7}, {_, 8}} :> Sequence[]]][[{1, 2, 4, 3}, 
        All]]]}, 
    "x-Drehung", {GraphicsComplex[wdrehungx[w], Polygon[i]]},
    "y-Drehung", {GraphicsComplex[wdrehungy[w], Polygon[i]]},
    "z-Drehung", {GraphicsComplex[wdrehungz[w], Polygon[i]]}]},
  Axes -> True, Boxed -> True, 
  Switch[x, "Verschiebung", PlotRange -> {{0, 5}, {0, 5}, {0, 5}}, 
   "Parallelprojektion", PlotRange -> {{0, 5}, {0, 5}, {0, 5}}, _, 
   PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}]], {{a, 1, "x-Richtung"}, 
  Switch[x, "Verschiebung", 0, "Streckung", 0, "Parallelprojektion", 
   0, _, -3], 3},
 {{b, 1, "y-Richtung"}, 
  Switch[x, "Verschiebung", 0, "Streckung", 0, "Parallelprojektion", 
   0, _, -3], 3},
 {{c, 1, "z-Richtung"}, 
  Switch[x, "Verschiebung", 0, "Streckung", 0, "Parallelprojektion", 
   0, _, -3], 3},
 {{w, 0, "Winkel (in \[Degree])"}, 0, 360},
 Button["Reset", a = 1; b = 1; c = 1; w = 0],
 {x, {"Streckung", "Verschiebung", "Parallelprojektion", "x-Drehung", 
   "y-Drehung", "z-Drehung"}, ControlType -> PopupMenu},
 Initialization :> 
  (verschiebung := {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {a, b, 
      c, 1}};
   k := PolyhedronData["Cube", "VertexCoordinates"];
   Short[i = PolyhedronData["Cube", "FaceIndices"]];
   streckung[a_, b_, c_] := k.{{a, 0, 0}, {0, b, 0}, {0, 0, c}};
   wuerfel[a_, b_, c_, M_, l_] := 
    ReplacePart[
     Transpose[
       Insert[Transpose[l], 
        ConstantArray[1, 
         Map[Part[Dimensions[l], Sequence @@ #] &, {1}]], 
        Map[Part[Dimensions[l], Sequence @@ #] &, {2}] + 1]].M, {{_, 
        4}} :> Sequence[]];
   wdrehungx[a_] := 
    k.{{1, 0, 0}, {0, Cos[a Degree], -Sin[a Degree]}, {0, 
       Sin[ a Degree], Cos[a Degree]}};
   wdrehungz[a_] := 
    k.{{Cos[a Degree], -Sin[a Degree], 0}, {Sin[a Degree], 
       Cos[a Degree], 0}, {0, 0, 1}};
   wdrehungy[a_] := 
    k.{{Cos[a Degree], 0, -Sin[a Degree]}, {0, 1, 0}, {Sin[a Degree], 
       0, Cos[a Degree]}};
   )
 ]

Mathematica graphics

I have to show each transformmatrix. when you choose "streckung" for example, you should see the transformmatrix streckung with the manipulated variables a,b and c.

share|improve this question
1  
Please include your code showing what you've tried. What you've included above is not valid code. –  rm -rf Dec 29 '13 at 23:02
3  
Maybe what you want is: Row[{Matrixform[mat],Graphics3D[]}] –  bill s Dec 29 '13 at 23:06
2  
Someone should write a Mathematica function that guesses what a question is asking. May be wolfram alpha can handle this, since it is an AI program also. –  Nasser Dec 29 '13 at 23:15
    
@Nasser !Mathematica graphics –  belisarius Dec 30 '13 at 0:17
    
@Nasser We could add a new gray button to our JS collection i.stack.imgur.com/z7N3d.png –  belisarius Dec 30 '13 at 1:10
add comment

closed as unclear what you're asking by m_goldberg, bobthechemist, Pickett, Oleksandr R., Mr.Wizard Jan 8 at 14:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Here's one way, basically as in my comment:

Manipulate[
 GraphicsRow[{streckung[a, b, c] // MatrixForm, 
   Graphics3D[{Switch[x, 
      "Streckung", {GraphicsComplex[streckung[a, b, c], Polygon[i]]}, 
      "Verschiebung", {GraphicsComplex[
        wuerfel[a, b, c, verschiebung, k], Polygon[i]]}, 
      "Parallelprojektion", {GraphicsComplex[
        wuerfel[a, b, c, verschiebung, k], Polygon[i]], Green, 
       Polygon[Transpose[
          ReplacePart[
           Transpose[
            wuerfel[a, b, c, verschiebung, 
              k].{{1, 0, 0}, {0, 1, 0}, {0, 0, 0}}], {{_, 2}, {_, 
              4}, {_, 6}, {_, 8}} :> Sequence[]]][[{1, 2, 4, 3}, 
          All]]], Blue, 
       Polygon[Transpose[
          ReplacePart[
           Transpose[
            wuerfel[a, b, c, verschiebung, 
              k].{{1, 0, 0}, {0, 0, 0}, {0, 0, 1}}], {{_, 3}, {_, 
              4}, {_, 7}, {_, 8}} :> Sequence[]]][[{1, 2, 4, 3}, 
          All]]], Red, 
       Polygon[Transpose[
          ReplacePart[
           Transpose[
            wuerfel[a, b, c, verschiebung, 
              k].{{0, 0, 0}, {0, 1, 0}, {0, 0, 1}}], {{_, 5}, {_, 
              6}, {_, 7}, {_, 8}} :> Sequence[]]][[{1, 2, 4, 3}, 
          All]]]}, 
      "x-Drehung", {GraphicsComplex[wdrehungx[w], Polygon[i]]}, 
      "y-Drehung", {GraphicsComplex[wdrehungy[w], Polygon[i]]}, 
      "z-Drehung", {GraphicsComplex[wdrehungz[w], Polygon[i]]}]}, 
    Axes -> True, Boxed -> True, 
    Switch[x, "Verschiebung", PlotRange -> {{0, 5}, {0, 5}, {0, 5}}, 
     "Parallelprojektion", PlotRange -> {{0, 5}, {0, 5}, {0, 5}}, _, 
     PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}]]}], {{a, 1, 
   "x-Richtung"}, 
  Switch[x, "Verschiebung", 0, "Streckung", 0, "Parallelprojektion", 
   0, _, -3], 3}, {{b, 1, "y-Richtung"}, 
  Switch[x, "Verschiebung", 0, "Streckung", 0, "Parallelprojektion", 
   0, _, -3], 3}, {{c, 1, "z-Richtung"}, 
  Switch[x, "Verschiebung", 0, "Streckung", 0, "Parallelprojektion", 
   0, _, -3], 3}, {{w, 0, "Winkel (in \[Degree])"}, 0, 360}, 
 Button["Reset", a = 1; b = 1; c = 1; 
  w = 0], {x, {"Streckung", "Verschiebung", "Parallelprojektion", 
   "x-Drehung", "y-Drehung", "z-Drehung"}, ControlType -> PopupMenu}, 
 Initialization :> (verschiebung := {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 
      0, 1, 0}, {a, b, c, 1}};
   k := PolyhedronData["Cube", "VertexCoordinates"];
   Short[i = PolyhedronData["Cube", "FaceIndices"]];
   streckung[a_, b_, c_] := k.{{a, 0, 0}, {0, b, 0}, {0, 0, c}};
   wuerfel[a_, b_, c_, M_, l_] := 
    ReplacePart[
     Transpose[
       Insert[Transpose[l], 
        ConstantArray[1, 
         Map[Part[Dimensions[l], Sequence @@ #] &, {1}]], 
        Map[Part[Dimensions[l], Sequence @@ #] &, {2}] + 1]].M, {{_, 
        4}} :> Sequence[]];
   wdrehungx[a_] := 
    k.{{1, 0, 0}, {0, Cos[a Degree], -Sin[a Degree]}, {0, 
       Sin[a Degree], Cos[a Degree]}};
   wdrehungz[a_] := 
    k.{{Cos[a Degree], -Sin[a Degree], 0}, {Sin[a Degree], 
       Cos[a Degree], 0}, {0, 0, 1}};
   wdrehungy[a_] := 
    k.{{Cos[a Degree], 0, -Sin[a Degree]}, {0, 1, 0}, {Sin[a Degree], 
       0, Cos[a Degree]}};)]

enter image description here

share|improve this answer
    
Bill, there is also few problems with the original code. k has delay on it even though it is constant. k is being passed around as argument L in function wuerfel, which makes no sense, since k is constant an already in the initialization section. verschiebung := is in the initialization section, yet it depends on control variables. Lots of calls to Dimensions[k], yet k do not change. These could be all made constants so that no need to made the same calls all the time since the value do not change. –  Nasser Dec 30 '13 at 1:35
    
@Nasser -- It could be made to look (and act) a lot nicer, but I was responding to the OPs question about how to display the matrices along with the plot. –  bill s Dec 30 '13 at 1:38
    
Sure, I understand, I was not criticizing you :) just pointing out some issues in original code. –  Nasser Dec 30 '13 at 1:40
    
Thanks for the moment, now you can see the matrix and the graphic. Another problem is, that the graphic is now very small. How can I get this bigger? I want it to look like here: demonstrations.wolfram.com/PolarAreaSweep On top the matrix, a delimeter and the graphic in that size like in my uploaded code. –  Manu Dec 30 '13 at 12:39
    
Have you looked at the code at that demonstration? Downlaod it and you will see how they did it: the code starts with Column[{Text@TraditionalForm@Style[Row[{ ... so they use a combination of Column and Row (instead of GraphicsRow) but the idea is the same. Another useful command is ImageSize though you have a lot of flexibility in the sizing of graphics commands. –  bill s Dec 30 '13 at 15:10
show 3 more comments

Not the answer you're looking for? Browse other questions tagged or ask your own question.