Message Boards Message Boards

1 Reply
1 Total Likes
View groups...
Share this post:

ColorFunction enters endless loop when applying a function as the Hue.

Posted 10 years ago

Hi there, I am trying to code a function that sums the intensity of a function at different points in space then apply those intensities as a hue to a sphere to analyse the result. When I run the code, the part that applies the Colorfunction to the sphere runs in an endless loop, either that or I have yet to wait long enough, more than 40 minutes seems a bit extreme for something so simple. Below is the code to generate the intensities and the plotting of the sphere. The sum function gives a complex sum, tested using Moniter[expr], and the spherePlot works fine as well. The problem enters when I uncomment the ColorFunction.

u[x_ , y_ , z_] := Sum[ uLG[k[[j]], k[[nn[[j, 1]]]] - k[[j]], 1, Length[nn[[j]]], 0, {x, y, z} ], {j, 1, Length[k]}]

r = 2 Pi;

uMax = Length[k]/2;

spherePlot = ParametricPlot3D[{r Cos[theta] Cos[phi], r Cos[theta] Sin[phi], r Sin[theta]}, {theta, -Pi, Pi}, {phi, 0, 2 Pi}, Mesh -> None, PlotPoints -> 100,

ColorFunction -> Function[{x, y, z}, v = u[x, y, z]; Hue[Arg[v]/(2 Pi) + 0.5, 1, (Abs[v]/uMax)]], ColorFunctionScaling -> False]

'j' is 12 3-D vectors corresponding to the cartesian coordinates of the vertices of a polyhedra. u[x_ ,y_ ,z_] gives a really large sum of complex numbers but this is what I was expecting. In the color function, I take the argument of the complex numbers and divide by 2Pi to make it more suitable. This method worked fine when my 'u' input was much simpler, merely the cartesian coordinate of the vertex as a vector * {x,y,z}

If anyone could explain why the Colorfunction doesn't plot, I would be eternally grateful. If the function uLG is needed, or the rough outline is needed, just ask. I also test function uLG for a single {x,y,z} input and gave the same answer my pen and paper calculation gave so am confident that isn't the problem.

I am quite new to Mathematica, Thanks in advance, Andrew

POSTED BY: Andrew Ross

My suspicion is that it is u[x,y,z] that is causing the issue, but I cannot be sure without knowing what uLG, k, and nn are. Would you post them, please?

POSTED BY: Robert Collyer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract