Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hello! I need to transform a short program from Visual basic to Mathcad. The algorithm is for determination whether point lies inside or outside of polygon. I have written program in Mathcad, but according to the result - incorrectly. Please help.
thanks in advance
Rosen
Solved! Go to Solution.
Rosen Mitrev wrote:
Hello! I need to transform a short program from Visual basic to Mathcad. The algorithm is for determination whether point lies inside or outside of polygon. I have written program in Mathcad, but according to the result - incorrectly. Please help.
thanks in advance
Rosen
I haven't checked your program in detail, Rosen, but it seems to work when given a (closed) square to deal with.
I've given an alternative implementation using 'continue' rather than nested if statements. This allows an implementation that is closer to the original. I've also a set of test points that track through the polygon.
Stuart
Rosen Mitrev wrote:
Hello! I need to transform a short program from Visual basic to Mathcad. The algorithm is for determination whether point lies inside or outside of polygon. I have written program in Mathcad, but according to the result - incorrectly. Please help.
thanks in advance
Rosen
I haven't checked your program in detail, Rosen, but it seems to work when given a (closed) square to deal with.
I've given an alternative implementation using 'continue' rather than nested if statements. This allows an implementation that is closer to the original. I've also a set of test points that track through the polygon.
Stuart
... forgot to add.
I removed the image of the VBA code to reduce the file size.
I haven't checked it as don't have time ... so, caveat emptor!!
Stuart, thanks again! Except you are Mathcad expert, i saw you achievments in Russian (at russian Mathcad forum),Bulgarian, and Latin languages and I am impressed:)
I think your program will be helpfull for other users, because i didn't find in Internet any algorithm for point in polygon, programmed in Mathcad.
Пожелавам ви приятен празник!
Rosen Mitrev wrote:
Stuart, thanks again! Except you are Mathcad expert, i saw you achievments in Russian (at russian Mathcad forum),Bulgarian, and Latin languages and I am impressed:)
I think your program will be helpfull for other users, because i didn't find in Internet any algorithm for point in polygon, programmed in Mathcad.
Пожелавам ви приятен празник!
Благодаря ви, Розен, nяма защо.
I regret that my Bulgarian is courtesy of Mr Google, my Russian a little less so and my Latin a little less so again (thanks to a British Grammar School education when Latin was mandatory). However, I can order a beer, pick a fight, and tell the waitress how good looking she is in 5 different languages. 🙂
Once Richard pointed out that the original test polygon didn't work with the 'while' loop programme, I instantly saw what the problem was and corrected it - for some reason, the test polygon didn't show on my downloaded sheet, P was just zero. I've attached an updated worksheet with both versions implemented as functions plus a version that iterates over a list of points (nx2 array). I've added a mesh test array to give enhanced testing - should have done it in the first place 😞
However, as a general algorithm, it probably needs some work to check for points that lie on vertices.
Пожелавам ви приятен празник!
И същото и с вас. В момента има хубаво време днес - твърде горещо за мен!
Stuart
-------------------------
I have noted many very similar words in Bulgarian and Russia - I recognized Благодаря straight away.
Stuart_Bruff wrote:
I have noted many very similar words in Bulgarian and Russia - I recognized Благодаря straight away.
Bulgarian and Russian have one root - Old Slavonic language.
Now we use this language in Russian Church. Many people do not understand because of this that the priest is reading in the Russian Orthodox Church.
Stuart, thanks, you have done a lot of work!
Few remarks for languages:)
1.The word "beer" sounds identically in most languages:) But not in Russian - пиво (cheers prof. Ochkov!)
2. In the communications with waitreses Mathcad expertise is useful:)
Ok, now seriously!
I am trying to rotate the cross section (pls. see attached file1) around the zero vertical axis (see attached file2), but i have no sucsess. Please help!
OK, I'll have a look later when I get some time.
Stuart
However, using the orginal polygon yours works, but the original does not.
I've converted the worksheet to Mathcad Prime ...
Whilst Prime appears quite capable (*) and will run the 'in polygon' function, it is an experience I would rather avoid. The primary reason is that Prime is Soooooo Sloooooowwww to edit. Even with nothing else running on my Windows 7, 4 GB PC, it took over an hour to do something that would have taken 10 minutes in M11..M15 (excluding M12 which would probably have required a major rewrite). The lack of a ctl-G to form Greek characters is a big pain.
I have confirmed that I do not like the mandatory if..then nested form - takes up far too much room and makes it harder to read compared to the old single-line form (and I've programmed in assembler, BASIC, Algol, FORTRAN, Pascal, Modula, C, C++, ADA, LISP, Prolog, etc and variants thereof, so I'm quite familiar with the form)
Stuart
Note:
(*) ... given that it's got a lot still to implement, 3D plots being one omission from the conversion and region alignment a significant editing omission. I'm keenly awaiting boxes around plots and text styles.
Hi Stuart,
3D plots are coming in Prime 2.0. We're working on them right now.
Mona