4
$\begingroup$

I've got a function that maps a 2D plane onto a sphere (I'm trying to learn about Geodesics).

f[u_,v_]:={X[u,v],Y[u,v],Z[u,v]};
X[u_,v_]:=Cos[v]Sin[u];
Y[u_,v_]:=Sin[v]Sin[u];
Z[u_,v_]:=Cos[u];

I want to plot this, but the Plot3D gives me only a single value for any given [X,Y] set of coordinates. At the least, I'd like something like a scatter chart (that is, just give it 3 coordinates and have it plot a point), but it would be nice to be able to generate a wire-frame so I could draw my solutions.

$\endgroup$
7
$\begingroup$
Clear["Global`*"]

f[u_, v_] := {X[u, v], Y[u, v], Z[u, v]};
X[u_, v_] := Cos[v] Sin[u];
Y[u_, v_] := Sin[v] Sin[u];
Z[u_, v_] := Cos[u];

SeedRandom[1234]

data = f @@@ RandomReal[{0, 2 Pi}, {5000, 2}];

Graphics3D[Point[data]]

enter image description here

However, you can get a smoother distribution with RandomPoint on a Sphere

SeedRandom[1234]

data2 = RandomPoint[Sphere[{0, 0, 0}], 5000];

Graphics3D[Point[data2]]

enter image description here

EDIT: Converting the points into a 3-D surface

ListSurfacePlot3D[data2, Axes -> False]

enter image description here

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Your first approach is not correct. Pay your attention that the points flock near the poles. $\endgroup$ – user64494 Dec 17 '19 at 8:01
  • 1
    $\begingroup$ @user64494 it's not incorrect — it's just a different distribution. $\endgroup$ – Ruslan Dec 17 '19 at 10:39
  • $\begingroup$ Great answer. Thank you. For extra points, can you make that into a wire-frame? $\endgroup$ – Quarkly Dec 17 '19 at 15:22
  • $\begingroup$ @Ruslan: Exactly saying, the points produced by the first code are not uniformly distributed on the sphere so these can't be called random points on the sphere. $\endgroup$ – user64494 Dec 18 '19 at 8:15
  • $\begingroup$ @user64494 random doesn't imply uniform. $\endgroup$ – Ruslan Dec 18 '19 at 8:16
0
$\begingroup$

Thanks to Bob Hanlon for his answer. Using that as a starting point, I was able to work out this, which is what I was really after:

ParametricPlot3D[{R[u, v]}, {u, 0, Pi}, {v, 0, 2*Pi}]

enter image description here

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.