def projectToTrackball(self, camera, newX, newY):
     """ Project the mouseposition onto a trackball to rotate the camera.
     
     Parameters:
         newX - new x position on the trackball
         newY - new y position on the trackball
     
     Return:
         vector - position on the trackball
     """
     x = newX / (camera.getWindowWidth() / 2.0)
     y = newY / (camera.getWindowHeight() / 2.0)
     x = x - 1
     y = 1 - y
     z2 = 1 - (x * x + y * y)
     z = 0.0
     if z2 > 0:
         z = math.sqrt(z2)
     # print " x, y, z on sphere: " , x, y, z
     p = Vec([x, y, z])
     p.normalize()
     return p