Yes, this is possible, and it does generalize to N dimensions with geometric algebra.
First, calculate the geometric algebra vector product of the two vectors, which results in scalar and bivector parts (1 scalar number and 6 bivector numbers). The scalar is the dot product of the two vectors, and the bivector is formed by the wedge product, which looks similar to the cross product (ex: xy = a.x * b.y - a.y * b.x). We call the combination of scalar and bivector a rotor.
This operation gives us a rotor that rotates by twice the angle between the two vectors. Therefore, if we want a rotor that rotates from one to the other, we need to get a rotor with half the angle. You can compute the normalized bivector and rotation angle from the rotor, then multiply that angle by 0.5 and construct a new rotor. Here is some C++ code for how to do that part:
Rotor4D Rotor4D::half_angle() const {
double_t angle = Math::acos(scalar);
double_t sin_angle = Math::sin(angle);
double_t fractional_angle = 0.5 * angle;
double_t new_scalar = Math::cos(fractional_angle);
double_t new_sin_angle = Math::sin(fractional_angle);
Bivector4D new_bivector = bivector * (new_sin_angle / sin_angle);
return Rotor4D(new_scalar, new_bivector).normalized();
}
This formula is dimension-agnostic, and works in any dimension. The resulting rotor can be used to rotate any 4D vector.