Average quaternion between two quaternions

Hello!

How do I find a quaternion, whose direction is strictly between two given quaternions? In 2D space was simple: (directionA + directionB) / 2, but the conditions were by then what area of the axis is used - left or right (if we talk about the degree measure of the angle). In addition quaternions no function or division.

For Simplified problem, I can say that one quaternion will always look on the axis X (in the inspector is the angle (0, 0, 0)). The second will change. A quaternion is required to be always in the middle between the two quaternions.

In the image you want me to quaternion (red) is strictly between quaternions A and B in space.

If you get 2 vectors A,B from those quaternions.

i.e.

Vector3 aVector = Vector3.forward * aRotation;
Vector3 bVector = Vector3.forward * bRotation;

Vector3 halfVector = (aVector  +bVector).normalized;

Quaternion halfRotation = Quaternion.LookRotation(halfVector);

Not tested, but it’s the first thing which came to mind

aRotation and bRotation - what is it?

Your quaternion, but he made a mistakes, the quaternion must be first in the multiplication;

Vector3 a = quaternionA * Vector3.forward;

Also, his method will lose part of the quaternion data, such as the up.

Something easier would be;

Quaternion average = Quaternion.Slerp(a, b, 0.5f);

Might give unexpected result if from and to are total opposite from each other.

Can’t you just do:

Vector3 half = Vector3.Lerp(vector1, vector2, .5f);

Quaternion look = Quaternion.LookRotation(half);