# Cartesian coordinates inside Spherical function

I would like to write a function that draws a graphic object and its projections along the x,y and z axes. I specify the $r,\theta, \phi$ of the object and an arrow and it's dashed projections are created in a Graphics3D list.

However, to draw the lines, it's much easier to work with ${x,y,z}$ coordinates. I am trying to use both of them in my function, but do not know how do this. Here is my function (I apologize for the image, but I cannot control C control V from this linux machine, weird characters appear): Now I just want to substitute the $x,y,z$ values for the values obtained by the transformation:

{x,y,z} = CoordinateTransform["Spherical" -> "Cartesian", {r, theta, phi}];


Is there any way I can go about this? Also, if there is an easier way for doing this, please let me know. I tried using "Module" as well, but while it did do what I want, it did not allow me to use "Show" to plot it.

• Does this give what you need: Graphics3D[{{Thickness[0.005], RGBColor[.4, .3, .2], Arrow[Tube[{{0, 0, 0}, {x, y, z}}]]}, {Dashed, Line[{{x, y, 0}, {x, y, z}}], Line[{{x, 0, 0}, {x, y, 0}}], Line[{{0, y, 0}, {x, y, 0}}]}}] /. Thread[{x, y, z} -> CoordinateTransform[ "Spherical" -> "Cartesian", {r, θ, ϕ}]]? – kglr Apr 29 '16 at 21:04
• It does! Thanks for the help – triplebig Apr 29 '16 at 21:09

spinArrow[r_, θ_, ϕ_] := Module[{cart = CoordinateTransform["Spherical" -> "Cartesian",
{r, θ, ϕ}], x, y, z}, {x, y, z} = cart;
Graphics3D[{{Thickness[0.005], RGBColor[.4, .3, .2],
Arrow[Tube[{{0, 0, 0}, {x, y, z}}, .005]]}, {Dashed,
Line[{{x, y, 0}, {x, y, z}}], Line[{{x, 0, 0}, {x, y, 0}}],
Line[{{0, y, 0}, {x, y, 0}}]}}, BoxRatios -> 1]]

spinArrow[1, π/4, π/4] Or use ReplaceAll (/.)

spinArrow2[r_, θ_, ϕ_] := Graphics3D[{{Thickness[0.005], RGBColor[.4, .3, .2],
Arrow[Tube[{{0, 0, 0}, {x, y, z}}]]}, {Dashed,
Line[{{x, y, 0}, {x, y, z}}], Line[{{x, 0, 0}, {x, y, 0}}],
Line[{{0, y, 0}, {x, y, 0}}]}}] /.
Thread[{x, y, z} ->  CoordinateTransform["Spherical" -> "Cartesian", {r, θ, ϕ}]]

spinArrow2[1, π/6, π/3] 