06-240/QuiltPlot

From Drorbn
Revision as of 10:25, 17 October 2006 by Drorbn (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
06-240-QuiltBeforeMap.png 06-240-QuiltAfterMap.png

Code in Mathematica:

QuiltPlot[{f_,g_}, {x_, xmin_, xmax_, nx_}, {y_, ymin_, ymax_, ny_}] :=
Module[
  {dx, dy, grid, ix, iy},
  SeedRandom[1];
  dx=(xmax-xmin)/nx;
  dy=(ymax-ymin)/ny;
  grid = Table[
    {x -> xmin+ix*dx, y -> ymin+iy*dy},
    {ix, 0, nx}, {iy, 0, ny}
  ];
  grid = Map[({f, g} /. #)&, grid, {2}];
  Show[
    Graphics[Table[
      {
        RGBColor[Random[], Random[], Random[]],
        Polygon[{
          grid[[ix, iy]],
          grid[[ix+1, iy]],
          grid[[ix+1, iy+1]],
          grid[[ix, iy+1]]
        }]
      },
      {ix, nx}, {iy, ny}
    ]],
    Frame -> True
  ]
]

QuiltPlot[{x, y}, {x, -10, 10, 8}, {y, 5, 10, 8}]
QuiltPlot[{x^2-y^2, 2*x*y}, {x, -10, 10, 8}, {y, 5, 10, 8}]

Back to 06-240/Linear Algebra - Why We Care.