perp-perp distance analysis

Next
 From:  BurrMan
4547.1 
Hi Michael,
I was speaking with a guy in another forum regarding solving a proplem for him. I was wondering if a script in MoI could perform this function.

He's looking for the largest gap between 2 defined curves.. Lineweb can iterate out a line between the 2 curves, but can it determine which will be the longest and place only that one??



Basically, some type of perp-perp analysis, with points or a line placed at the largest gap... He is looking for an iteration tolerance of .001.

Thanks.

EDITED: 19 Jun 2012 by BURRMAN

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4547.2 In reply to 4547.1 
Hi Burr, that kind of requires a level of processing that's beyond what a script is good at doing.

It's something that is possible to add in the future but the function for it would really need to be added as some core c++ code, it's not really suited for fully implementing the entire process in script.

But Rhino has a CrvDeviation command that sounds like it will do what he wants here, I think even the trial version of Rhino would work fine for that particular purpose. If you set the "keep marks" option in Rhino it will generate points and a line at the min and max deviation spots and you can select a point and use the "what" command to get its x,y,z coordinate, so you don't really even need to use up a save for getting that particular information.

Doing that should get the job done right now I would think.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
4547.3 In reply to 4547.2 
Hi Michael,
Thanks for the help there... I'll tell him. I have told him about MoI too.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
4547.4 
Seems if you export segments in skp Format, Free Google Sketchup must have a ruby script who calculate smaller or bigger segment of a selection ;)
I will see that :)
If not yet exist I will ask some coder and you will have the script in an half day I presume ;)
maybe 10 minutes :)

EDITED: 24 Sep 2011 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4547.5 In reply to 4547.4 
Hi Pilou - the problem is that SKP format cannot hold true curves, it can only hold polylines.

So part of the process of getting it into SketchUp to run the Ruby script in there on it will involve a conversion to polylines which is a pretty big degradation of the curve accuracy.

With that method it will probably be difficult to guarantee a tolerance of 0.001 units as was requested.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
4547.6 In reply to 4547.5 
:) I have speed reading and believe that the problem was only know the samllest or bgigest segment :)
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
4547.7 In reply to 4547.3 
Hi Micahel,
Sorry to bother you about this again. I was trying to wrap my head around it and got stuck. Here is a picture of 2 curves. The idea would be I need to drop the pink curve down in the Y direction (black arrow) only enough to completely pass the wavy curve at all points, and no more.



The red line is the result of rhinos CrvDeviation command and is the largest space.

Can I move this pink line down by knowing the value of the red line? I thought I stumbled onto Danny's Bisector line as an idea to get a perp verticle line to use as a guide, but it was a little off too..

It alsmost seems like I need to do a "Y only" raster of the CrvDeviation command to get the result I need? (The angle of the red line thows off my planar Y move)

Thanks for any help...

EDITED: 19 Jun 2012 by BURRMAN

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
4547.8 In reply to 4547.7 
Curves are coplanar?
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4547.9 In reply to 4547.7 
Hi Burr, I'm not quite following why you are talking about the Y direction there - the closest and furthest points between 2 curves can be in any direction, not just in the Y direction.

Once you have found a maxima or minima, you can't just take one base point of it and then go in some completely other direction to still maintain the max/min property of it...

Are you trying to find some more constrained type distance than you mentioned originally? If so then you may be looking for a kind of "collision detection" mechanism and not actually a "closest point between curves" type operation.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4547.10 In reply to 4547.7 
Hi Burr - basically if you want to find the shortest distance that you can move the curve in one specific direction until it first touches another one, that is a totally different problem than finding closest or furthest points along shared perpendicular lines.

For something like that instead of finding the shared perp/perp lines it would instead involve shooting a ray out along that move direction on every point from the base curve and then intersecting that ray with the target object and finding which spot has the smallest distance between the start of the ray and the intersection point.

That's a different problem than what CrvDeviation in Rhino is doing - CrvDeviation in Rhino will find the shortest and furthest global distances between the 2 curves (which will include perp/perp lines).

For a directed one I'm not sure where you would find that already done - maybe as a collision detection mechanism in some physics simulation stuff...

But a direction constrained one doesn't really have anything to do with perp/perp lines like you were originally asking about here.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
4547.11 In reply to 4547.10 
Hi Michael,
Sorry, I can be confusing... I made a short visual to try and be clear about what I am asking... I also think I determined what I needed originally, and perhaps a script could still work?

Basically I need a "longest line" highlighted.. So in the video, I created an array of 30 lines to measure a small area by trimming the lines and manually measuring them... If I wanted to do the whole curve at a more finite resolution, I may be talking about a couple hundred or more curves...

If I manually did the array and trim, could a script pick out and highlight the longest one (Or 2 or 3 if they were equal) Possibly discarding all others? I think this would get whats needed...

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
4547.12 
here in Sketchup gives the biggest segment from a selection of segments

This one-liner copy+paste + <enter> in the Ruby Console highlights the longest segment in the selection and prints its length/id

By TIG

d=0;s=Sketchup.active_model.selection;a=s.to_a;q=nil;a.each{|e|(q=e;d=e.length) if e.class==Sketchup::Edge and e.length>d};s.clear;s.add(q);puts d;q

About the problem : generally perspective has a cone or a rectangle of visibility
Here your curves are coplanar at the place where you want find the biggest segment ?

EDITED: 25 Sep 2011 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4547.13 In reply to 4547.11 
Hi Burr, thanks for the video description that helps clear it up.

So yeah you don't want any "perp/perp" type of thing for your case, so that CrvDeviation tool in Rhino will not work for this case.

Doing a set of y-axis aligned lines like you showed there will work but the accuracy will be limited to whatever density of lines you used. But you can probably do a pretty large number of them just in the general area where you know the spot is at.

Then doing a script that just selects the longest curve from all existing ones in the model is definitely possible without much fuss - here's one that you can set up on a shortcut key:

script: /* select longest curve */ var curves = moi.geometryDatabase.getObjects().getCurves(); var maxlen = -1; var maxcrv = null; for ( var i = 0; i < curves.length; ++i ) { var crv = curves.item(i); if ( crv.hidden || crv.locked ) { continue; } var thislen = crv.getLength(); if ( thislen> maxlen ) { maxlen = thislen; maxcrv = crv; } } if ( maxcrv != null ) maxcrv.selected = true;

That will look through all curves that are not hidden or locked, it does not only look at lines, so if you have some curves that you don't want to have considered (like the original ones that you are measuring between) lock or hide those before running the script.

Hope that helps!

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
4547.14 
so you have now 2 scripts ;)
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
4547.15 In reply to 4547.14 
Hi Michael,
Thanks for the help.

Frenchy,
Thanks for looking in... Yes the curves are all planar and the sketchup script does the measurment too, 2... :)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
4547.16 
@Michael
Does it possible to have the smallest curve ?
I have made some try without success but a little headache ;)
At first view some inverse sign and other trivial changements but not so easy for me :D

Added the biggest :)
http://moiscript.weebly.com/select-biggest--smallest.html

Ps What happen if there are 2 biggest equal?
Seem the first created is selected :)

Pss And it's a curious workflow : nothing must be selected before lauch the script!
I have make many try before find it by hasard :D

EDITED: 26 Sep 2011 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
4547.17 In reply to 4547.16 
Hi Pilou,

> Does it possible to have the smallest curve ?

Yup, this script will select the smallest curve instead:

script: /* select shortest curve */ var curves = moi.geometryDatabase.getObjects().getCurves(); var minlen = 1e100; var mincrv = null; for ( var i = 0; i < curves.length; ++i ) { var crv = curves.item(i); if ( crv.hidden || crv.locked ) { continue; } var thislen = crv.getLength(); if ( thislen < minlen ) { minlen = thislen; mincrv = crv; } } if ( mincrv != null ) mincrv.selected = true;


> Ps What happen if there are 2 biggest equal?
> Seem the first created is selected :)

Yup, that's correct.


> Pss And it's a curious workflow : nothing must be selected
> before lauch the script!

Yup, it adds the shortest or longest one to the selection without disturbing other already selected objects. That allows for more flexibility - for example if you want to select both the shortest and the longest curve you can start with nothing selected and then run both of those scripts and you'll then have that selection at the end. If each script cleared the selection first then it wouldn't be possible to do that anymore.

But if you do want everything else to be deselected, it's possible to do that by adding a call to moi.geometryDatabase.deselectAll(); at the start of the scripts.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
4547.18 In reply to 4547.17 
Well well all is clear now!
So 2 more little scripts who can be useful for tricky things!

var minlen = 1e100; that was this that I have missed !
Near the infinite of the number of stars ;)
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Frenchy Pilou (PILOU)
4547.19 
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All