Get axis perpendicular to x-axis and aligned to horizontal plane

Hello, I want to rotate my object around an axis. I’m having trouble figuring out the perpendicular axis that is also aligned to a horizontal plane.

Here is an image to show:

Axis Formed by the perpendicular direction of the
red x axis arrow and the horizontal glass plane. (not actually using a glass plane, but just to show what I mean)
How do I get this purple axis?
I will use it for:
RotateAround(object.transform.position, Axis, 5);

The simplest way I can think of this in Unity is to create an empty set 1 unity on the object’s X axis (or any axis you desire to be the red one in the illustration). Use this empty as a target object, and then the script would look something like this in C#;

Vector3 xProjection = new Vector3( target.transform.position.x - transform.position.x, 0, target.transform.position.z - transform.position.z);

Vector3 purpleAxis = Vector3.Cross(transform.right, xProjection);

Keep in mind, however, that this will return (0,0,0) when the object isn’t rotated on its forward (blue) axis - so you will need to code to handle that situation. But in that case your purple axis will simply be (or align with) the forward/blue axis.

In mathematical terms, you want to find the vector projection of the object’s local axis on the plane through the object parallel to the global XZ plane and then use the cross product of this projection and the local axis to determine the purple axis.