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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Translate the entire conversation x

Chart Component

RM_12291418
4-Participant

Chart Component

Hello everyone, I hope you are doing fine!

I recently calculated wave theory selection using Mathcad Prime 9.0.0.0. I'm curious, is there a way to determine the region automatically for given points? I want the function to return "Linear/Airy", "Stokes 5", "Stream Function 3", etc. based on the chart.

Does anyone know? I attached the full calculation below.

 

RM_12291418_0-1758161862694.png

 

19 REPLIES 19
Werner_E
25-Diamond I
(To:RM_12291418)

No, Prime does not offer any automatic way to determine which area a given point would lie in.

You would have to program a function which determines which area a point with given coordinates is in and also would have to decide what to do with points lying on the border of two or more areas. Looks like quite some work to do.

RM_12291418
4-Participant
(To:Werner_E)

I see. Thank you for the explanation!

Hi

A while ago dealing with vector based text fonts in bitmap graphics on this forum wrote a Mathcad 15 routine to find if a point is in a polygon.

If the areas on your excellent graph are turned into polygons it is possible to test where a point lies.

This will take a while to work up so please be patient.

Cheers

Terry

Hi,

Here is the start on point in polygon method to determine where a point is.

It uses a complex variable for each point with Re() being the x coordinate and Im() being the y coordinate.

I would rather do this than rewrite the point in polygon functions.

 

Cheers

Terry

Hi! Thank you so much, Terry!

I'd like to ask, should I just continue this section until all the polygons are defined?

RM_12291418_1-1758187976077.png

 

Also, can you explain what do these loopings do? Please explain the mathemathical forms into sentence

RM_12291418_2-1758188130757.png

 

Thank you!

 

Hi,

I'd like to ask, should I just continue this section until all the polygons are defined?

 

terryhendicott_1-1758189360596.png

Yes just keep going until they are all defined.  The method I have shown here results in for example poly2 a figure eight shape that should be sorted out.  That is why I have asked for the excel sheet with the lines in.  In poly1 I have added the bottom left corner of the graph as well.

 

Also, can you explain what do these loopings do? Please explain the mathemathical forms into sentence

terryhendicott_2-1758189922678.png

The pip3() function stands for point in polygon version 3.  The function takes a point and a polygon as inputs.

It returns zero (means false) if the point lies outside the polygon.  It returns 1 (means true) if the point lies inside or on the boundary.

This zero and one result can be used in an if statement to make a choice between two options true and false.

I have given examples of a point inside (gives the name of the region) and an example of a point outside (gives "No") of each of the first three polygons.

In the end I would write a program to test all the polygons in turn to determine which one the point lies in.

Capture.JPG

A complex variable for each point is used for points and polygons with Re() being the x coordinate and Im() being the y coordinate.

Above is a sample of a point inside poly1

 

Cheers

Terry

 

 

Hi,

Here is a sample of the final function to select a region.

Capture.JPG

Hi,

Completed worksheet.

Alteration to poly5 to square off the top right corner:

Capture.JPG

Capture2.JPG

Cheers

Terry

Nice implementation of the Jordan scanline algorithm. Works quite well apart from a minor inconsistency with vertex points or points on polygon edges. Some of these points are seen as interior points and others are not.

Werner_E_0-1758235561890.png

You may streamline the is_between function to

Werner_E_2-1758236456901.png

and you could get rid of the if-statement at the end of the pip3 function

Werner_E_7-1758240242214.png

 

BTW, in "pip3wh", why do you exclude hole-polygons starting at the origin with

Werner_E_1-1758236155284.png  ???

 

In the attached sheet I added an winding counting algorithm quickly converted from an old Mathcad sheet and called it "pip4". When I look at it after that many years I have the feeling that is sure could be written more simplified.

pip4 still seems to have a problem with the point(s) of intersection of self-intersecting polygons.

Werner_E_9-1758240817467.png

 

Maybe the Dan Sunday algorithm would be a better (and faster) alternative?

 

Prime 9 sheet attached.

Prime 9 did not allow me to save the sheet while the original Chart component was embedded. (I know why I hate and avoid the chart component). So I deleted all but the "pip" functions and the demo polygon.
So this sheet does not deal with the original question but the function pip4 within sure could be used to determine the area a point lies in once the polygons are defined correctly.

 

 

Werner_E
25-Diamond I
(To:Werner_E)

Concerning holes it looks like your pip3 (notpip3wh) can pretty well deal with holes when they are part of the polygon but separated by NaN. But that would need further testing with various holed polygons.

BTW, pip4 fails completely when provided polygons with NaN's.

I think it would be good for both algorithms to consciously recognize NaNs in the polygon list and skip them.

Werner_E_10-1758241664549.png

Also works with multiple holes. One can argue about the hole in hole, though 

Werner_E_12-1758242325444.png

 

We may get undesired effects when the hole surmounts the original polygon 😉

Werner_E_11-1758241814608.png

 

 

Werner_E
25-Diamond I
(To:Werner_E)

Added another "point-in-polygon" algorithm "pip5". 

Its basically also a ray casting algorithm counting the number of intersection points with the polygon edges to the right of a given point.

But it distinguishes between three possible positions with its return value: IN the polygon (2), ON the polygon (1), and OUTSIDE (0).

So I derived two functions, pip5a (including margin) and pip5b (excluding margin), for testing purposes.

The four algorithms included so far can be selected via a simple combo box.

Feel free to play around and report any problems or discrepancies with the algorithms.

 

Prime 9 sheet attached

Hello @RM_12291418

 

It looks like you have some responses from our community experts. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Vivek N.
Community Moderation Team.

Hi,

Can you upload the excel sheet for the lines?

Cheers

Terry

Werner_E
25-Diamond I
(To:RM_12291418)

Here is my attempt defining the necessary polygons and determining the area a points lies in:

Werner_E_0-1758331536512.png

 

After saving the file and reopening it the region with the Chart component was corrupt and so I deleted it.

Prime 9 file attached

Werner_E
25-Diamond I
(To:Werner_E)

Added the hatching function by Prof. Birkeland.

Unfortunately the creation of all the hatch lines is very time consuming and the result is not as nice as we would like. Guess its also because of the log scale.

Werner_E_0-1758343671524.png

 

Werner_E
25-Diamond I
(To:Werner_E)

Hatching took far too long in my opinion. So I implemented a simpler approach, filling the areas just with dots.
Also added grid lines.

Werner_E_0-1758350220231.png

 

StuartBruff
23-Emerald IV
(To:Werner_E)

By coincidence, I've (literally) just started looking at an old Express worksheet that generates cellular automata.  I used dots as a workaround for the missing Picture component.

 

2025 09 20 A.png

 

A thicker line style fills the space better, but looks a bit more brutal (IMO).

 

2025 09 20 B.png

 

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Rule 110?

EDIT: Should have looked at the top of your screen shot. Seems to be Wolframs Rule 30.

StuartBruff
23-Emerald IV
(To:Werner_E)

Bittet, so wird euch gegeben ...

 

2025 09 21 B.png

 

A triangle variant, so it does look like CA30.  I've changed the initialisation for this one, otherwise it was difficult to see.  A problem with the 2D Plot method for displaying CAs is that one can only display so many points before the display can only show single circles of minimal thickness.

 

2025 09 21 C.png

 

Stuart

Announcements

Top Tags