How do I return a float value between 1 and -1 based on a camera's rotation?

I have a have a ball with a rigidbody attached and I am adding torque to the ball based on the angle of a third person camera witch rotates around the ball. I am trying to change the direction of the ball based on the position of the camera in its rotation around the ball. I am using Vector3.right for forward and reverse torque and Vector3.back for right and left. I have the forward/reverse value, rightVal working but I have been working on the left/right value, backVal for three days and am at a loss. Here is how I am trying to accomplish this.

 void CalcRightVal()
        {
             float degrees = Camera.main.transform.localEulerAngles.y;
            if (degrees > 0 && degrees < 180.0f)
            {
                rightVal = (-degrees / 360) * 4 + 1;
            }
    
    
            if (degrees > 180.0f && degrees < 360.0f) //
            {
                rightVal = (-degrees / 360) * 4 + 1;
    
                if (rightVal < -1.0f)
                {
                    rightVal = (degrees / 360) * 4 - 3;
                }
            }
    
        }
    
        void ApplyTorque()
        {
            Vector3 dir = new Vector3(rightVal, 0, backVal);
            ball.AddTorque(dir * ballAcceleration);
        }

In ApplyTorque() I need the backVal to go from 0 to -1 i.e. Vector3.back when degrees == 90. Then backVal should increase in value to 0 when degrees == 180 then up to 1 when degrees == 270 then back to 0 when degrees == 360. This will apply torque to the right when the camera is at 90 degrees and left when the camera is at 270 degrees. The Idea is that the user will add input to forward i.e. KeyCode.W to add acceleration and reverse or KeyCode.S for breaks. The camera will be responsible for changing the direction of the force. I am not terrible at math but this one has me beat.

Here is a graphic to help out.
111631-quadrant.png
Thank You.

I could be misinterpreting, but the way you describe it, it sounds like the end goal is to get a 2D normalized vector in the direction from the camera to the ball, and then apply ballAcceleration amount of torque in that direction. This doesn’t necessarily answer your original question, but I’m guessing there’s a better way to avoid doing all that math yourself. Would the following work?

void ApplyTorque()
{
    var cameraPosition = Camera.main.gameObject.transform.position;
    var direction = ball.position - cameraPosition;
    var planarDirection = new Vector3(direction.x, 0, direction.z).normalized;
    ball.AddTorque(planarDirection * ballAcceleration);
}

EDIT: based on the comment below, it sounds like you want a vector 90 degrees off from the direction the camera is facing. You can do that by getting a normal/perpendicular vector to the camera’s direction. In that link, you’ll notice you need two vectors representing your plane to get a normal. In your case we can use the vector from the camera to the ball as the first vector, and “up” as the second:

void ApplyTorque()
{
    var cameraPosition = Camera.main.gameObject.transform.position;
    var direction = ball.position - cameraPosition;
    var planarDirection = new Vector3(direction.x, 0, direction.z);
    var perpendicularDirection = Vector3.Cross(planarDirection, Vector3.up).normalized;
    ball.AddTorque(planarDirection * ballAcceleration);
}

I’m still not clear on which direction the torque vector is rotated from the camera (clockwise or counterclockwise) – BUT if you find this script works almost perfectly except backwards, just reverse the perpendicularDirection by making it negative.