3
$\begingroup$

I was trying to understand how 3D objects work in Mathematica, but I run into a problem I am not able to solve by myself. I have the following 3D plot:

f1=SphericalPlot3D[1 - Sin[t], {t, 0, Pi/2}, {f, 0, 2 Pi}]

figure

What I would like is to change the position and orientation of this object, so that if $\vec a$ and $\vec b$ are any two vectors, I would get something like

figure

Is this possible?

Maybe its even easier than this, becuase what I actually need is to place that figure into another (previously generated) plot, at a specific position specified by $\vec a,\vec b$. I thought I could use Epilog, together with some placing command or something like that, but Im unable to make it work. My intention is to do something like Plot3D[...,Epilog->Placed[f1,{a,b}]] (this is obvioulsy schematic, because the notation makes no sense), but I have no clue as to how to proceed.

Thank you in advance.

$\endgroup$
6
$\begingroup$
f1 =  First @ SphericalPlot3D[1 - Sin[t], {t, 0, Pi/2}, {f, 0, 2 Pi}];

a = {2, 2, 1};
b = {0, 2, 3};

Graphics3D[{
  Thick, Arrow[{{0, 0, 0}, a}], Arrow[{{0, 0, 0}, b}],

  GeometricTransformation[
   Translate[Scale[f1, {1, 1, 1} Norm[a - b], {0, 0, 0}], a],
   RotationTransform[{{0, 0, 1}, -a + b}, a]
   ]
  },
 Axes -> True, BoxRatios -> Automatic
 ]

enter image description here

Maybe more readable approach:

x = {0, 0, 1};
a = {1, 1, .5};
b = {0, 1, 2};
Graphics3D[{
  Red, Thick, Arrow[{{0, 0, 0}, a}],
  Blue, Arrow[{{0, 0, 0}, b}],
  Green, Arrow[{{0, 0, 0}, x}],
  {Opacity[.1], f1},
  GeometricTransformation[
   f1,
   {Norm[b - a] RotationMatrix[{x, b - a}], a}
   ]
  },
 Axes -> True, BoxRatios -> Automatic
 ]

enter image description here

$\endgroup$
  • $\begingroup$ When I execute this, I get the arrows, but the "tear" is not displayed, and I get the error Graphics is not a Graphics3D primitive or directive.. How can I fix this? This looks perfect by the way. $\endgroup$ – AccidentalFourierTransform Nov 20 '15 at 20:23
  • $\begingroup$ @qftishard sorry, forgot First. $\endgroup$ – Kuba Nov 20 '15 at 20:24

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.