7 ms·
Matrices from a geometric perspective
- stevemk14ebr 9y agoThis is obvious for anyone who does game development. Matrices are use to convert between 3d game coords -> screen coords. Also almost all movements/rotations/scaling of objects in game is done via matrix multiplications. I used matrices once to draw 3d spheres efficiently! It's very computationally expensive to calculate the points of many sphere's of varying radii every frame. What i instead did was pre-compute a few small sized spheres located at the origin. I then matrix multiplied the pre-computed vertices to position spheres at the desired location and size in the 3d world. This was so much faster my fps went from ~5 to a smooth 60! Very useful knowledge!
- deleted 9y ago[deleted]
- Scea91 9y ago> Also almost all movements/rotations/scaling of objects in game is done via matrix multiplications. Not necessarily true. Quaternions are used a lot because they have some desirable properties over matrices. As far as I remember, they are smaller and more suitable for interpolation.
- andrewflnr 9y agoI could have sworn that quaternion transforms were still 4x4 matrices, but I think that's just because quaternions themselves are representable as 4x4 real matrices, which are computationally convenient. https://en.wikipedia.org/wiki/Quaternion#Matrix_representations https://en.wikipedia.org/wiki/Quaternion#Matrix_representati...
- deleted 9y ago[deleted]
- jacobolus 9y agoQuaternions are a 4-parameter representation of a rotation + scaling operator, the analog of using a complex number to represent rotation + scaling in the plane. You can convert a (4 parameter) quaternion to a (9 parameter) 3x3 matrix in a similar way that you can convert a (2 parameter) complex number to a (4 parameter) 2x2 matrix. In either case you aren't using the full parameter space of the matrices. In general in programs quaternions are used for storing and manipulating rotation operators (e.g. composing them together, etc.) because it saves work and improves numerical stability, but then final application of the rotation to a gigantic list of vectors is done using a matrix, because matrix-vector multiplication is very efficient (only need 9 multiplications and 6 additions to multiply a 3x3 matrix by a 3-element vector).
- theoh 9y agoQuaternions represent 3D rotations in a way which avoids the drawbacks of Euler angles. See "gimbal lock".
- cma 9y agoYes, but he's comparing them against Rotation Matrices (which don't suffer from gimbal lock), not Euler angles: http://work.thaslwanter.at/Kinematics/html/04_Quaternions.html http://work.thaslwanter.at/Kinematics/html/04_Quaternions.ht... In practice, game engines use all three methods.
- theoh 9y agoEuler angles (or an equivalent) are implicit in the the way rotation matrices work.
- jacobolus 9y agoThis is not correct (or at any rate is oversimplified). A rotation matrix can represent any arbitrary path through the space of possible rotations (SO(3)) by smoothly varying parameters. There is no inherent “gimbal lock” or the like. In general I would recommend avoiding Euler angles as a formal representation of rotations. There are several choices of better representations, some of which are described at https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_d...
- theoh 9y agoYou're right, I should have said "usually inherent". But it's a major reason for using quaternions. While you stress the case of gimbal lock occuring within a single rotation, which is typically due to the use of Euler angles, there is also the problem of gimbal lock emerging through the composition of two or more rotations in matrix form. I'm vague on this point but AFAIK this problem can arise with rotation matrices whether or not Euler angles are used. Choose three successive unlucky rotation axes and you've got the problem. This seems to get so complicated. See e.g. https://en.m.wikipedia.org/wiki/Davenport_chained_rotations https://en.m.wikipedia.org/wiki/Davenport_chained_rotations
- dahart 9y agoIt's not either-or, quaternions do not replace matrices. Matrices are (almost) always used, regardless of the use of quaternions (also regardless of use of any other types of transforms including geometric algebra). Quats are typically used for interpolating orientations. Once you have an interpolated orientation, you still have to turn it into a matrix to interact with other transforms, and to send to the GPU. The vast majority (if not all) game engines, libaries, and GPU/console hardware operate on matrices at the lower levels.
- peterjs 9y agoFor people interested in the relationship between algebra and geometry, there is a quite rigorous, yet not too long discussion of these topics in the "Elements of Geometry for Computer Vision" [1]. It comes the from the engineering end and finds a good balance between going into too much depth and introducing the necessary theory for bridging algebra and geometry. E.g. representing motion as a change in basis in linear space, the perspective camera as a mathematical model, etc. [1] http://cmp.felk.cvut.cz/~pajdla/gvg/GVG-2016-Lecture.pdf http://cmp.felk.cvut.cz/~pajdla/gvg/GVG-2016-Lecture.pdf
- Scea91 9y agoDid not expect to see this mentioned. I attended this exact course at the university. This is my goto material for computer vision geometry.
- dyarosla 9y agoFor an article like this I find that static visualizations aren't anywhere near as effective as dynamic ones found in a similar explanation here (3Blue1Brown on Linear Algebra Transformations) https://www.youtube.com/watch?v=kjBOesZCoqc&list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab&index=1 https://www.youtube.com/watch?v=kjBOesZCoqc&list=PLZHQObOWTQ...
- pdkl95 9y ago3Blue1Brown has an outstanding series of short videos, "Essence of linear algebra"[1], which covers vectors, matrix transformations, and the related math. What I particularly like about these videos is that the concepts are introduced first without the numbers and calculations (that stuff is covered later). The concepts are first introduced as abstract animations to emphasize the "shape" of what the vector, matrix, etc really represent. [1] https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2x...
- lexpar 9y agoCan't overstate how great his stuff is.
- edanm 9y agoAmazing series! Open question I still have - what is the "geometric interpretation" of the transpose operation? A^T? Considering the fact that the transpose shows up all the time, I'm very surprised that I've never seen a good explanation of how I should be visualizing it.
- thethirdone 9y ago> Open question I still have - what is the "geometric interpretation" of the transpose operation? A^T? AFAIK, there is not a solid geometric interpretation. Part of the trouble is that the transpose can change the shape of the matrix. For example, for a vector the transpose turns it into a matrix outputting a single number. These two objects seem to be rather incomparable geometrically. The best intuition I have for transposition is that it represents a time reversal (but not necessarily an inverse). In the case of a vector, you have to think of it as a linear transformation that maps 1 to that vector. The transpose instead maps that vector to its length squared. I have more vague intuition for the why its length squared and how it relates to projections, but its hard to put into words. With rotation matrices, this time reversal results in the inverse. So essentially rotation/skewing is reversed, but scaling is not.
- akalin 9y ago
- dboreham 9y agoGenuinely curious how anyone could know about matrices and _not_ know their relationship to geometry.
- tnecniv 9y agoYou could have learned them from a very algebraic source, I suppose.
- dboreham 9y agoNot sure how that could happen without going through high school math, but I suppose anything is possible.
- twic 9y agoI first came across them in a book about discrete mathematics, which was more about the algebraic structures matrices can form than what matrices themselves can represent.
- MrBingley 9y agoHehe, you'd be suprised. I took an honors linear algebra course in my first year of university, and abstraction was the word of the day. Everything we did was for abstract vector spaces over arbitrary fields. We didn't look at the determinant as the signed volume of an n-cube, for example, but rather as a homomorphism from the group of matrices to the base field under multiplication. The cross product was never mentioned because it didn't generalize to arbitrary dimensions. It was good preparation for further abstract algebra courses, but not so much for others, like differential geometry, which rely heavily on geometric intuition.
- BucketSort 9y agoA notebook I made for exploring this relationship. If you have Jupyter notebooks setup, you can change the parameters and see how this works in a more interactive setting: https://github.com/Andrewnetwork/WorkshopScipy/blob/master/Notebooks/Matrix%20as%20a%20Function%20%26%20Plotting%20Vectors.ipynb https://github.com/Andrewnetwork/WorkshopScipy/blob/master/N...
- catnaroek 9y agoHow disgraceful, conflating matrices with linear and affine transformations.
- Koshkin 9y agoWay too often intuition (or trying to make things clear on an intuitive level) interferes with and/or severely impedes and slows down gaining the actually useful skills. Maybe not in applications to computer grahics, but in genreral there is so much to matrix analysis [1] that trying to translate everything into geometric images would make learning it at a practically useful level anything but impossible. Rote learning, like the mindless memorizing of the multiplication table, is an extremely important component of education that is to reach any degree of sophistication or usefulness. Also, being not (too firmly) attached to a particular interpretation of a formal system leaves open the door to potentially discovering new applications. [1] See, for example, a book by Horn and Johnson.
- heavenlyblue 9y agoI just love how a few posts over here massively upvote clearly simple comments such as "I had used a matrix in 3D and then used them to rotate points in 3D space" against somebody who may not clearly understand, yet still makes a point that matrices are way more abstract than people expect them to be - and they downvote because it's harder to understand. This is such a horrible form of childish anti-intellectualism.
- gizmo686 9y agoIts almost as if there is an isomorphism between matrices and linear transformations. Actually, not almost. The author clearly explains this isomorphim in his introduction to matrices.
- wenc 9y agoI finished Ph.D. courses without ever having to pay much attention to the geometric interpretation of matrices. The path I took was solely computational and algebraic. I often wondered if I'd missed anything. The 3Blue1Brown videos say I did. I will admit I don't have a solid intuition for matrices used for rotations, flips, etc. (outside of basic 2x2 examples). This can be a disadvantage, even if one pursues a purely computational approach to linear algebra. For instance, it took me a little longer to understand numerical techniques like Householder transformations. https://en.wikipedia.org/wiki/Householder_transformation https://en.wikipedia.org/wiki/Householder_transformation That said, I want to also say something in defense of the purely algebraic approach. In higher dimensions, there is no geometric analogy and people who rely on geometry alone find themselves unable to think abstractly in higher dimensions. To me, matrices and vectors are the building blocks for multivariate generalizations of familiar relationships. The algebraic approach meant I was comfortable dealing with complicated high dimensional objects that weren't amenable to visualization. I believe intuitions are good for laying a foundation, but abstractions are necessary for generalization and for building larger theoretical systems. Intuitive constructs can only get you so far. If I'm not mistaken, this was what Bourbaki group strove for; that is, to move mathematics past the intuitionist approaches of the day to a solid theoretical foundation built upon abstractions. There are pros and cons, but arguably without this foundation, mathematics might not have grown in the way it did.
- chii 9y ago> Intuitive constructs can only get you so far. yes, but intuitive constructs helps the beginner. It makes the material easier to obsorb, and hopefully, by building this intuition up, it can lead to a deeper learning later on (what you call abstraction).
- thethirdone 9y ago> In higher dimensions, there is no geometric analogy and people who rely on geometry alone find themselves unable to think abstractly in higher dimensions. Often features in higher dimensions can start to be seen in lower dimensions. For example the common example of the strangeness of higher dimensional spaces is the case that a hypercube with side length 2 can have a smaller volume that a hypersphere touched by hyperspheres of radius 1 at each corner of the hypercube. This is not true in 3 or even 4 dimensional space. But if you use geometric intuition to see the trend from 1d to 2d to 3d, it seems entirely reasonable. (Apologies if I didn't explain the problem well. I wanted to find a video on it, but couldn't find one) > I believe intuitions are good for laying a foundation, but abstractions are necessary for generalization and for building larger theoretical systems. Intuitive constructs can only get you so far. I have a slightly different view on this. I feel that abstractions are fundamentally necessary for communicating rather than conceptualization. For example, you may realize that the type of theorems you have been making about vectors equally applies to polynomials, but in order to convince others you would need to write done the properties they both have (resulting in an abstraction). Its kind of a subtle point because communication is key to mathematics. But normally, before I try to write a proof, I figure out the intuition for why it must be true in my head. Because this is a powerful tool, I try to learn a solid intuition for any abstraction I am introduced to.
- dbranes 9y agoI don't want to doubt the potential usefulness of the linked article to certain audiences, but I wanted to point out the following: It's important to acknowledge that intuition from rotations etc. are crutches, and not substitutes for deeply understanding linear-algebraic constructions and their formal properties. Linear algebra is not really about the arithmetic of multiplying arrays of numbers - it's about the nice algebraic things that happen when you're working with things that come with "linear" operations. The linear-algebraic things that permeate all of mathematics aren't "rotations matrices" and such, but rather "universal constructions" like kernels and cokernels, products and tensor products etc. We even have abstractions that precisely formalize these nice properties of the category of modules/vector spaces, such as abelian categories and linear functors. Any introductory reference on these will provide you with an abundance of examples where things with these formal properties naturally arise.
- dbranes 9y agoA related remark: there is another (rather silly) way to "geometrize linear algebra". It goes something like whenever you see a ring R, think of it as the sheaf of functions (the structure sheaf) on some space. Whenever you see a module over R, think of it as the space of sections in some vector bundle over that space. Then anything you say about modules through this admits a sheaf-theoretic version, which is often easier to picture if you're geometrically inclined.
- joppy 9y agoIn the case where the base ring R is a field (all of typical linear algebra), then the space associated to it is a point. So a vector bundle over this point is just a vector space, so we didn't really gain any extra geometry here - if you want a way of picturing linear algebra geometrically, you still need some other idea.
- dbranes 9y agoGood point!
- deleted 9y ago