       Re: Translations

• To: mathgroup at smc.vnet.net
• Subject: [mg32474] Re: Translations
• From: "David P. Johnson" <johnson at nmtx.edu>
• Date: Tue, 22 Jan 2002 03:20:02 -0500 (EST)
• Organization: New Mexico Tech
• References: <a2gi1g\$kl\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```In article <a2gi1g\$kl\$1 at smc.vnet.net>, manuel avalos
<manuel at voicenet.com> wrote:

> Hello
>
> Perhaps if I state my problem you might suggest a method using
> mathematica how it could be accomplished.
> How can I translate a graph, say a triangle, in an R2 coordinate system
> to another given position on the x y plane showing all the various
> stages from the one position to the other?
> The triangle was formed by connecting the points (-4,4),(-3,-2) and
> (-2,-4) by straight lines...and another triangle was formed by
> translating that triangle by (6,6). Suppose you want to move the first
> triangle smoothly to the position of the second triangle using, let's
> say, a total of 31 frames numbered- 0, 1, 2,...30. How would one go
> Thanks for whatever
> Manuel

This can be done with a Do loop. If all you want to do is move the
triangle up and over by the same amount (6 as you stated above, this is
simple. First, here's the truangle you gave:

In:=
triangle={{-4,4},{-3,-2},{-2,-4},{-4,4}};

Next, put a ListPlot inside a Do loop, adding the increment 6i/30 to x
amd y for each vertex (6 is the amount you want to translate, and 30 is
the number of frames in the animation):

In:=
Do[ListPlot[triangle+6i/30,PlotJoined->True,
PlotRange->{{-4,4},{-4,10}}],{i,0,30}]

The PlotRange is required so that each frame in the animation has the
same axis ranges. If you double-click on the bracket (at right) that
encloses all the plots (but not the Do[] statement), they will all
collapse to one cell. Double click on this cell to play the animation.

If instead of translating up and over by the same amount, you'll have
to change it some, using the Table[] command. For instance, if you want
to move your triangle up six, but over only 2, then the following will
do it:

In:=
Do[ListPlot[Table[{triangle[[j,1]]+2i/30,triangle[[j,2]]+6i/30},{j,1,4}],
PlotJoined->True,PlotRange->{{-4,4},{-4,10}}],{i,0,30}]

--
-David
(Signature continues here)
N.B.: Remove the 'x' to email me

```

• Prev by Date: RE: Translations
• Next by Date: Tom Wickham Jones presents webMathematica course in Amsterdam
• Previous by thread: RE: Translations
• Next by thread: Programming question