Skip to Main Content Skip to Search
Product Documentation

plot::Translate2dtranslation of 2D objects

plot::Translate3dtranslation of 3D objects

plot::Translate2d([d_x, d_y], object) shifts a 2D object by d_x units along the x-axis and d_y units along the y-axis.

plot::Translate3d([d_x, d_y, d_z], object) shifts a 3D object.

→ Examples

Calls:

plot::Translate2d([dx, dy], obj1, <obj2, ...>, <a = amin .. amax>, Options)

plot::Translate3d([dx, dy, dz], obj1, <obj2, ...>, <a = amin .. amax>, Options)

Parameters:

dx, dy, dz

the components of the shift vector: numerical real values or arithmetical expressions of the animation parameter a
dx, dy, dz are equivalent to the attribute Shift.

obj1, obj2, ...: 

arbitrary plot objects of the appropriate dimension

See Also:

plot, plot::copy, plot::Rotate2d, plot::Rotate3d, plot::Scale2d, plot::Scale3d, plot::Transform2d, plot::Transform3d

Details:

Example 1

We use an animated translation object to shift a vector to the tip of another vector:

A1 := plot::Arrow2d([0, 0], [2, 1], Color = RGB::Red):
A2 := plot::Arrow2d([0, 0], [2, 3], Color = RGB::Green):
plot(A1, plot::Translate2d([2*a, a], A2, a = 0..1,
                           TimeRange = 0..4),
     plot::Arrow2d([0, 0], [4, 4], Color = RGB::Blue,
                   VisibleFromTo = 4..6),
     Header = "how to add 2 vectors"):

MuPAD graphicsimage

delete A1, A2:

Example 2

Note that plot::Translate2d and plot::Translate3d do not actually change the objects translated, so it is possible to use the same object in different places in the same plot. As an example, we show an intuitive way of constructing the Sierpinski carpet, a flat version of the Menger sponge.

The Sierpinski carpet is a fractal with the general shape of a square and the property that the following operation maps it onto itself: Take eight copies, scale them by 1/3, and arrange them in a square with the middle left unfilled. Now, this can be directly written in MuPAD code:

Carpet := proc(iter)
  local square;
begin
  if iter <= 1 then
    return(plot::Polygon2d([[0,0], [0,1], [1,1], [1,0]],
                           Closed, Filled, FillPattern = Solid,
                           FillColor = [0.2234, 0.4563, 0.4568],
                           LinesVisible, LineColor = RGB::White,
                           Scaling = Constrained, Axes = None));
  else
    square := plot::Scale2d([1/3, 1/3], Carpet(iter-1));
    return(plot::Group2d(
                 plot::Translate2d([  0,   0], square),
                 plot::Translate2d([  0, 1/3], square),
                 plot::Translate2d([  0, 2/3], square),
                 plot::Translate2d([1/3,   0], square),
               //   plot::Translate2d([1/3, 1/3], square),
                 plot::Translate2d([1/3, 2/3], square),
                 plot::Translate2d([2/3,   0], square),
                 plot::Translate2d([2/3, 1/3], square),
                 plot::Translate2d([2/3, 2/3], square)));
  end_if;
end_proc:

plot(Carpet(3))

MuPAD graphics

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS