Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi there,
How can I draw the lines with specific points... in pervious thread we draw them each 200 m >>> Can it be drawn in specific distance using these values ( using the metreage values)
I tried to change the markers
and then I need to find the distance between these new lines and all the (Se-CPTs) points . the distance between the green point and the nearest metreage line
And then showing them in a plot .
BTW>> I start using mathcad prime 10
Everytime I struggle in mathcad I say I will do it myself , but it is new concept eachtime and I can't reach what I need without your help. Thanks in advance.
Yusra
Solved! Go to Solution.
@YA_10963798 wrote:
Ok... I think the best is to find distance from P to point #2
NO!!!! You don't mean the distance to POINT #2 !!! You sure are talking of the distance to the LINE through point #2.
There is a huge different if you say point or line!
What would be perpendicular to the road when the road is just a number of line segments. The definition of the direction I meant was how you would define perpendicular in that case.
Look again to the sketch with the five points. Would you really say that the red lines are perpendicular to the blue street?
They are just perpendicular to one of the line segments joining. They could as well be perpendicular to the other one or we choose a direction in between. There are many ways we could define the direction of the road "normal".
If it doesn't matter because the points forming the road are very close to each other and the road does not show a large curvature, then we could stay with my approach.
My new approach which is attached here uses interpolation to determine more precise the point with the given meterage. So most of the times none of these "red" points will be exactly one of the given "blue" A-points but rather would the red point lie in between two blue points. And so i define the normal to be normal to the line segment the point lies on.
The attached file contains both ways to define the distance and also provides means to plot the difference line segment. But even if you zoom in it looks confusing because there are way too much "green" CPT points too close together:
Before you use/send this file again you sure should clean it up, deleting all unnecessary or duplicate calculations and plots. When I played around with it it got slower and slower up to the moment when Prime would not react at all and I had to forcefully close the program via task manager.
Attached file is in P10 format
Its never a good idea to change the rule in midst of a game!
That said, the attached is just a quick hack to modify the already existing function makeMarkers to plot markers a positions provided by a vector.
Maybe you can use and modify it to your needs.
But your vector Meterage contains values which are far too large!! The whole length of the object is just 7500. So values like 22000 would have which meaning??
According your question of finding the distance between a point and a line (I don't think you really mean that as that would be basic maths) I have no idea what you actually are looking for and I must confess that your file with all the remainments of previous questions id far to confusing for me to be able to further invastigate.
Hi Werner,
I hope you are doing well. Thank you for answering my question,
Actually I collect all the answers I get from you in a file and the ones I get from Stuart in another file then I use them in my orginal file.
For the meterage it is too easy to implement it in AutoCAd ... I think depending on your last file I can manage to add them. Sorry I provided the points of meterage not the distances I changed them as below
What I meant by the distance between the line and The selected CPTs ... Can you see these green points ...I want to find the distance between them and the nearst red line you draw
Sorry again when I work with more than one program I mix between them and provide wrong data
thanks in advance
Yusra
Are you really talking about the distance from a point to the (theoretically) infinite line! Not to point on the blue street/river/orwhatever for which the the line is just a marker?
After all m red lines may look like the are perpendicular to the blue line, but actually thats just a crude approximation as a right angle never was demanded (you were initially talking just about 'vertical' lines).
Actually my red lines are perpendicular to the previous line segment.
Look at the sketch below.
The point P has the shortest distance to the red marker line associated to point #2, the point of the blue line closest to it it point #4.
So what kind of distance is the one you are talking about?
Do you mean something like this, Yusra?
Stuart
Hi Stuart,
happy to hear from you. what I meant is like in the photo below >>> do you see the black distance this is what I meant ..
we in civil engineering lebal the red lines as meterages which are used to divide the roads to segments and near each segment we take many tests( the green points) so then we group all the tests and name them by the name of the red lines
The end results will be like this:
In this answer to Stuart you show the distance of the green points to the red LINES but in the answer to me your wrote "What I’m looking for is the distance between the test(CPTs green points) and the points where we divided the road ( the red lines)"
This was exactly the reason why I posted the sketch which, as I hoped, clearly sowed that it may be a big difference if you the the distance of the green point to the red marker lines or to the associated points on the road.
Please specify this clearly and unambiguously!
Additional to my questions in my previous answer you have to specify what should be used if the distance of a green point to two or more red lines/points is equal and that's the minimal distance.
I was writing the answers while you post this ..
ok
"What I’m looking for is the distance between the test(CPTs green points) and the points where we divided the road ( the red lines)">>> Yes this is it ..I ..the distance should be between the red line and the green point
I think the issue is we are thinking in two different ways
You think of the distance as in the yellow ... but I need the distance like the black
because the yellow drawn distance is bigger than the black one >>>
The length of red line is not important we can make it longer till the last green point because all the points in the red line are in the same coordinate
I hope you get the idea
If the distance is equal can we show them both ?
I may get the idea but it still need clarification as to what exactly to measure as being the "distance".
Just look again at the sketch I posted here: https://community.ptc.com/t5/Mathcad/Finding-the-distance-between-a-line-and-point/m-p/982621/highlight/true#M214919
You really mean that the green point P should be associated to point #2 because its normal(!) distance from the red line through point #2 is minimal. And this even though P is much farther away from point #2 as from point #4 ???
Sure your green points are close to to road than my point P in this example, but we need a general rule/algorithm which is valid for any point.
If you are really talking about the distance of the points from the red lines you would first have to clearly specify what the exact position/direction of that line should be. What I did was just a coarse guess.
And when you provide a drawing and you show what you call the distance of a point to a line you should take care that the distance line you draw should at least be approximately perpendicular to the line as otherwise its very confusing and unclear to find out what exactly you need.
Ok... I think the best is to find distance from P to point #2
hat the exact position/direction of that line should be.: the exact position can be taken from the meters ... the direction ( do you mean drawing from left to right or the opposite >> it doesn't matter ... think of this line as a wall separate two buildings if we start from right to left or the opposite direction , we will get the same result in both cases...
<<you should take care that the distance line you draw should at least be approximately perpendicular to the line >> Yes totally rigth it should be perpendicular.
@YA_10963798 wrote:
Ok... I think the best is to find distance from P to point #2
NO!!!! You don't mean the distance to POINT #2 !!! You sure are talking of the distance to the LINE through point #2.
There is a huge different if you say point or line!
What would be perpendicular to the road when the road is just a number of line segments. The definition of the direction I meant was how you would define perpendicular in that case.
Look again to the sketch with the five points. Would you really say that the red lines are perpendicular to the blue street?
They are just perpendicular to one of the line segments joining. They could as well be perpendicular to the other one or we choose a direction in between. There are many ways we could define the direction of the road "normal".
If it doesn't matter because the points forming the road are very close to each other and the road does not show a large curvature, then we could stay with my approach.
My new approach which is attached here uses interpolation to determine more precise the point with the given meterage. So most of the times none of these "red" points will be exactly one of the given "blue" A-points but rather would the red point lie in between two blue points. And so i define the normal to be normal to the line segment the point lies on.
The attached file contains both ways to define the distance and also provides means to plot the difference line segment. But even if you zoom in it looks confusing because there are way too much "green" CPT points too close together:
Before you use/send this file again you sure should clean it up, deleting all unnecessary or duplicate calculations and plots. When I played around with it it got slower and slower up to the moment when Prime would not react at all and I had to forcefully close the program via task manager.
Attached file is in P10 format
The second approach is nearer to what I have in mind .... I will adjust some things in the calculation and I believe it will be perfect..
Thank you so much for your help....
@YA_10963798 wrote:
The blue points represent the road ( in reality they are from A9 project the longest highway in the Netherlands)The green points represent the (CPTs) the test results on soil next to the road .The markers ( red lines ) are the points that we divided the road from and make segments.What I’m looking for is the distance between the test(CPTs green points) and the points where we divided the road ( the red lines)
SIgh! So we are NOT looking for the "distance between a line and a point" but rather the task is to calculate the distances between ONE green point to all red POINTS and choose the minimum of all. An then do this for all green points which you call CPTs.
So there are a couple of questions open for me,
Input is your Meterage vector of values, the data points which represent the road and the green CPT points coordinates.
What are the variable names of these input data in your sheet?
Is it "Meters", "A" and "Se_CPT" ? Correct?
The task would consist in determining the coordinates of the "red" points ("mpoints" in my sheet so far) based on "Meters" and "A" and then cycle through all the "mpoints" and determine the closest of the red points for each of them.
So for every 'green' point in "mpoints" we could have either a (minimal) distance, the corresponding "red" point or both of them.
So which data structure you need as the output???
As far as I see we have 16 "red" marker points and 1308 green CPT points.
So the output COULD be a 1308 x 6 matrix ????
The columns could be
1&2) coordinates of the green CPT point (basically the "Se_CPT" matrix
3) minimal distance
4&5) coordinates of the corresponding red marker point
6) the Meterage value of that red point
I don't know if you need all that information or if you are looking for a different data structure of the result - you have to specify.
Also I am a bit confused because in your first posting you wrote "And then showing them in a plot ".
Which kind of plot do you have in mind???
As far as I understood you have 1308 green points. Drawing that many line segments which connect the green CPT point with the corresponding nearest red marker point sure would look chaotic and not informative, I guess.
So please specify!
BTW, what I have in mind is to develop a solution from scratch, only using the input matrices A, Se_CPT and Meterage.
Instead of using the cumulative distances of the A points until a value in Meterage is achieved I think of using a function (linear interpolation) representing the road and using integration to get a more precise road length and this may result in red marker points inbetween two given A points.
EDIT: Was a bad idea! Is inaccurate an awfully slow!!
Hi Werner,
Guys I really think you should open a channel in Youtube to teach people MathCad ..the videos in Youtube are not enough especially if a user needs to know all the tricks to achieve certain results ...
Werner the answers of your questions:
1. What are the variable names of these input data in your sheet?
Is it "Meters", "A" and "Se_CPT" ? Yes exactly ... Meters actually represent the distance lines we draw to divide the road. its length is not important but its location on the road what matters the most.
2. So the output COULD be a 1308 x 6 matrix ????>> so far yes ,,, but can we make it fixable because I'm still working on the rest red lines ( where to put them >> we can accept this for the moment and I will change it in the future , because I will add more red lines.
3. I don't know if you need all that information or if you are looking for a different data structure of the result - you have to specify.?
Yes it is good structre I may add only the row of the CPTs in excel
And then showing them in a plot ".>> I wrote this to use it as a proof that there is no smaller distance than the results we get... but if that will look bad so no problem we can ignore it or just show few of them ..
This is exactly what I need:>> your idea is amazing but please don't stress yourself
BTW, what I have in mind is to develop a solution from scratch, only using the input matrices A, Se_CPT and Meterage.
Instead of using the cumulative distances of the A points until a value in Meterage is achieved I think of using a function (linear interpolation) representing the road and using integration to get a more precise road length and this may result in red marker points inbetween two given A points.
Side Note:
Meterage>> is the point coordinat
Meters>> is the distance of this point from the refence
Thanks in advance
Yusra