Group Abstract Group Abstract

Message Boards Message Boards

1
|
4.1K Views
|
6 Replies
|
3 Total Likes
View groups...
Share
Share this post:

RegionUnion of 4 polygons not working in NSolve?

Posted 4 years ago
POSTED BY: Erik Mahieu
6 Replies
POSTED BY: Gianluca Gorni
Posted 4 years ago
POSTED BY: Erik Mahieu
Posted 4 years ago

Thanks for the advice Gianluca. I also try out all sorts of things, especially to get geometric code to work. I tried DiscretizeGraphics, DiscretizeRegion, etc.. However, the relation between (of all things) Rationalize and RegionUnion or Polygon is completely baffling for me. But it works!

Somebody at Wolfram should be able to explain this??

POSTED BY: Erik Mahieu

My experience with computational geometry in Mathematica is that I cannot predict in advance which approach will work for a given problem, and I must be prepared to try something else. I don't ask "why" any more.

POSTED BY: Gianluca Gorni
Posted 4 years ago

Thank you Gianluca! This works really well but hard to understand "why" for me. Where did you get this, in the docs?

POSTED BY: Erik Mahieu

It works if you Rationalize the coordinates:

polys = Rationalize@{Polygon[{{0, -2, -2.9}, {0, -1.5, -2.65}, {10, \
-1.5, -2.65}, {10, -2, -2.9}}], 
    Polygon[{{0, -1.5, -2.65}, {0, 0, -2.95}, {10, 
       0, -2.95}, {10, -1.5, -2.65}}], 
    Polygon[{{0, 0, -2.95}, {0, 1.5, -2.5}, {10, 1.5, -2.5}, {10, 
       0, -2.95}}], 
    Polygon[{{0, 1.5, -2.5}, {0, 2, -3.5}, {10, 2, -3.5}, {10, 
       1.5, -2.5}}]};
line = Rationalize@HalfLine[{0, 1, 0}, {1, 0, -.52}];
surface = RegionUnion[polys];
Solve[And[Element[{x, y, z}, line], Element[{x, y, z}, surface]], {x, 
  y, z}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard