Can I create points on polygon with specific distance between them?

Can someone help to make function to create points with specific distanace from each other on a polygon made of points in XY-plane with random distance between them.
for example: if I have the blue polygon made of X and Y point (file attached) as in the pictures1, can I create points (red) in as in picture 2. with distance D between them?
Picture 1
Picture 2

 채택된 답변

Image Analyst
Image Analyst 2019년 2월 16일

3 개 추천

This is what interparc does. See John D'Errico's File Exchange: interparc

댓글 수: 7

seems like a good solution. but this function devides the distance based on the number of points you put .for example if t=100. this meand distance between points= length of polygon/100.
is there anyway i can input D and get number of points according t OK the length of the polygon?
thank you so much
Not sure, but one thing you might try is to use interp1 to interpolate values
xq = x(1) : D : x(end);
xEvenlySpaced = interp(1:length(x), x, xq);
Same for y - you need to do both of them independently.
Of course you realize that there may be a small left over part at the end if the length of the segments or curve is not an integer multiple of D.
Well, for 2D data points (xy) I can use the following trick to solve for specific distance (D).
polyin = polyshape(xy);
P = perimeter(polyin);
t = round(P/D);
I'm just wondering how to get P for 3D data points (xyz)
Any idea???
Thank you so much
As the author of those tools, there is no reason you cannot compute the arclength of the segmented line yourself in advance. Then use that to indicate the set of points to be generated, or just the number of points.
A piecewise linear arclength is trivial to compute, but you can be lazy and just use my arclength tool to compute that length too.
Faez Alkadi
Faez Alkadi 2019년 2월 17일
편집: Faez Alkadi 2019년 2월 17일
John, First of all thank you for making this great stuff!!!
second, I wasn't lazy as you se from my previous comment :)
I just had a problem to find it for 3D data points !!!
again thanks to all of you :)
problem solved !!!
I'll admit to being lazy. :) It saves a lot of time.
well, if you say so ,master :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Kevin Phung
Kevin Phung 2019년 2월 16일
편집: Kevin Phung 2019년 2월 16일
depends if your y values are equally spaced in the first place.
Is this an appropriate workaround?:
% add this to your plot
hold on;
spacing= 10;
plot(xy(1:spacing:end,1),xy(1:spacing:end,2),'ro');
this is spacing the distance between each index used rather than the actual distance

댓글 수: 1

Faez Alkadi
Faez Alkadi 2019년 2월 16일
편집: Faez Alkadi 2019년 2월 16일
What I'm looking for is the actual distance!!!
Thank you though

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

2019년 2월 15일

댓글:

2019년 2월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by