Skip to main content

News

Topic: I finally understand matrices (Read 4460 times) previous topic - next topic

0 Members and 2 Guests are viewing this topic.
  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
I finally understand matrices
Matrices always confused me.  I knew they were used for transformations in 3D rendering, and Sphere has the color matrix which allows similar tricks with RGB colors... but I never understood more than that, it all just seemed like black magic.  Even the Wikipedia articles didn't help--all the algebraic equations just go right over my head.  It wasn't until I was working on improving minisphere's ColorMatrix object last night that it finally clicked: All the matrix is doing is setting each component of the output (color, point in space, etc.) proportionally to one or more components in the input.  This is why scaling factors are on the diagonal rather than filling the matrix--each component is set proportionally only to itself.

Basically it's a weighted average in N dimensions.  It's quite elegant.

I also now understand why 3D matrices are 4x4 as well: In order for translation to work, you need to have a known constant factor somewhere.  So you have the W coordinate, which is always 1 so that you can express translation as a product of it (W=1 * tx/ty/tz).

Why could I not find this layman's perspective on matrices anywhere else?  Everywhere I looked showed the mathematical theory behind them, but not much else.  If I had seen the description above, I would have understood immediately and then the math would have made more sense.
  • Last Edit: April 30, 2016, 10:15:11 am by Lord English
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: I finally understand matrices
Reply #1
Yeah, they are nifty. I took Linear Algebra in college and got a decent understanding, but I wasn't fully able to understand and appreciate them until I used them in code. Many 3D game engines like Unity use them to make sense of the world. It's really convenient too.

I'm actually excited a bit that matrices are going to be put into a proper Sphere API. :)
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: I finally understand matrices
Reply #2
In 2013 I had to implement matrix multiplication from scratch for a college assignment and was reading a Microsoft article on software-based 3D rendering at around the same time. I was familiarizing myself with byuu's phoenix GUI wrapper and took the opportunity to implement the MS examples in the software canvas with much success. That's when matrix maths clicked for me and I easily passed Linear/Matrix Algebra a semester or two later.

Re: I finally understand matrices
Reply #3
All my teachers had skipped over them in high school, and I never quite got to the college classes that would have them (linear algebra, etc) before I switched away from a math major.

On the other hand, I've learned all about matrix math at my new job (along with beziers and nurbs curves). Seeing them in action actually makes them quite a lot easier to understand than any explanation I ever came across. Sadly, even in games it seems that people only explain them using mathematical notation, which is not helpful unless you basically already fully understand them in a mathematical context.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: I finally understand matrices
Reply #4
Yeah, all I would have needed to understand what a transformation matrix was doing was for someone to say "weighted average in 3 dimensions" (not a fully accurate description, but close enough) and everything would have clicked.  But as you said, the only explanation you ever get is the mathematical theory behind it, confusing equations and all.  This kind of thing, incidentally, is what makes Wikipedia practically useless for learning anything new in math - everything is explained as though you're already basically a math wiz.

Interestingly enough, it was playing with color matrices that made me understand what 3D coordinate transforms were doing.  I guess because RGB components are readily understood to be quantities (coordinates... not so much), so it's a lot easier to understand what the multiplication is really doing.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub