Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hi @Werner_E
Do you mind showing me how to change this program for the min distance to find the distance between the red point and all the green points come before it regardless the min distance
like ...In the previous topic we found the nearest to the red point ...I need now to change it to find the distance between the red points ana all the greens come before it and the calculation of the distance should be separet for each red point ..that means if we consider to the third red point the target greens will be the ones between the second and the third points only without involving the previous segments
Thanks in advance
Solved! Go to Solution.
I agree with Martin that for every new question you should provide the Prime sheet and also the necessary data file so that all members of the community have the opportunity to take part. The smaller and simplified the sheet, the better!
Furthermore you can't expect us to keep track which file was posted by whom in the past and keep all the files. Being lazy by nature I don't delete the files as regular as I maybe should and so your new files worked even though you did not provide the necessary Excel sheet. But the missing sheet sure would have hindered other members to try to help.
Concerning your new question I don't think that i can help. The function "connect2" you reference is a function which creates the data structure necessary to plot the line segments from every green point to the red LINE nearest to it - that way visually showing hat minimal distance.
The function is called "connect2" because it followed "connect", which would do similar but by connecting each green point and the nearest red point.
I don't see how your new question would relate to that function. Actually I don't understand what that question would be all about.
What should "find the distance between the red point and all the green points come before it regardless the min distance" mean?
How would "before" be defined?
As far we cycled through all green points to find the red line closest to it. Not you want to cycle through the few red points(!?) and find ... what?
Again, as you reference the function "connect2", I have no clue to what you may need.
In case you just want to create a list of all green points within a certain section, we could add the information, if the point is left or right of the red marker line
and use this information to select all points within a section
Example:
In the attached P10 file I got rid of all regions not relevant to the question. If you can reduce the sheet further, please do so before you re-up it again. Smaller sheets make life a lot easier!
Hi,
if you are asking for a help, please upload your mcdx file.
I agree with Martin that for every new question you should provide the Prime sheet and also the necessary data file so that all members of the community have the opportunity to take part. The smaller and simplified the sheet, the better!
Furthermore you can't expect us to keep track which file was posted by whom in the past and keep all the files. Being lazy by nature I don't delete the files as regular as I maybe should and so your new files worked even though you did not provide the necessary Excel sheet. But the missing sheet sure would have hindered other members to try to help.
Concerning your new question I don't think that i can help. The function "connect2" you reference is a function which creates the data structure necessary to plot the line segments from every green point to the red LINE nearest to it - that way visually showing hat minimal distance.
The function is called "connect2" because it followed "connect", which would do similar but by connecting each green point and the nearest red point.
I don't see how your new question would relate to that function. Actually I don't understand what that question would be all about.
What should "find the distance between the red point and all the green points come before it regardless the min distance" mean?
How would "before" be defined?
As far we cycled through all green points to find the red line closest to it. Not you want to cycle through the few red points(!?) and find ... what?
Again, as you reference the function "connect2", I have no clue to what you may need.
In case you just want to create a list of all green points within a certain section, we could add the information, if the point is left or right of the red marker line
and use this information to select all points within a section
Example:
In the attached P10 file I got rid of all regions not relevant to the question. If you can reduce the sheet further, please do so before you re-up it again. Smaller sheets make life a lot easier!
Hi Werner,
Actually I tried to write this program depending on your previous solution>> to find the distance between markers and the previous green points
when I say before I mean example : distance between marker 2 all greens(cpt) (which located in between marker 1 and marker 2 )
dist3 will be ( marker3 and all greens located in marker 2 and 3)
Do you think what I wrote is correct? >>> I'm asking because I honestly don't know why I used (seg) I just follow your steps
also tried this one:
Thank you for your above answer >> that was my next step >> you are always awesome ..and it wasn't me who posted as a new question ..
I read the file and it is beyoned expectations ... this is incredibly genius .. thank you soooooooooooooo much
If I understand you correctly you already got what you have looked for?
So you don't really need the distances you write about but just wanted to be able to select all greens in-between two markers?
Note that in the approach above I simply added the information in the data structure created by "nearestPoint2" if a point is to the left or to the right of its closest marker.
So if a point is between marker 2 and marker 3 it can be closest to marker 2 but because its left/right column says "L" I know that its between marker 2 and 3 and not between marker 1 and 2, But the distance in the mindist column still will be the distance to its closest marker which is marker 2 and the segment marker in the "seg" column still will say 2. If you rather need the distance to marker 3 (the next marker, not the closest one) in this case, the function "nearestPoint2" would have to be modified accordingly.
One way would be
The NaN's are returned if there is no "next" red marker line. This is the case for the points a the left of the road.
Maybe the first in that series on NaN's ("seg" column) would better be replaced by the maximum marker number +1. This would make selecting them later easier.
So , the last one you sent will get the distance between all the greens in region ( between marker 2 and marker 3) to marker 3 only regardless the nearest marker >> if so, this is exactly what I'm looking for.
One more question >> how do you know that mathcad is not also calculating the distance before marker 2.. what is the expression?
thanks in advance
@YA_10963798 wrote:
So , the last one you sent will get the distance between all the greens in region ( between marker 2 and marker 3) to marker 3 only regardless the nearest marker >> if so, this is exactly what I'm looking for.
One more question >> how do you know that mathcad is not also calculating the distance before marker 2.. what is the expression?
thanks in advance
The function dist2 returns an oriented distance, this means that the sign indicates on which side of the line the point lies.
In my first version I just used the absolute value of dist2 because we were looking for the nearest red line, regardless if it is to the left or to the right of the point. In the new version, only values with a certain sign are considered.
There was an error in the function I posted before as it should read dist>=0 and not dist<=0 if we only want to consider red lines to the left of the green point.
That way the numbering of the segments now start with 1 (and not with 0 as before) and end with 17.
Segment 17 indicating points to the left of the last 16th marker - of course no distance is returned but rather a NaN for these points.
The slider to select the points in a certain segment at the end of the sheet was also modified. Formerly it ran from 0 to 16 whereas now it runs from 1 to 17.
Segment 9 now means the segment between marker #8 and marker #9.
Segment 1 are all points to the right of marker #1 and segment 17 all points to the left of marker #16.
Attention: I did not use input values and scripting when implementing the slider. It was a quick hack and the values 1 to 17 are just "hard coded" by editing the Properties of this component. If necessary it would be possible to make the limits (especially the upper one) dynamically changing according to the number of markers provided.
Prime 10 sheet attached
Ahh >> Now I got it ... Thank you so much for such thorough explanation