1
$\begingroup$

What is the difference between

Manipulate[Graphics[Disk[{x, 0}, 1], Axes -> True], {x, 0, 10}]

and

Manipulate[Graphics[Translate[Disk[{0, 0}, 1], {x, 0}], Axes -> True], {x, 0, 10}]

Both appear to give the same visualization.

$\endgroup$
0

2 Answers 2

2
$\begingroup$

If x is an abscissa of the Disk there is no point in using Translate which only makes the code longer.

If you want to scale the code and really translate a lot of graphics primitives then Translate makes sense as it can do it in bulk.

Eventually the best improvement here would be to wrap x with Dynamic. That way FrontEnd can take care of updating the position of the disc instead of recreating the whole Graphics scene. See more in tutorial/AdvencedDynamicFunctionality in Nesting Dynamics functionality.

Manipulate[
  Graphics[
    Translate[{Circle[], Rectangle[]}, {Dynamic@x, 0}], 
    Axes -> True, 
    PlotRange -> 12
  ], 
  {x, 0, 10}
]
$\endgroup$
0
$\begingroup$

I would say that they a nearly equivalent. The only difference I see is that

Translate[Disk[{0, 0}, 1], {x, 0}]

might be slightly slower than

Disk[{x, 0}, 1]

if this is used very often in a single Manipulate.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.