Mathematica demos for teaching

by Oliver Knill

3. Interacting with lines and showing text

Manipulate[ A={{a,b},{c,d}};
  Q1 = {0,0}; Q2 = Dynamic[A.{1,0}]; Q3 = {0,0}; Q4 = Dynamic[A.{0,1}];
  B0={RGBColor[0,1,0],PointSize[0.04], Dynamic[Point[Q1]]};
  B1={RGBColor[1,0,0],Thickness[0.02], Dynamic[Arrow[{Q1,Q2}]]};
  B2={RGBColor[0,0,1],Thickness[0.01], Dynamic[Arrow[{Q1,Q4}]]};
  B3={RGBColor[1,1,0],Dynamic[Polygon[{Q1,Q2,Q2+Q4,Q4}]]};
  B4 = Locator[Dynamic[{a,c}]];
  B5 = Locator[Dynamic[{b,d}]];
  B6 = Text[MatrixForm[Dynamic[Floor[10*{{a,b},{c,d}}]]],{1.5,1.5}]; 
  Graphics[{B6,B3,B2,B1,B0,B4,B5}, 
   PlotRange -> {{-2,2},{-2,2}},
   ImageSize -> {400,400}], 
   {{a,1},{-1,1},ControlType->None},
   {{b,0},{-1,1},ControlType->None},
   {{c,0},{-1,1},ControlType->None},
   {{d,1},{-1,1},ControlType->None}]