2
$\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$
2
  • $\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$ Commented Sep 22, 2017 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$ Commented Sep 22, 2017 at 23:05

1 Answer 1

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$
1
  • 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
    Commented Sep 23, 2017 at 19:49

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.