I just put a tremendous amount (a full hour) of effort into trying to come up with the perfect way to explain vectors from the ground up, and you don’t even recognize me for it. If you want to learn CFrames, or really do anything, you can’t laze around and ask people to give you answers to everything. You need to take an active stance in your learning.
I appreciate that you made this guide to understanding CFrames. I understand that it’s not targeted at users who have no experience with CFrames, but I am one of those users. I tried to ask you specific questions about what I don’t understand so you could clarify.
Edit: I just noticed you posted some new content in reply to my previous message. I thought you had just posted a quote of the original post. Thanks!
Quaernions are fairly easy to understand once you’ve learned them… Basically works just like e^(i theta) except in 3D, but it’s exceedingly hard to explain.
I guess I could start in terms of 2D rotations using imaginary numbers, skip all of the proofs, and keep it all conceptual.
I might want to do one on Vector stuff first, like dot and cross product, as well as a useful way to think about vectors.
…Did you know that dot and cross product come from quaternions?
The dot product and the cross product have their origins in physics. You might know that work is equal to force times distance when the force and the distance traveled are parallel. The dot product is an extension of this to cases where force and distance are not parallel. Essentially it is the same as taking the parallel component of the force being applied and then multiplying it by the distance (or vice versa).
There is an analogy for the cross product with torque. If you push directly down against a balanced beam, you are pushing perpendicular to it. Note that pushing directly perpendicular to the beam gives maximum leverage with respect to the input force. This can be explained in part by the fact that |sin(theta)| = 1 when theta is a right angle (i.e. 90 degrees or -90 degrees). Intuitively, that the cross product is always perpendicular to the operand vectors can be visualized by the analogy of turning a wrench.
It is also indeed true that the magnitude of the cross product is equal to the area of the parallelogram formed by the two vectors. This is a natural consequence of the fact that the area of a parallelogram is the length of the base times the height, because if one vector is taken to be the base, then the other vector times the sine of the angle is the relative height of that vector.
As a programmer, I find myself using the dot product much more often than the cross product. For an example of the usage of the dot product, suppose I want to find out if a point lies within a polygon (in the 2-dimensional case, for simplicity, but this is also applicable to any number of dimensions). This is very straightforward with dot products (at least for convex polygons) as one is able to gather information about the point relative to each edge of the polygon.
However the cross product is also very nice as it allows you to trivially compute the surface normal of a polygon in 3D space given two of its edges.
You’re not wrong. Though the history doesn’t go all the way back. I also feel as though your description is a bit limited.
Dot and cross product have their origins in quaternions, though Quaternions DID play a lot into physics. Hamilton described quaternions as the product of two vectors. In other words, q = a dot b + i (a cross b)
Where i is <sqrt(-1), sqrt(-1), sqrt(-1)>
and where multiplication with i is component-wise.
My definition is quite visual. Once I came up with this definition for dot product, it has been the only definition I have ever needed. I have actually changed my understanding of everything else to fit this definition, lol. It’s really useful.
Dot product is especially useful when you have at least one unit vector, u and another vector p, where u dot p returns the distance p travels in the direction of u.
Cross product, the way it’s defined with two vectors, is more of a hack for 3D. Very valid, just way less useful than dot product, and in many cases, something which can be entirely replaced with dot product in cases such as:
a cross b cross c = something I don’t remember
and
||a cross b|| = sqrt((a dot a)(b dot b) - (a dot b)(a dot b))
I’ve left stuff out. This is more in addition to your explanation.
Limited, yes, but I veered away from quaternions intentionally. For those who haven’t worked extensively with vectors, quaternions are a very confusing subject. I am not unfamiliar with their history–in fact, I was under the impression that I was the one who told you the dot and cross products arise naturally from quaternion algebra.
I disagree with your description of quaternions. Strictly speaking, the square root of -1 is not a unique number under the quaternions. In the case of the complex numbers, the two solutions to x^2 = -1 are +i and -i. But when you introduce the other two basis elements (j and k), then there are an infinitude of solutions to the equation x^2 = -1, as any number living on the unit sphere of basis (i, j, k) satisfies that relation.
To arrive at the quaternions it is necessary to adjoin elements such as j and k that satisfy Hamilton’s identity i^2 = j^2 = k^2 = ijk = -1. This equation encodes the vital information that i, j, and k are mutually orthogonal. Such numbers do not exist in the complex number field.
Moreover you are incorrect about the product of two vectors–for vectors a, b, the Hamilton product ab is equal to -(a dot b) + (a cross b). The quaternion was traditionally defined by Hamilton and his successors as the quotient of two vectors so as to represent a transformation between one another–a rotation combined with a change of length. The product q = (1/b)a is equal to (1/magnitude(b))^2 * ((a dot b) + (a cross b)), so that bq = a.
Btw, been wanting to get into quaternions for a while because of interpolation on matrices natively doesn’t yield very good results, but my math book doesn’t go into quaternions, so I never took the step (also, tbh, a little frightened by them, and the strange voodoo talk people give when talking about them), I’d love for you to write a tutorial on them
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 [quote]and where multiplication with i is component-wise.[/quote].
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:
Btw, been wanting to get into quaternions for a while because of interpolation on matrices natively doesn’t yield very good results, but my math book doesn’t go into quaternions, so I never took the step (also, tbh, a little frightened by them, and the strange voodoo talk people give when talking about them), I’d love for you to write a tutorial on them :D[/quote]
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.
I’m very very late to this, but thank you
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