Message Boards Message Boards

0
|
2085 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Problem with RegionUnion function

Hi,

I'm having problems with generating the union of several cylinders. I create the cylinders with this code

    pVec1 = {5., 0, 0};
    pVec2 = 0.4 pVec1 + {0, 5., 0};
    pVec3 = 0.4 (pVec2 + pVec1)/2 + {0, 0, 5.};
    {posA, posB, posC} = {{0, 0, 0}, {-2., 4., 0}, 
       RotationMatrix[-\[Pi]/2, pVec2] . {-2., 4., 0}};
    len=1.; width = .2;
    {upVec1, upVec2, upVec3} = Normalize@# & /@ {pVec1, pVec2, pVec3};
    cylinders = {
      Cylinder[{posB + pVec1 - len upVec1, posB + pVec1 + len upVec1}, 
       width],
      Cylinder[{posB - len upVec1, posB + len upVec1}, width],
      Cylinder[{posA + pVec2 - len upVec2, posA + pVec2 + len upVec2}, 
       width],
      Cylinder[{posA - len upVec2, posA + len upVec2}, width],
      Cylinder[{posC + pVec3 - len upVec3, posC + pVec3 + len upVec3}, 
       width],
      Cylinder[{posC - len upVec3, posC + len upVec3}, width]}

Which gives the expected shape if you run the following code:

Graphics3D[cylinders]

enter image description here

However, if I generate the union of the same cylinders, I get the following

Region[RegionUnion @@ cylinders]

enter image description here

The region is cropped. Any insight on this?

If I use just a subset of the cylinders (up to 3 or 4) I don't get the problem.

Thanks in advance, Marcelo

POSTED BY: Marcelo Guzmán
4 Replies
Posted 2 years ago

Hi Marcelo,

I don't understand why it is cropped, but a simple workaround is

Region[RegionUnion @@ cylinders, PlotRange -> Full]
POSTED BY: Rohit Namjoshi
Posted 2 years ago

Values for upvec1,2,3 are missing. Can you please edit your question and add them.

POSTED BY: Rohit Namjoshi

Ah sorry for that, question updated.

POSTED BY: Marcelo Guzmán
Posted 2 years ago

How you go about this really depends on what you want to use the output for. I've found that the generic Region* functions have lots of problems with certain kinds of regions, especially if you want very accurate details. The Discretize* functions do better for most of my use cases. But again, it really depends on what you're going to do next.

Anyway, to just get a more accurate visualization of your system, you might try this:

DiscretizeRegion[RegionUnion @@ cylinders, MaxCellMeasure -> .0001]

As for "any insight" into why the generic Region cropped the visualization, I have no idea. That's the kind of stuff I've come to expect from Region* functions.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract