How to produce equally distant samples in Matlab?
Show older comments
I am interested to produce equally distant samples inside a closed n-dim space whereas each generated point has the same distance to its neighboring points. Is there any matlab function or method to do this?
Let's say we have a vector in 2D system with known coordination for the tip and tail of that vector. How to find equally distant samples over this vector? Let's assume we have a regular triangle shape and the coordination of the edges in the 3-dim Cartesian system is known. How to find equally distant samples in this shape? Last, what if the shape is not regular and has curvature arms (curves connecting the edges). Assume there are some known points (coordination) on the arms. How to find equally distant samples in this shape. For first figure:
p1=[1,3];
p2=[5,4];
for triangle shape:
p1=[1,3,0];
p2=[5,4,1];
p3=[-1,2,4];
for the last shape, there are just some known points on the arms (red curves).

25 Comments
John D'Errico
on 2 Sep 2017
Edited: John D'Errico
on 2 Sep 2017
Jamais said:
"I want the equally distant points to be generated IN the shape and also on it's boundary.
For the first two figures, they lie on a plane, but for the 3rd one, it doesn't lie on a plane."
Johns response: For the non-convex, non-planar general case, Have fun. It is not gonna happen without a hell of a lot of work at defining EXACTLY what it means to be "inside" that region. (Why I deleted my answer.) Don't expect to be successful at the task.
Jamais avenir
on 2 Sep 2017
Jamais avenir
on 2 Sep 2017
Edited: Jamais avenir
on 2 Sep 2017
Walter Roberson
on 2 Sep 2017
What are they equally distant from ?
Your description so far implies that you should be creating a single arc of a circle relative to something, since a circle is the set of points that are equally distant from some origin (at least if you are working in Euclidean space.)
Jamais avenir
on 2 Sep 2017
Edited: Walter Roberson
on 2 Sep 2017
Walter Roberson
on 2 Sep 2017
In N dimensions, at most (N+1) points can be equally distant from each other, vertices of a hyper-pyramid.
Jamais avenir
on 3 Sep 2017
Edited: Jamais avenir
on 3 Sep 2017
John D'Errico
on 3 Sep 2017
Let me explain. You want code to generate what is essentially optimal circle or sphere packing, inside and on the boundary of a completely general non-convex object, defined only by a set of arbitrary points along a simple curved path in 2 or 3 dimensions.
Of course, since you have not yet decided how to define what are the boundaries of that complicated curved object, the task you ask to solve will be rather difficult, the subject of a doctoral thesis even if someone were able to show you how to do it.
Even if you were willing to accept a maximal circle/sphere packing inside (and on the surface of) the convex hull of your object, that alone is a quite difficult problem, and it surely would not be acceptable, since those curved lines will not lie inside the convex hull.
It is easy to say, I want to do this (...) on a computer. Before you find a computational algorithm to solve a problem, you need to decide what is the problem. You have not even done that yet. What is the object described by that rather complex 3-d region defined by that curved path in your third picture? Start there.
Jamais avenir
on 3 Sep 2017
Edited: Jamais avenir
on 3 Sep 2017
Image Analyst
on 3 Sep 2017
If it's not lying in a plane, then it's not a photo. What generated this 3-D image? A profilometer? Computer graphics? If it's computer graphics (a simulation) then you know the boundaries and so you'll know all locations along the edge of the leaf. If it's from a profilometer or some kind of 3-D white light scanning system, then why don't you just find all the edges? Why do you want/need only some of them?
Jamais avenir
on 3 Sep 2017
Image Analyst
on 3 Sep 2017
Why don't you have them already? You should have a voxel at every point already. Why do you have them only at certain widely-spaced locations?
Walter Roberson
on 3 Sep 2017
You want a triangular mapping along the surface of an arbitrary 3D curve. It is not possible to do that without distortion.
See in particular http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/foldout.html, but add the additional restriction that you permit the vertices to be only where the equivalent of "land" is.
Your situation is even more complicated than a regular surface such as a sphere. Those pages discussion projection techniques and what they preserve or not (and why so), which might allow you to choose a trade-off that is acceptable to you.
Jamais avenir
on 3 Sep 2017
Jamais avenir
on 3 Sep 2017
Image Analyst
on 3 Sep 2017
Instead of coordination, I think/hope you mean coordinates. Otherwise I have no idea what you have. Assuming you have only a few points along a boundary, you can't "fill in" other points unless you make some assumptions. For example let's say you have a salad bowl and only the coordinates of 12 points along the upper rim. There is no way to get the points on the surface of the bowl below the rim (i.e. "interior" to the rim points) unless you make some assumptions that the shape will be a concave bowl shape. Otherwise you'd simply get a flat disk, not dipping into the bowl. Does that make sense?
Jamais avenir
on 3 Sep 2017
Image Analyst
on 3 Sep 2017
Why not use John D'Errico's polyfitn? You can fit a plane between the points so now you have a z value for every (x,y) location. If you want just some of them, rather than each and every pixel, you can either subsample the whole plane or use randi() to randomly pick locations.
Jamais avenir
on 3 Sep 2017
Edited: Jamais avenir
on 3 Sep 2017
Image Analyst
on 3 Sep 2017
No, it takes points anywhere in space and builds a model. Then you can use that model to get estimated values at any other locations that you want. I attach a background correction demo where I used it.
Jamais avenir
on 3 Sep 2017
Image Analyst
on 4 Sep 2017
Maybe, if I have time and you post a set of coordinates.
Jamais avenir
on 4 Sep 2017
Edited: Jamais avenir
on 4 Sep 2017
Walter Roberson
on 4 Sep 2017
You cannot get a spatially-curved 3D figure from those points.
In your post https://www.mathworks.com/matlabcentral/answers/354968-how-to-produce-equally-distant-samples-in-matlab#comment_481591 you showed a diagram with a leaf, and that leaf appears to have a shadow. Are leaf and shadow images available? If so then it might be possible to deduce some 3D information (not easily though.)
Jamais avenir
on 4 Sep 2017
Edited: Jamais avenir
on 4 Sep 2017
Answers (1)
Image Analyst
on 2 Sep 2017
0 votes
I don't see how having curved "arms" makes any difference if you're just interested in finding the point in the middle between three specified points.
Anyway, you can write those points to an image and use bwdist() to compute the Euclidean Distance Transform. You may need to use poly2mask() if you have a solid shape with "arms".
Attach input data and desired result if you want more help.
3 Comments
Jamais avenir
on 2 Sep 2017
Image Analyst
on 3 Sep 2017
In your diagram, a point at the center of the hexagon is equidistant from only 6 other points and has different distances to all the other points.
Assuming that's what you want, you can generate such a hexagonal grid by simply making two simple rectangular grids and combining them, with one offset from the other by half a box.
Jamais avenir
on 3 Sep 2017
Categories
Find more on Agriculture in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
