Well, Quaternions don’t have a divide or subtract method.
Here’s how it works.
To combine to Quaternions you multiply them, they’re like matrices in this respect (actually quaternions are a special kind of matrix):
var c = a * b;
Now, when you want to do the opposite of add, what do you do? You subtract. But is subtract? It’s the opposite, or inverse of add.
If you wanted to subtract b from a, you could just add the additive inverse of b to a:
a - b == a + -b
When you want to do the opposite of multiply, you divide. Division is the opposite, or inverse of multiplication.
If you wanted to divide a by b, you could just multiply a by the multiplicative inverse of b. The multiplicative inverse is the reciprocal of a value.
a / b = a * 1/b
2 / (2/3) == 2 * (3/2) == 6 / 2 == 3
Side Note - this is actually how I always did my arithmetic growing up. Division and subtraction aren’t associative, which made it very difficult to do my math, because I couldn’t just simplify parts of it… I had to do the math left to right, because / and - required it. BUT if I could just remove all the division and subtraction signs… then the entire thing became associative. I can just rearrange as I saw fit.
3 + 1 / 4 - 6 * 4 == 3 + 1 * (1/4) + -6 * 4 == 3 + (0.25) + -24 == -20.75 or -20 3/4
I actually still can’t solve that with out changing to the inverses. I don’t know how anyone does… it just seems so ridiculous.
This same thing works with matrix/quaternion multiplication (remember, a quaternion IS a kind of matrix). Here’s the thing though, there is no inverse operation to matrix multiplication. Why? Well matrix multiplcation has a weird definition, we call it multiplication because the definition utilizes scalar multiplication for most of its steps. But it’s not actually multiplicaiton in the end… it’s a very complex algorithm. And that algorithm doesn’t translate to a process that includes division as it’s primary operator on the scalars in the matrix. Because it’s not multiplication! It’s just an algorithm that we called multiplication because some of its parts are. But the over all operation acts nothing like multiplicaiton… multiplication is both associative and commutative, matrix multiplication is not.
BUT, really, subtraction and division are defined as the inverse operations of addition and multiplication. If we wanted. If we can find a general case algorithm to get the operative inverse of a value, then we can just multiply by that inverse. Additive inverse algorithm, 0 - value. Multiplicative inverse, 1 / value. Matric multiplicative inverse, well… it’s a pretty complex algorithm, BUT we know it (see: Invertible matrix - Wikipedia).
So, to undo a matrix multiplication, we can multipy by the inverse. It LOOKS like the same operation in scalar multiplication.
MA / MB == MA * Inverse(MB)
Oh, and I’d like to point out one last problem with this though, and another reason why we didn’t create an operator for it. Inverting a matrix doesn’t always work. Some matrices just can’t be inverted (see that wiki article I posted). Which makes special cases where this operation fails.
Don’t worry though, all the quaternions you use to represent rotation are invertible.