# -----------------------------------------------------------------------------
# Create an annulus.
#
def annulus(rinner, router, n, color):

  from numpy import zeros, single as floatc, intc, arange

  vertices = zeros((2*n,3), floatc)
  from math import pi, sin, cos
  for i in range(n):
      ai = i*2*pi/n
      ao = (i+0.5)*2*pi/n
      vertices[i,:] = (rinner*cos(ai), rinner*sin(ai), 0)
      vertices[n+i,:] = (router*cos(ao), router*sin(ao), 0)

  triangles = zeros((2*n,3), intc)
  triangles[:n,0] = arange(n)
  triangles[:n,1] = (triangles[:n,0]+1)%n
  triangles[:n,2] = n + triangles[:n,0]
  triangles[n:,0] = triangles[:n,0]
  triangles[n:,1] = triangles[:n,2]
  triangles[n:,2] = n + (triangles[:n,0]-1)%n

  from _surface import SurfaceModel
  s = SurfaceModel()
  s.addPiece(vertices, triangles, color)
  s.piecesAreSelectable = True
  from chimera import openModels
  openModels.add([s])

# -----------------------------------------------------------------------------
#
annulus(rinner = 10,             # inner radius
        router = 12,             # outer radius
        n = 100,                 # circle subdivisions
        color = (1,1,1,1),       # red, green, blue, opacity
        )
