1
$\begingroup$

Writing:

A = ImplicitRegion[Max[Abs[x - 1 + 2 y], Abs[y - 1 - 2 x]] == 1, {x, y}]; 
RegionPlot[DiscretizeRegion[A]]

I get:

enter image description here

while writing:

A = ImplicitRegion[Max[Abs[x - 1 + 2 y], Abs[y - 1 - 2 x]] == 1., {x, y}];
RegionPlot[DiscretizeRegion[A]]

I get:

enter image description here

Why?


Writing:

a = ImplicitRegion[Max[Abs[x-1+2y], Abs[y-1-2x]] == 1., {{x, -1, 1}, {y, -1, 2}}];
RegionPlot[DiscretizeRegion[a, {{-1, 1}, {-1, 2}}]]

I get:

enter image description here

and so things are not going well yet!

(I have 11.1.0 for Microsoft Windows (64-bit) (March 13, 2017))

$\endgroup$
  • $\begingroup$ Specify a region via A = ImplicitRegion[ Max[Abs[x - 1 + 2 y], Abs[y - 1 - 2 x]] == 1., {{x, -1, 1}, {y, -1, 2}}] works for me. Putting the region inside DiscretizeRegion also works: DiscretizeRegion[A, {{-1, 1}, {-1, 2}}] $\endgroup$ – egwene sedai Sep 22 '17 at 21:48
  • $\begingroup$ Never use an upper-case letter, or even a name that starts with an upper-case letter, as a variable in Mathematica (e.g., A) as it is likely to conflict with system variable names. $\endgroup$ – David G. Stork Sep 22 '17 at 23:05
  • $\begingroup$ Thanks for the answers. Above, I modified the question by taking it into account. $\endgroup$ – TeM Sep 23 '17 at 9:40
2
$\begingroup$

You can get better results by decreasing the maximum mesh size.

a =
  ImplicitRegion[
    Max[Abs[x - 1 + 2 y], Abs[y - 1 - 2 x]] == 1., {{x, -1, 1}, {y, -1, 2}}];
RegionPlot[DiscretizeRegion[a, MaxCellMeasure -> .00001]]

plot

But, really, in this case you will be much better off using exact numbers; i.e, to replace

Max[Abs[x - 1 + 2 y], Abs[y - 1 - 2 x]] == 1.

with

Max[Abs[x - 1 + 2 y], Abs[y - 1 - 2 x]] == 1

Update

Here is some code that will get you started on your actual problem as you described it in a comment below.

With[{s = 2},
  Manipulate[
    Graphics[
      {EdgeForm[{Red, Thick}], FaceForm[None], 
       Translate[Rotate[sqFrame, inclination °], position]},
      Frame -> True,
      PlotRange -> 5 s,
      ImageSize -> 400],
    {{position, {0, 0}}, 4.5 s {-1, -1}, 4.5 s {1, 1}, .25, Appearance -> "Labeled"},
    {{inclination, 0}, -90, 90, 5, AppearanceElements -> All},
    Initialization :> (
      sqFrame =
        Polygon[
          TranslationTransform[-s {1, 1}/2][{{0, 0}, {s, 0}, {s, s}, {0, s}}]])]]

demo

$\endgroup$
  • $\begingroup$ Thank you! Unfortunately I have to simulate the collision between a square frame and a material point, so the square LxL I have to plotted for any center translation and for any angle of rotation, so I was looking for an efficient way to plot it. $\endgroup$ – TeM Sep 23 '17 at 18:59
  • 1
    $\begingroup$ @TeM. That is a very different and much easier question to answer. Simply define a square in terms of its center and its boundary polygon, then use the built-in geometric transforms Rotate and Translate to control the motion of the square in your graphics viewport. The results will be much faster than fooling around with regions. $\endgroup$ – m_goldberg Sep 23 '17 at 19:49
  • $\begingroup$ Thank you for your patience, unfortunately at times I think of asking for simplifying the problem, when I'm complicating it. I guess I'll open another thread to put the whole question. Thank you! $\endgroup$ – TeM Sep 23 '17 at 20:24
  • $\begingroup$ Fantastic, really, I understand! $\endgroup$ – TeM Sep 24 '17 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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