The ship location should be relative to the mouse location before you start the trig.
If the mouse is at 10,10 and the ship is at 20, 15 then for the start triangle x is 10 and y is 5.
The trig functions all work on the cartesian grid, where x increases to the right and y increases toward the sky. So start out by getting the mouse position and the ship position in as3 coordinates and then calculate the triangle dimensions:
mouse_x = 320
mouse_y = 240
ship_x = 10
ship_y = 10
starting_triangle_x = ship_x - mouse_x = -310
starting_triangle_y = mouse_y - ship_y = 230
angle = atan2(starting_triangle_y, starting_triangle_x)
adjust theta by your orbital velocity:
angle += rv
Get the unit lengths for the new triangle:
new_triangle_x = cos(angle)
new_triangle_y = sin(angle)
Get the radius:
radius = sqrt(starting_triangle_x^2 + starting_triangle_y^2)
Scale the triangle:
new_triangle_x *= radius
new_triangle_y *= radius
Now apply the positions relative to the mouse:
ship_x = mouse_x + new_triangle_x
ship_y = mouse_y - new_triangle_y
I'm not entirely sure if you'll run into quadrant problems. I'll have to check that when I get back home. Now that I'm thinking about it, the mouse moving around during play could drag the ship all over the place. I don't think this is what you want either.
This would be a lot simpler if orbit had no momentum. -.-
I guess you could generate a [theta, r] vector velocity for the ship, then generate a new vector from the input, add them together, apply them and then multiply the vector by your friction value.
Alternatively, on the first frame that a direction is pressed you fix the motion angle and just keep moving that direction until the input changes?
Edited by Khatharr, 08 March 2013 - 06:35 PM.