0
$\begingroup$

I am using ParametricPlot3D to plot a superellipsoid using the code below:

    Manipulate[ParametricPlot3D[{
        a1 Sign[Cos[eta] Cos[omega]] Abs[Cos[eta]]^e1 Abs[Cos[omega]]^e2,
        a2 Sign[Cos[eta] Sin[omega]] Abs[Cos[eta]]^e1 Abs[Sin[omega]]^e2,
        a3 Sign[Sin[eta]] Abs[Sin[eta]]^e1}, {eta, -Pi/2, Pi/2}, {omega, -Pi, Pi}, Axes -> False, Boxed -> False],
       {a1, 0.1, 2}, {a2, 0.1, 2}, {a3, 0.1, 2}, {e1, 0.1, 1.9}, {e2, 0.1, 1.9}]

However I now need to plot just the (x,y,z) triplets generated using samples of eta, omega in their respective ranges, and given some constant values for the rest of the parameters a1,a2,a3,e1,e2. Unfortunately I only recently started using mathematica and I am unfamiliar with its mechanics. From the docs I could not find an option for ParametricPlot3D to plot just the points.

My goal here is to be able to plot the resulting points, using different distributions of eta, omega. I tried splitting the parametric plot into 3 separate functions:

    X (eta_, omega_, a1_, e1_, e2_) := a1 Sign[Cos[eta] Cos[omega]] Abs[Cos[eta]]^e1 Abs[Cos[omega]]^e2
    Y (eta_, omega_, a2_, e1_, e2_) := a2 Sign[Cos[eta] Sin[omega]] Abs[Cos[eta]]^e1 Abs[Sin[omega]]^e2
    Z (eta_, omega_, a3_, e1_, e2_) := a3 Sign[Sin[eta]] Abs[Sin[eta]]^e1

    eta = Subdivide[-Pi/2, Pi/2, 50]
    omega = Subdivide[-Pi, Pi, 50]

Then I planned use eta, omega as inputs to get the x,y,z outputs. However functions don't seem to take ranges as input, and also I would prefer a solution I can use Manipulate on, to control the values of a1,a2,a3,e1,e2 separately. How should I go about this?

$\endgroup$
3
  • $\begingroup$ X (eta_, omega_, a1_, e1_, e2_) this is not correct syntax - it should be X[eta_, omega_, a1_, e1_, e2_] := ... . You could either generate random numbers, or use a Table for the points as follows ListPointPlot3D[Flatten[Table[..., {eta, -Pi/2, Pi/2, .025}, {omega, -Pi, Pi, .025}],1]] $\endgroup$ – flinty May 30 at 10:23
  • $\begingroup$ @flinty So instead of ... I put my 3 functions X,Y,Z? Will Manipulate with a1,a2,a3,e1,e2 work? $\endgroup$ – VlassisFo May 30 at 10:29
  • $\begingroup$ If you with to plot a set of points in 3D, use ListPointPlot3D. $\endgroup$ – bbgodfrey May 30 at 12:43
0
$\begingroup$

despite is not that clear that do you want to manipulate the Points as Well!!? or only Plot!? or both !?

Here is my answer

x[eta_, omega_, a1_, e1_, e2_] := 
 a1 Sign[Cos[eta] Cos[omega]] Abs[Cos[eta]]^e1 Abs[Cos[omega]]^e2

y[eta_, omega_, a2_, e1_, e2_] := 
 a2 Sign[Cos[eta] Sin[omega]] Abs[Cos[eta]]^e1 Abs[Sin[omega]]^e2

z[eta_, omega_, a3_, e1_, e2_] := a3 Sign[Sin[eta]] Abs[Sin[eta]]^e1


Manipulate[
 Show[
  {
   ListPointPlot3D[
    Table[{x[eta, omega, a1, e1, e2], y[eta, omega, a2, e1, e2], 
      z[eta, omega, a3, e1, e2]}, {eta, -Pi/2, Pi/2, .1}, {omega, -Pi,
       Pi, .1}], PlotStyle -> {Red, Red, Red}],
   
   ParametricPlot3D[{x[eta, omega, a1, e1, e2], 
     y[eta, omega, a2, e1, e2], 
     z[eta, omega, a3, e1, e2]}, {eta, -Pi/2, Pi/2}, {omega, -Pi, Pi},
     PlotStyle -> Directive[Blue, Opacity[0.2]]]
   }
  
  , Mesh -> None, Axes -> False, Boxed -> False, ImageSize -> Large]
 , {a1, 0.1, 2}, {a2, 0.1, 2}, {a3, 0.1, 2}, {e1, 0.1, 1.9}, {e2, 0.1,
   1.9}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks! Sorry if the question was unclear, I only started using it 2 days ago. I have two questions, is there a way to have a slider controlling the amount of eta and omega samples? Also, if I wanted to use a different distribution of eta,omega, can I generate it separately and replace {eta, -Pi/2, Pi/2, .1} ? $\endgroup$ – VlassisFo May 30 at 13:31

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.