A: 

Assuming that whatever calls your function that draws the slice has its data in some kind of list, sort that list so that the closer items appear later and are drawn last.

Some code or other details would go a long way in helping give you a better answer, though.

overslacked
+2  A: 
macbirdie
Yes I kind of see - glad you understood my poor initial explanation at least! See my answer as I think you've given me the right idea to start with...
Great! Glad to help!
macbirdie
+1  A: 

EDIT:

mbeckish is right - this should fix it. Build up two lists with a 'cartoon-race method' - ie keep adding to a list until its total angle content exceeds the other list, then change lists and keep going. Once that's done, draw the 'smaller' one first. As this will contain at most 180 degrees it can never cross the danger point. If they're equal it doesn't matter. (It's not pretty)

define clockwiseAngles[], antiClockwiseAngles[]
define totalClockwiseAngles, totalAntiClockwiseAngles

for each angle in angles
  if totalClockwiseAngles > totalAntiClockwiseAngles
    totalAntiClockwiseAngles += angle
    AntiClockwiseAngles.push(angle)
  else
    totalClockwiseAngles += angle
    clockwiseAngles.push(angle)

if totalClockwiseAngles > totalAntiClockwiseAngles
  // draw all anticlockwise angles
  // draw all clockwise angles
else
  // draw all clockwise angles  
  // draw all anticlockwise angles
You need to make sure that the slice that crosses the 180 deg line (i.e. the slice that comes closest to the screen) is drawn last.In your current pseudocode, it could be clockwise's turn, but the slice could be really big and wrap around to the anticlockwise side. Then, when you draw the next anticlockwise piece, you will have problems.
mbeckish
A: 

Maybe you should just refactor to use whatever standard methods are out there to draw a cylinder from a given perspective, then color the surface of the cylinder to delineate the slices.

mbeckish
+1  A: 

Assuming that the value of angle when pointing straight to us is 270, simply calculate the distance of the slices' midpoint from this six o'clock line:

 Math.abs(270 - (startAngle + endAngle) / 2)

Then sort the slices based on this distance and draw in descending order.

Lars Haugseth
+1 Thanks, this is basically the right answer. It'll work in any half decent language, but in this specific application anything other than sort high -> low is not really feasible, and I will probably have to use my more long winded solution
See my edited answer for a case where the simple formula doesn't work.
macbirdie
@macbirdie: You're right, I've upvoted your answer.
Lars Haugseth