N=500;r = 6;center = [2,1,3];plot3(center(1),center(2),center(3),'ro')hold onfor i=1:N x1 = rand; x2 = rand; Px = sqrt(x1*(2-x1))*cos(2*pi*x2)+ center(1); Py = sqrt(x1*(2-x1))*sin(2*pi*x2)+ center(2); Pz = 1-x1 + center(3); plot3(Px, Py, Pz,'o'),hold onend p = [Px, Py, Pz]; dist = Ddist(center,p);
What am I missing here? I'm using the dist variable to be sure I'll get 6, but currently I get 1
Best Answer