How to think about CFrames


OMG. I don't even know what I was writing. I think I was trying to redefine stuff to be easier to understand and logic failed.
I'm not very strong with the math part of quaternions, but I am very strong with other stuff, and I stand by everything I said after


However, minus the stupid component wise shit I tried to do, the construction I provided IS very valid, though I see now it's not what I said it was.
qw = a dot b
qx, qy, qz = a cross b

Anyway, to make this a good post, here's a useful way to construct quaternion.
qw = a dot b
qx, qy, qz = a cross b
That generates a quaternion twice rotated from a to b, so if we slerp a vector half way from a to b, we can use this to construct a quaternion which is rotated from a to b once.

Instead of slerping, we can just do c = (a+b)/||a+b||, which is just:

c = (a+b).unit

And then do:
qw = a dot c
qx, qy, qz = a cross c


I attempted the same thing once. It's easy to interpolate between two vectors of course, using addition and scalar multiplication. It's not quite so easy with rotations however because they are fundamentally different from the real numbers.
In the familiar setting of Euclidean space, we know that the shortest path between two points is the line segment connecting them. But in "rotation matrix space", the shortest path between two points is a geodesic--an arc along the great circle passing through them. So already we see that we cannot treat rotations like ordinary numbers.

The quaternions are the number system which harbor 3-dimensional (and 4 dimensional) rotations in their most "natural" form, in a similar fashion to how the complex numbers are the most natural setting for 2-dimensional rotation problems.
For plain, constant-speed spherical interpolation, quaternions are not necessary--they actually are sub-optimal in this particular case. Trey demonstrated quaternion-free SLerping a while back using the axis-angle parameterization. But if you want more control over the interpolation process, then quaternions are nice because they obey most of the common rules of arithmetic, save for the commutative law of multiplication. You can actually define analogous, "quaternionic" counterparts for the complex exponential & logarithm over the quaternions, which make applying calculus more straightforward.


Corrected the formatting of the original post. (and suremark's post was 531 days ago)


Iā€™m very very late to this, but thank you :smiley:
You should write more articles, something about the way you explain things lets me grasp concepts much more easily than I could in the past with other resources


Within the first bit of the article I now understand CFrames a lot more. I never knew that the 9 numbers at the end were the directional unit vectors!


Nice Tutorial.