I am plotting an anisotropy distribution function as color coding on the surface of a unit sphere with this code:
PAD[β_, θ_] :=
1/(4 π) (1 + β LegendreP[2, Cos[θ]])
SphericalPlot3D[1, {θ, 0, π}, {ϕ, 0, 2 π},
ColorFunction ->
Function[{x, y, z, θ, ϕ, r},
ColorData["Rainbow"][
Rescale[PAD[β = 1, θ], {0, 0.5}, {0, π}]]],
Mesh -> False, Boxed -> False, Axes -> True, AxesLabel -> {x, y, z},
ColorFunctionScaling -> False, PlotPoints -> 100,
SphericalRegion -> True]
Thanks to this solution. Next, I would like to calculate the integral along the y axis and plot the result as a density map in the same color coding. It should look similar to this image (the outer ring, disregard the inner rings).
Embarrasingly, I fail to even find a proper starting point in this problem. I have to calculate the projection of my function on a sphere, scale the values according to the color coding of the 3D plot, transform to cartesian coordinates, integrate, density plot. While the last steps are simple, my mind is stuck on how to begin with the first two.
Update: I un-stuck my mind thanks to the discussion with Alexei and came to the following approach: I need a function for the radial part, and chose a Gaussian function
Gaussian[r_, r0_, s_] := Exp[-(r - r0)^2/(2 s^2)]
and then made a DensityPlot of a slice through the distribution with
DensityPlot[
Gaussian[Sqrt[x^2 + y^2 + z^2], 1, 0.05]
PAD[β = 1, ArcTan[z, Sqrt[x^2 + y^2 + z^2]]] /. y -> 0,
{x, -1.2, 1.2}, {z, -1.2, 1.2}, PlotPoints -> 150,
ColorFunction -> ColorData["Rainbow"], PlotRange -> All]
which works nicely. To get the projection along the y axis, I wrapped the plotted functions into NSum as in
NSum[<func>, {y, -1.2, 1.2, .25}]
and repeated the DensityPlot. This is taking forever and the results depend obviously a lot on the chosen increment of NSum. For larger values, I do not get a smooth distribution inside the ring, and smaller values take hours to complete. Does anybody have a better idea?
Hue
function. Check Menu/Help/WolframDocumentation/ColorFunction and have a look at the very first example, or some other examples showing different ways. $\endgroup$Function[{x, y, z, \[Theta], \[Phi], r}, ColorData["Rainbow"][ Rescale[PAD[1, \[Theta]], {0, 0.5}, {0, \[Pi]}]]]
defined in your question? $\endgroup$