Message Boards Message Boards

Align / orient a 2D inset within a 3D graphic?

GROUPS:

This is what I have gotten to work:

drawSphereRadius = 1/8;
Graphics3D[
 {
  Inset[Plot[x^2, {x, -1, +1}]],
  Sphere[{0, 0, 0}, drawSphereRadius],
  Sphere[{1, 0, 0}, drawSphereRadius],
  Sphere[{0, 1, 0}, drawSphereRadius]
  }
 ]

But it results in the 2D plot facing the viewer dead on. That isn't where I want the 2D plot; I want:

  • the origin of the parabola coincident with the sphere at the 3D origin;
  • the parabola to lie within the plane containing the three spheres;
  • the line splitting the parabola should contain the spheres at 0,0,0 and 0,1,0.

I have no idea how to translate by verbal description into the correct parameters for Inset[]. I have looked at the Inset-function manual page and the inset tutorial, but still unable to do this. Thank you.

POSTED BY: Joe Donaldson
Answer
15 days ago

This may be a way:

drawSphereRadius = 1/8;
Graphics3D[{Inset[Plot[x^2, {x, -1, +1}], {0, 0, 0}, {0, 0}], 
  Sphere[{0, 0, 0}, drawSphereRadius], 
  Sphere[{1, 0, 0}, drawSphereRadius], 
  Sphere[{0, 1, 0}, drawSphereRadius]}, ViewPoint -> Above]

Otherwise

Show[ParametricPlot3D[{x, x^2, 0}, {x, -1, 1}], 
 Graphics3D[{Sphere[{0, 0, 0}, drawSphereRadius], 
   Sphere[{1, 0, 0}, drawSphereRadius], 
   Sphere[{0, 1, 0}, drawSphereRadius]}], PlotRange -> All]
POSTED BY: Gianluca Gorni
Answer
15 days ago

Thank you. Your second solution returns what I had envisioned, oriented as I had hoped for, while your first solution intrigues me because it exercises the 2nd and 3rd parameters in the function Inset[], and those parameters are confusing me even after I've read the docs. Can you please briefly explain to me how you selected {0, 0, 0}, {0, 0} as your values for those parameters? I'll speculate the {0,0,0} refers to the origin of the 3D system, and {0,0} refers to the origin of the 2D system, which is also the parabola's vertex? And while you specified that those two origins should be coincident, the 2D and 3D axes happened to align in the way I had hoped, even though you specified nothing explicitly about alignment?

POSTED BY: Joe Donaldson
Answer
15 days ago

Yes, you guessed right about the Inset parameters. The remaining two spheres go into place with ViewPoint -> Above. You can still make more fine-tuning of the size parameter of Inset, which is almost but not exactly right already.

POSTED BY: Gianluca Gorni
Answer
15 days ago

Thanks again.

POSTED BY: Joe Donaldson
Answer
15 days ago

Group Abstract Group Abstract