In my previous question 2D random walk within a bounded area, I asked how to implement a 2D random walk within a bounded area. In the provided solution, one can use Rectangle[{-10, -10}, {10, 10}]
or Disk[{x, y}, r]
to define the bounded region as a disk or rectangle. How can I define new bounded regions in Mathematica?
For example, how can I add these two Rectangle[{-10, -10}, {10, 10}]
and Rectangle[{10, 0}, {15, 5}]
to get a new region made of these two rectangles?
Polygon
on earlier versions. $\endgroup$Element[position + randomStep, region]
is the line that determines if the new step is valid or not. If you use an earlier version than 10, you don't have access toRegionUnion
so you can't combine arbitrary shapes. Instead you have to writeElement[position + randomStep, rectangel1] || Element[position+randomStep, rectangle2]
to indicate that both areas are valid. $\endgroup$