How to fade out the edges of random spheres?

3 ビュー (過去 30 日間)
Seba
Seba 2021 年 1 月 4 日
編集済み: Seba 2021 年 1 月 4 日
I'm using the method described here to generate 3D points that are uniformly distributed on a sphere. I combine several of those together with uniformly distributed scatters to get something like this:
The points are stored in a Nx3 vector. The difference of density in the spheres and outside would be lower later, this is just for better visualisation.
My goal now is to fade out the edges of the spheres a bit, so that there are not so sharp edges but a more smooth transition. How could I achieve this? I was thinking of a gaussian filter but couldn't get the desired result.
As a student I have access to most toolboxes if that's required.

回答 (1 件)

Dave B
Dave B 2021 年 1 月 4 日
Starting in R2020b you can set the alpha independently when using scatter, so I used scatter for a large sphere.
If 2020b isn't an option, you could potentially use color (again, I'd recommend scatter for this) and choose colors near the edges that are closer to white.
rng(0,'twister')
n=10000;
rvals = 2*rand(n,1)-1;
elevation = asin(rvals);
azimuth = 2*pi*rand(n,1);
radii = 3*(rand(n,1).^(1/3));
[x,y,z] = sph2cart(azimuth,elevation,radii);
figure(1);clf
scatter3(x,y,z,10,'o','filled','AlphaData',max(radii)-radii.^2,'MarkerFaceAlpha','flat')
axis equal
  3 件のコメント
Dave B
Dave B 2021 年 1 月 4 日
Ah that makes, sense, you just wanted less points near the outside of the sphere. How about if you just changed the exponent in radii, e.g.
radii = 3*(rand(n,1).^2);
Seba
Seba 2021 年 1 月 4 日
編集済み: Seba 2021 年 1 月 4 日
thank you! I totally didn't think of that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by