You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
how can I determine the density in each quadrant or small region of randomly uniformly deployed points in a 3D plot
3 views (last 30 days)
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
let's say this is the code
N=1e3; % Number of points
cubesize = 100; % meter
subdivision = 3; % == 27^(1/3)
subcubesize = cubesize/subdivision;
% Generare N points in big cube V :) (0,cubsize)^3
xyz=cubesize*rand(N,3);
% Compute the density of 27 small cubes
ijk = ceil(xyz/subcubesize);
n = accumarray(ijk,1,subdivision*ones(1,3));
density = n/subdivision^3 % #points per m^3 in each of 27 subcubes
close all
scatter3(xyz(:,1),xyz(:,2),xyz(:,3));
hold on
h = slice([0 cubesize],[0 cubesize],[0 cubesize],zeros(2,2,2),...
(0:3)*subcubesize,(0:3)*subcubesize,(0:3)*subcubesize);
set(h,'FaceColor','none')
axis equal
and I need to calculate the spherical distance between the points in each small cube so that i could calculate the redundancy in random distribution and can avoid it.
I hope this makes sense?
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.
Adam Danz
on 4 Sep 2020
Edited: Adam Danz
on 4 Sep 2020
"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
You are right I have got it done partially to calculate the density. However, the part I am struggling in is to calculate the distance between the points. so the points on the 3D plot are spheres and have a circular radius of the sphere=r lets say 1m. since the points are plotted in 3D plot there distance will be calculated in 3D from other points. I am not sure how to do that so each point knows all other points in the 3d sub cube are at what distance from it.
Adam Danz
on 4 Sep 2020
Edited: Adam Danz
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
Each point represents a sphere. I know the code does not reflect this yet but it is a a code under progress. so all the points within each subcube are the surfaces of sphere themselves.
There distances will be linear so the distance of one sphere(point) from all other spheres(points) in the same subcube like an euclidean distance in a 3D plot
Adam Danz
on 4 Sep 2020
Edited: Adam Danz
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.
Dana
on 4 Sep 2020
Edited: Dana
on 4 Sep 2020
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?
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
I am not sure what do you mean by pairwise distance. But I asked this bothways because whether it is density or distance between the nodes it can give me some idea about distribution function which then I can use to calculate the redundant points based on an objective function which i intend to define.
But to define a function about redundant points in a 3D plot i need to determine different information everytime from a random distribution.
So the aim is:
1. Plot n points in a cubical randomly and uniformly with rand. 2. Divide the plot into sub cubes to obtain the distribution information closely in each cube. 3. In each cube obtain information about neigbourhood to each node. 4. Based on the neigbourhood information some points can be declared least important as other points can cover their range/region as well. Some other points can be defined as most important due to their position information.(I was thinking through density and distance information about the points a neigbourhood function can be defined) this is why I asked the kind of an open ended question in several ways so could get solution to current problem in different ways and observe. 5. Since the objective function will declare series of points as most important and some as least important. 6. Use this objective function to show effective cluster head nodes
But I am only asking question on my current level do mot intend you to get full system here.
But I think it was difficult to explain the idea here
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
so how can i determine linear distances of each point from others in each sub cube? would it be an AxB matrics for the distances in each sub cube where A is node number and B be the total number of nodes in that subcube?
I want to do some computation on it but i need to understand how to ontain the data first.
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)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- ä¸å›½
- 日本Japanese (日本語)
- í•œêµKorean (í•œêµì–´)