how can I determine the density in each quadrant or small region of randomly uniformly deployed points in a 3D plot
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
Dana
2020-9-4
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
2020-9-4
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
2020-9-4
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.
Tamoor Shafique
2020-9-4
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
2020-9-4
编辑:Adam Danz
2020-9-4
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
2020-9-4
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
2020-9-4
编辑:Adam Danz
2020-9-4
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
2020-9-4
编辑:Dana
2020-9-4
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
2020-9-4
@Adam I originally suggest Tamoor to open the specific thread on pairwise distances because the density calculation is independent.
Adam Danz
2020-9-4
Thanks for letting us know. That must have been offline or within a different thread because I didn't see that suggestion.
Bruno Luong
2020-9-4
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
2020-9-4
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
2020-9-4
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
2020-9-4
编辑:Bruno Luong
2020-9-4
"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
2020-9-6
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
2020-9-6
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)
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)