Author Topic: Minimum rectangle  (Read 5693 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Minimum rectangle
« Reply #15 on: January 17, 2017, 10:09:40 AM »
The speed is just a little faster... I think to gain boost, you should change mr_IsInsidePolygon sub function... I revived an old topic started by ymg ab those sub functions, but as I trust the most to just me I left this sub inside the main code... The issue you describe well20152016, I solved by adding 2 sub functions one main and the other for rotate_ptlst... Still the main trick wasn't in solving that task, but how to incorporate it inside main routine... Where mirror occur you should add (setq pts1 (mirror_ptlst (car pts1) (cadr pts1) pts1)) and when rectangle is found, before ROTATE command for aligning with current UCS, you should get "bp" and "ang" for rotate_ptlst sub applied to mirrored or not pts1... I'll attach both lisps for you to see, but speed gain is just slight if not even slower than with REGIONs... Like I said (mr_IsInsidePolygon) may be the problem with speed...

HTH., M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Minimum rectangle
« Reply #16 on: January 22, 2017, 10:14:00 AM »
well20152016, don't get me wrong, but I hope that you realized that results with multiple polygons nesting aren't 100% reliable...
To explain what I am saying :
Lets say we took selection set of polygons sorted by areas like it is in my posted lisps... Even without transformations like mirror, one resulting outcome of calculation by this array may be more adequate than with included mirroring. What I mean 1-2-3-4-5 polygons are currently calculated so that at each sub step 1-2 minimum enclosing rectangle is searched, then that 12 is meeting 3, so 12-3 is calculated so that 123 minimum enclosing rectangle is searched, but at this point it may sometimes occur that not minimum 123 will produce final 12345 as minimal, but some other branch where 123 is maybe larger than searched 123 by calculations by posted routines... Further more this not logical simptom may occur in every step of rearranging and what's even more frustrating when mirroring is included 12 may be normal, 3 mirrored, and then 123 already complex can be altogether mirrored again... So given all this facts, I think that you see that algorithm should be much more complex and to gain desired result, calculation should be much more time consuming... But that's not all!!! This is how should it be doing with 1-2-3-4-5, but in fact there are combinations of 5 elements multiplied with combinations of 5 mirrored elements and who knows how much combinations of already processed 123 for ex. elements combined of 2 mirrored and 1 not mirrored or 1 mirrored and 2 not mirrored or all 3 mirrored or all 3 not mirrored or middle (2) element mirrored and (13) elements not mirrored and ...
What can we say for sure is that posted routines are correct for 2 polygons - first without mirroring should get you desired result just little larger than second which is taking into consideration and mirroring...
So this versions are just fine for quick packing of multiple polygons into some kind of minimal enclosing rectangle that is composed in straight away lisp simple calculation giving in return result that's quick and satisfactory in optimal time limit...

Conclusion : do not take everything that's close to satisfactory as 100% true... Nesting is complex process and even with preset inputs that are simple like polygons without arcs and desired resulting minimal enclosing rectangle you see the complexity of calculations that are to be processed... So if you plan to utilize and use those posted lisps, I advice you to use it on only 2 polygons as by my testings only then result is reliable...

Of course if you're in hurry and plan to just find what's possible in short time limits with just a few input polygons, then it's your call wheather you'll find it good enough to be claimed as desired resulting outcome...

Regards, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

well20152016

  • Newt
  • Posts: 130
Re: Minimum rectangle
« Reply #17 on: January 22, 2017, 08:18:29 PM »
The best nesting software can't 100%!
Thank you Marko Ribar, I hope all interested people happy!
« Last Edit: January 22, 2017, 08:22:10 PM by well20152016 »

mailmaverick

  • Bull Frog
  • Posts: 494
Re: Minimum rectangle
« Reply #18 on: January 22, 2017, 08:25:20 PM »
Dear Marko,

You have provided two LISPS :- multiplepolygonsnest-fasttest.lsp and multiplepolygonsnest-new-fastest.lsp.
By your post, I assume that first is without mirroring and second is with mirroring.
Please correct me if I am wrong.