I'm not sure if you're asking for the actual code-writing or the math to write the code, but I can help with the math.
I'm starting from assuming the function has an input desired bearing Phi, and outputs v1, v2, and v3 for the motors.
v1, v2, and v3 and all going to be elements on the range [-1,1], where -1 will rotate the robot clockwise and an output of +1 will rotate counterclockwise.
The bearing input Phi determines which direction the robot will move. You can convert that into x_dot and y_dot. Theta dot represents angular rotation (and it will be 0).
x_dot = -sin(phi)
y_dot = cos(phi)
theta_dot = 0
x_dot = v1_x + v2_x + v3_x
y_dot = v1_y + v2_y + v3_y
theta_dot = v1 + v2 + v3 = 0
(For the equations below, I structured them so that straight up is zero degrees, and it increases going counterclockwise so that you can more easily generalize to other wheel placements)
v1 = v1_x + v1_y = - v1*sin(135)i + v1*cos(135)j
v2 = v2_x + v2_y = - v2*sin(270)i + v2*cos(270)j
v3 = v3_x + v3_y = - v3*sin(45)i + v3*cos(45)j
Now you will want to setup a system of equations.
x_dot = -sin(phi) = v1_x + v2_x + v3_x
y_dot = cos(phi) = v1_y + v2_y + v3_y
theta_dot = 0 = v1 + v2 + v3
This is a system of 3 equations with 3 unknowns, your unknowns being v1, v2, and v3. The matrix form of the equation will look like A*v = x, and the solution will be v = A^-1 * x.
This will give you values for your v vector (v1, v2, v3). Before outputting those values, I'd normalize them (just in case they aren't) by dividing by max(abs(v1,v2,v3)).
If you want to further edit your code to allow for the robot to change the direction its facing while also moving, simply make Theta_dot non-zero (positive is counterclockwise, negative clockwise). In this case, you'd also have to take in to account the change in reference frame as you rotate.