follow mouse constrain to circle

Hey guys, could anyone help with this? I want to orbit an actor around another actor but I want it to follow the mouse and not just be going around in orbit. I want's it to be constrained around a circle still but just be able to make it follow where the mouse is without leaving the orbit constraints. Any thoughts? Thanks.
SM
SM
Comments
constrain attribute: self.Position.X To: sceneX+orbitRadius*cos(vectorToAngle( game.Mouse.Position.X - sceneX , game.Mouse.Position.Y - sceneY ))
constrain attribute: self.Position.Y To: sceneY+orbitRadius*sin(vectorToAngle( game.Mouse.Position.X - sceneX , game.Mouse.Position.Y - sceneY ))
sceneX and sceneY is the center point (in scene coordinates) that you want to orbit around
orbitRadius is the distance from the center point
Also, if you want the actor to point away from the center point (and towards the mouse) you could constrain the actor to:
vectorToAngle( game.sceneX - self.Position.X , game.sceneY - self.Position.Y )
As for tilt control, here is a way to determine "down" from the accelerometers. (The actor can point "down", whatever that means.)
(vectorToAngle( game.Accelerometer.X , game.Accelerometer.Y )+90)%360
The +90 is in case the device is oriented to landscape left. If in portrait, just remove the +90.
EDIT: Both of those would be used to constrain self.rotation