how can I determine the density in each quadrant or small region of randomly uniformly deployed points in a 3D plot
Show older comments
I have a 3D plot of random and uniformly distributed points. how could i determine the density in each quardrant/sector or subdivided area.
18 Comments
Dana
on 4 Sep 2020
You say you have a 3-D plot. Does that mean the data itself is 3-D, or that the data is 2-D and you've plotted it as a 3-D histogram or something?
Also, how exactly are you defining "density" here? Probability density? Number of points/volume? Something else
Tamoor Shafique
on 4 Sep 2020
Dana
on 4 Sep 2020
I'm a little confused. It looks like you've already computed the desired density. So what is it exactly you don't know how to do?
Also, "spherical distance" usually refers to the distance between two points on the surface of a sphere, where "distance" refers to the length of the shortest path on the surface of the sphere between those two points. Is that what you're after here? If so, I'm not seeing what the sphere in question is.
"I need to calculate the spherical distance between the points in each small cube"
This is very different from the question you're asking initially so I'm not sure if my answer (which addresses your initial question) is helpful. Which question are you asking?
Tamoor Shafique
on 4 Sep 2020
A few comments,
"the points on the 3D plot are spheres"
Not sure what that means. Each point represents a sphere? All points within each sub-cube is the surface of a sphere or is within a sphere?
"since the points are plotted in 3D plot there distance will be calculated in 3D from other points"
Tamoor Shafique
on 4 Sep 2020
Ahh, I see.
Your densities in "n" are correct so my answer no long addresses your updated question. I'll likely remove that answer.
To compute the distances between points use D = pdist(xyz), although if the number of points grow too large, you might reach memory capacity with that fuction (ie, Matlab crash).
For example, the distance between every pair of point in xyz is
D = squareform(pdist(xyz));
where D(i,j) is the distance between points xyz(i,:) and xyz(j,:). If you want to compute the distance between the sphere surfaces, as Dana mentioned, you would just subtract the two radii
surfDist = D(i,j) - radii(i) - radii(j);
where radii is a vector of radii for each sphere.
It's still unclear to me exactly what you want the final output to be. Pick two points from xyz that are in the same cube. Let's call them a and b. Should I think about those points as each being the center of a sphere of radius r? If so, do you want compute the distance between the centers of the spheres, or between their surfaces? If it's the former, you simply want norm(a-b). If it's the latter, you can simply do max(norm(a-b)-2*r,0), where a result of 0 here indicates that the spheres overlap each other. Is this what you're after?
Adam Danz
on 4 Sep 2020
Bruno Luong
on 4 Sep 2020
@Adam I originally suggest Tamoor to open the specific thread on pairwise distances because the density calculation is independent.
Adam Danz
on 4 Sep 2020
Thanks for letting us know. That must have been offline or within a different thread because I didn't see that suggestion.
Bruno Luong
on 4 Sep 2020
Here we go, for the record. It seems in Tamoor's mind the density and pairwise distance represent the exactly same thing. Which I honestly can only vaguely see.
Adam Danz
on 4 Sep 2020
There are too many threads on this topic for me to easily follow. For example, in one of the threads we are trying to figure out what "spherical distance" is supposed to mean - it seems like OP wants euclidean distance. Then I see the "spherical distance" pop up in a different thread. I need a cork board, push pins, and some yarn to follow all of this 😄. I'll still follow the threads in case I can contribute in some way but the problem lacks clarity and is very dispersed at this point.
Tamoor Shafique
on 4 Sep 2020
Bruno Luong
on 4 Sep 2020
Edited: Bruno Luong
on 4 Sep 2020
"I am not sure what do you mean by pairwise distance"
Density of a random distribution is this
Eucidian distance is the pythagore formula, the distance for flat geometry space sqrt(dx^2+dy^2+dz^2)
Spherical distance is this
If you want to communicate well, youhave to use accurate vocabulary.
"But I think it was difficult to explain the idea here"
We all see it.
Tamoor Shafique
on 6 Sep 2020
Walter Roberson
on 6 Sep 2020
so how can i determine linear distances of each point from others in each sub cube
Separate the points according to sub-cube, and pdist() them. If you have a subcube number already for each coordinate, then you can use
splitapply(@(points) {pdist(points)}, list_of_coordinates, subcube_number_for_each_coordinate)
Answers (0)
Categories
Find more on WSNs 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!