Generating points on flattened sphere
1 view (last 30 days)
Show older comments
hi i am new in matlab I have a flattened sphere x1^2+0.01*x2^2+x3^2=1; I have code but it does not give exact results.
function A = rand_pick_sphere(n,a,b,X,Y,Z)
% Uniform points in a shell of inner radius a, outer radius b and center at
% (X,Y,Z)
% [x,y,z] = rand_pick_sphere(300,.5,.6); % 300 points in shell between
% r = .5 and r = .6, with center at origin.
if nargin==3
X = 0;
Y = 0;
Z = 0;
end
r1 = (rand(n,1)*(b^3-a^3)+a^3).^(1/3);
phi1 = acos(-1 + 2*rand(n,1));
th1 = 2*pi*rand(n,1);
% Convert to cart.
x = r1.*sin(phi1).*sin(th1) + X
y = r1.*sin(phi1).*cos(th1) + Y
z = r1.*cos(phi1) + Z
A=[x y z];
how can generates points that lies on this sphere plz help me
1 Comment
John D'Errico
on 28 Aug 2016
Why do you think the code that you have is inadequate? Where is the problem?
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots 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!