Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Color grid with x and y args to visualize effects of 2D

  • To: mathgroup at smc.vnet.net
  • Subject: [mg0] Re: Color grid with x and y args to visualize effects of 2D
  • From: Fred Bartoli <myname_with_a_dot_inbetween at free.fr>
  • Date: Mon, 21 Feb 2011 05:40:16 -0500 (EST)
  • References: <ijo588$lk8$1@smc.vnet.net> <ijqqmc$ars$1@smc.vnet.net>
  • Reply-to: myname_with_a_dot_inbetween at free.fr

Christopher O. Young a écrit :
> On 2/19/11 5:15 AM, in article ijo588$lk8$1 at smc.vnet.net, "Christopher O.
> Young" <cy56 at comcast.net> wrote:
> 
>> I'm trying to get a simple kind of color chart function that I can pass x
>> and as arguments to. I want to have it running across by hue and up by
>> saturation and value. This is to illustrate 2D transformations, so I need to
>> have arguments that I can _inversely_ transform in order to illustrate the
>> effects of 2D transformations, whether linear or not.
>>
>> One direct approach would seem to have nested loops, but I can't see how to
>> do this if the body of the For loop in Mathematica is part of the function.
>>
>> Any help getting a "jump start" in this kind of thing would be a huge help
>> to me.
>>
>> For[i = 0, i < 10, i++,
>>
>>   For[j = 0, j < 10, j++,
>>
>>       RegionPlot[(i < x < i + 1) && (j < y < j + 1), {x,0,10}, {y,0,10}]
>>
>>   ]
>>  
>> ]
> 
> 
> As shown at http://home.comcast.net/~cy56/Grid.nb, I finally got a color
> grid with x and y as arguments, but it's hard to believe there isn't a
> simpler way to do it. It's quite a struggle to figure out how to specify the
> colors. If high school students are going to be comfortable with doing these
> visualizations, there needs to be a way to simplify this radically, I think.
> 
> I need to have the arguments x and y since I want to be able to transform
> the grid by transforming x and y using the inverse transform.
> 
> RegionPlot[
>   {0 < x < 1 && 0 < y < 1,
>    0 < x < 1 && 1 < y < 2,
>    0 < x < 1 && 2 < y < 3,
>    1 < x < 2 && 0 < y < 1,
>    1 < x < 2 && 1 < y < 2,
>    1 < x < 2 && 2 < y < 3,
>    2 < x < 3 && 0 < y < 1,
>    2 < x < 3 && 1 < y < 2,
>    2 < x < 3 && 2 < y < 3},
>   {x, 0, 3}, {y, 0, 3},
>   ColorFunction ->  Function[{x, y},
>      Hue[\[LeftFloor]x\[RightFloor]/3, .5 + .5 \[LeftFloor]y\[RightFloor]/3,
> 1]],
>   ColorFunctionScaling -> False
>  ]
> 
> 
> I still can't figure out how to use Table or whatever to get the region
> specifications into a general function. 
> 
> 

mappingFunc[{x_, y_, scale_}] = {x/scale, y/scale};

(* or, if you want to vary brightness as well and get your students lost :-)

mappingFunc[{x_, y_, scale_}] = {x/scale, y/scale, 
yourbrightnessfunction[x,y]};

*)

data[n_] := Table[mappingFunc@{j, i, n}, {i, 0, n}, {j, 0, n}]
data[3]
Graphics@Raster[data[10], ColorFunction -> Hue, ColorFunctionScaling -> 
False]


-- 
Thanks,
Fred.


  • Prev by Date: Re: NDSolve Unable to find initial conditions that satisfy the
  • Next by Date: Re: Solids of revolution
  • Previous by thread: Re: Color grid with x and y args to visualize effects of 2D
  • Next by thread: Re: Color grid with x and y args to visualize effects of 2D