How to fade out the edges of random spheres?

2 Ansichten (letzte 30 Tage)
Seba
Seba am 4 Jan. 2021
Bearbeitet: Seba am 4 Jan. 2021
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.

Antworten (1)

Dave B
Dave B am 4 Jan. 2021
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 Kommentare
Dave B
Dave B am 4 Jan. 2021
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 am 4 Jan. 2021
Bearbeitet: Seba am 4 Jan. 2021
thank you! I totally didn't think of that.

Melden Sie sich an, um zu kommentieren.

Tags

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by