cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to plot mesh with if condition

ifomenko
15-Moonstone

How to plot mesh with if condition

Hi
I`m trying to plot function on triangular area without success. Is it possible?
CreateMesh with if statement.png

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:ifomenko)

Finally found it!

I knew it would/should be lying around somewhere but wasn't able to find it in first place.

A long time ago I tried to write an alternative "CreateMesh" function which would allow for a polygon as boundary rather than just being limited to a rectangle with the standard the x- and y-limits. Of course I missed the ability to use NaN a lot at those times and tried to find workarounds. The first attempt was a quick hack and then the project never was finished and fell into oblivion. The last version was quite faulty, especially when using non-convex polygons, some polygons which the function for some reason did not like (changing the order of the points in the polygon sometimes helped). I guess I did not come back to finish the project because I realized that I would not be able to achieve with reasonable efforts what my goal at those times was - using multiple polygons to create "holes" in the boundary area. As you can see in the example below I succeeded in avoiding any mesh points in the "hole" area, but because of the simple approach used there still are mesh lines in this area which means that it will be filled and so no see-through effect.

For whatever it may be worth I attach the worksheet "as is" if someone likes to play around with it.

Werner_E_1-1581460991011.pngWerner_E_0-1581460967545.png

 

 

View solution in original post

5 REPLIES 5
Werner_E
25-Diamond I
(To:ifomenko)

 


@ifomenko wrote:

Hi

I`m trying to plot function on rectangular area without success. Is it possible?


Unfortunately Mathcads 3D plot does not suppport Nan's (on contrary to its 2D plots).

So all you can do is to set values outside of the desired area to a value which does not do too much harm.

Another workaround is to find a different suitable parameter representation of the surface which allows you to just show the desired part. That can be quite tricky and difficult.

 

BTW, x+y<1 does NOT describe a rectangular area!

 

P.S.: Prime 3Dplots usually are a total crap, but they have one advantage - they support NaN's

Nonetheless Primes 3D plot shows a strange black area which should not be there.

See attached picture. It looks like inserting pics from the clipboard directly in the posts body does not work any more once again.

 
 

EDIT: Its confusing to edit and change a post after people have answered to and referred to what was written initially.

I see that now you are talking about a "triangular area" instead of a "rectangular area" and you have deleted the screenshot you initially had provide. This takes others the chance to take part in the thread and maybe find a solution to your problem (in case you still are interested). BTW, I wouldn't call the area described by x+y<1 "triangular" either, as this inequation describes half of the full plane. Or are there additional constraints like x>0 and y>0 ? Then we would have a triangular area.

 

 

ifomenko
15-Moonstone
(To:Werner_E)

Thanks, I`ve found solution!

3D NaN override.png

LucMeekes
23-Emerald III
(To:ifomenko)

This may be another way of solving it:

LucMeekes_0-1581285548315.png

Of course the magic is in the limit function. See attachment...

 

Success!
Luc

ifomenko
15-Moonstone
(To:LucMeekes)

Not bad, you`ve got zig-zag edge, but I like it, thanks

Werner_E
25-Diamond I
(To:ifomenko)

Finally found it!

I knew it would/should be lying around somewhere but wasn't able to find it in first place.

A long time ago I tried to write an alternative "CreateMesh" function which would allow for a polygon as boundary rather than just being limited to a rectangle with the standard the x- and y-limits. Of course I missed the ability to use NaN a lot at those times and tried to find workarounds. The first attempt was a quick hack and then the project never was finished and fell into oblivion. The last version was quite faulty, especially when using non-convex polygons, some polygons which the function for some reason did not like (changing the order of the points in the polygon sometimes helped). I guess I did not come back to finish the project because I realized that I would not be able to achieve with reasonable efforts what my goal at those times was - using multiple polygons to create "holes" in the boundary area. As you can see in the example below I succeeded in avoiding any mesh points in the "hole" area, but because of the simple approach used there still are mesh lines in this area which means that it will be filled and so no see-through effect.

For whatever it may be worth I attach the worksheet "as is" if someone likes to play around with it.

Werner_E_1-1581460991011.pngWerner_E_0-1581460967545.png

 

 

Announcements

Top Tags