Rotation math problem: Aim Offsets for rolling character?

I feel certain there’s a way to do this, but I cannot for the LIFE of me figure the math out.

I have a character who, for the purposes of this problem, is floating in a prone position (stomach down, feet back, head forward). I have an aim offset for this character with two axes; a “pitch” axis which goes from aiming toward the head, across aiming out/down from the chest, and finally to aiming back across the feet. The second axis is a 360° “yaw” axis that actually ROLLS the character (I use yaw and pitch here for reasons that will be clear below). Thus at pitch 0 yaw 0, the gun points at the ground; at pitch 0 yaw 180, the gun points at the sky. It’s sort of like your standard pitch/yaw aim controller, but rotated sideways so “up” is forward, “down” is backward, and rotating “left or right” actually rolls the character in a circle.

Okay, so far so good. Now here’s the issue:

This character can go off of a half-pipe-style ramp. This motion will change his pitch, yaw, AND roll at the capsule level. What will happen is his stomach will track the ramp as he goes off it, so when he’s airborne, what was once “down” has now become “forward” (literally, his stomach points where the ramp surface WOULD be if it extended further into the air). He will slowly roll and pitch such that his head goes from pointing toward the sky around to pointing at the ground, IN SUCH A WAY THAT THE DIRECTION OF HIS STOMACH NEVER CHANGES.

What that means is the aforementioned aim offset will always have “pitch = 0” effectively be horizontal aim… BUT both “pitch = 90” and “pitch = -90” will rotate from pointing upward to pointing downward, across either pointing left OR pointing right based on which angle he approaches the ramp (more specifically, which in direction the engine rotates him from upward to downward during his hang-time).

Similarly, “Yaw = 0” will ALWAYS aim in the direction of the pipe (i.e. pitch will sweep the gun across the plane defined by the vertical surface of the quarterpipe) and “Yaw = 180” will ALWAYS sweep the mirrored plane… But “Yaw = 90” and “Yaw = -90” will rotate from left to right across either upward or downward, respectively.

So my issue is this: given a control rotation defined in conventional world space (i.e. pitch and yaw in world space), how can I apply this Aim Offset such that the gun (more or less) points in the direction specified, regardless of the player’s rotation?

Perhaps a clearer way of phrasing it would be this:

Given a freely rotating sphere with surface coordinates defined by latitude and longitude, how can I find the lat/long coordinate pair (at a known rotation of the sphere) at which the surface normal of the sphere is equal to a given vector?

Managed to solve this with help from another forum; anyone in a similar situation (building aim offsets that work with a character that rotates arbitrarily) can borrow my solution, though.

Take the XVector of the Control rot, Unrotate it by the Actor rotation, and use cartesian-to-polar coordinate functions (ACosD of Z for pitch, ATan2D of Y, X for Yaw) to build the floats that drive your aim offset blendspace