frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Matrices can be your Friends

https://www.sjbaker.org/steve/omniv/matrices_can_be_your_friends.html
35•todsacerdoti•3h ago

Comments

pavlov•2h ago
Part of a fairly old OpenGL tutorial, about 2002.

The age doesn't affect this matrix part, but just FYI that any specific APIs discussed will probably be out of date compared to modern GPU programming.

shiandow•1h ago
I don't think there's any mathematical reason to lay out the elements in memory that way. Sure given no context I would probably use i = row + n col as index, but it doesn't really matter much me.

If I had to pick between a matrix being a row of vectors or a column of covectors, I'd pick the latter. And M[i][j] should be the element in row i column j, which is nonnegotiable.

globalnode•1h ago
yellow text on green background... my eyes!
stevemk14ebr•51m ago
Yea this is horrendous. Not reading this
Viliam1234•1h ago
> Mathematicians like to see their matrices laid out on paper this way (with the array indices increasing down the columns instead of across the rows as a programmer would usually write them).

Could a mathematician please confirm of disconfirm this?

I think that different branches of mathematics have different rules about this, which is why careful writers make it explicit.

gus_massa•1h ago
Mathematician here. I never heard that.

(In many branches the idea is that you care about the abstract linear transformation and properties instead of the dirty coefficients that depend on the specific base. I don't expect a mathematician to have an strong opinion on the order. All are equivalent via isomorphism.)

account42•54m ago
Not a mathematician, but programmers definitely don't agree on whether matrices should be row-major or column-major.
vintermann•33m ago
I'm surprised we even agree that they should be top-down.
getnormality•1h ago
People must get taught math terribly if they think "I don't need to worry about piles of abstract math to understand a rotation, all I have to do is think about what happens to the XYZ axes under the matrix rotation". That is what you should learn in the math class!

Anyone who has taken linear algebra should know that (1) a rotation is a linear operation, (2) the result of a linear operation is calculated with matrix multiplication, (3) the result of a matrix multiplication is determined by what it does to the standard basis vectors, the results of which form the columns of the matrix.

This guy makes it sound like he had to come up with these concepts from scratch, and it's some sort of pure visual genius rather than math. But... it's just math.

vasco•53m ago
Math is just a standardized way to communicate those concepts though, it's a model of the world like any other. I get what you mean, but these intuitive or visualising approaches help many people with different thinking processes.

Just imagine that everyone has equal math ability, except the model of math and representations of mathematical concepts and notation is more made for a certain type of brains than others. These kind of explanations allow bringing those people in as well.

omnicognate•33m ago
A lot of people who find themselves having to deal with matrices when programming have never taken that class or learned those things (or did so such a long time ago that they've completely forgotten). I assume this is aimed at such people, and he's just reassuring them that he's not going to talk about the abstract aspects of linear algebra, which certainly exist.

I'd take issue with his "most programmers are visual thinkers", though. Maybe most graphics programmers are, but I doubt it's an overwhelming majority even there.

foofoo12•16m ago
> most programmers are visual thinkers

I remember reading that there's a link between aphantasia (inability to visualize) and being on the spectrum.

Being an armchair psychologist expert with decades of experience, I can say with absolute certainty that a lot of programmers are NOT visual thinkers.

voidUpdate•3m ago
Do you have anything I can read about that? I'm definitely on the spectrum and have whatever the opposite of aphantasia is, I can see things very clearly in my head
zelphirkalt•32m ago
When I was studying and made the mistake of choosing 3D computer graphics as a lecture, I remember some 4x4 matrix that was used for rotation, with all kinds of weird terms in it, derived only once, in a way I was not able to understand and that didn't relate to any visual idea or imagination, which makes it extra hard for me to understand it, because I rely a lot on visualization of everything. So basically, there was a "magical formula" to rotate things and I didn't memorize it. Exam came and demanded having memorized this shitty rotation matrix. Failed the exam, changed lectures. High quality lecturing.

Later in another lecture at another university, I had to rotate points around a center point again. This time found 3 3x3 matrices on wikipedia, one for each axis. Maybe making at least seemingly a little bit more sense, but I think I never got to the basis of that stuff. Never seen a good visual explanation of this stuff. I ended up implementing the 3 matrices multiplications and checked the 3D coordinates coming out of that in my head by visualizing and thinking hard about whether the coordinates could be correct.

I think visualization is the least of my problems. Most math teaching sucks though, and sometimes it is just the wrong format or not visualized at all, which makes it very hard to understand.

dgacmu•25m ago
You can do rotation with a 3x3 matrix.

The first lecture was using a 4x4 matrix because you can use it for a more general set of transformations, including affine transforms (think: translating an object by moving it in a particular direction).

Since you can combine a series of matrix multiplications by just pre-multiplying the matrix, this sets you up for doing a very efficient "move, scale, rotate" of an object using a single matrix multiplication of that pre-calculated 4x4 matrix.

If you just want to, e.g., scale and rotate the object, a 3x3 matrix suffices. Sounds like your first lecture jumped way too fast to the "here's the fully general version of this", which is much harder for building intuition for.

Sorry you had a bad intro to this stuff. It's actually kinda cool when explained well. I think they probably should have started by showing how you can use a matrix for scaling:

    [[2, 0, 0],
     [0, 1.5, 0],
     [0, 0, 1]]
for example, will grow an object by 2x in the x dimension, 1.5x in the y dimension, and keep it unchanged in the z dimension. (You'll note that it follows the pattern of the identity matrix). The derivation of the rotation matrix is probably best first derived for 2d; the wikipedia article has a decentish explanation:

https://en.wikipedia.org/wiki/Rotation_matrix

kevindamm•3m ago
The first time I learned it was from a book by LaMothe in the 90s and it starts with your demonstration of 3D matrix transforms, then goes "ha! gimbal lock" then shows 4D transforms and the extension to projection transforms, and from there you just have an abstraction of your world coordinate transform and your camera transform(s) and most everything else becomes vectors. I think it's probably the best way to teach it, with some 2D work leading into it as you suggest. It also sets up well for how most modern game dev platforms like godot, unity, unreal deal with coordinates.
zkmon•40m ago
There are a lot more ways to look at and understand these mysterious beasts called matrices. They seem to represent a more fundamental primordial truth. I'm not sure what it is. Determinant of a matrix indicate the area of or volume spanned by its component vectors. Complex matrices used in Fourier transform are beautiful. Quantum mechanics and AI seem to be built on matrices. There is hardly any area of mathematics that doesn't utilize matrices as tools. What exactly is a matrix? Just a grid of numbers? don't think so.
ljlolel•28m ago
Take linear algebra
card_zero•19m ago
OK, now what?
bmacho•6m ago
A matrix is just a grid of numbers.

A lot of areas use use grid of numbers. And matrix theory actually incorporates every area that uses grids of numbers, and every rule in those areas.

For example the simplest difficult thing in matrix theory, matrix multiplication is an example for this IMO. It looks really weird in the context of grid of numbers, and its properties seem incidental, and the proofs are complicated. But matrix multiplication is really simple and natural in the context of linear transformations between vector spaces.

The Sveriges Riksbank Prize in Economic Sciences in Memory of Alfred Nobel 2025

https://www.nobelprize.org/prizes/economic-sciences/2025/summary/
28•k2enemy•2h ago•13 comments

Spotlight on pdfly, the Swiss Army knife for PDF files

https://chezsoi.org/lucas/blog/spotlight-on-pdfly.html
138•Lucas-C•4h ago•42 comments

Matrices can be your Friends

https://www.sjbaker.org/steve/omniv/matrices_can_be_your_friends.html
35•todsacerdoti•3h ago•20 comments

Show HN: SQLite Online – 11 years of solo development, 11K daily users

https://sqliteonline.com/
4•sqliteonline•38m ago•2 comments

More random home lab things I've recently learned

https://chollinger.com/blog/2025/10/more-homelab-things-ive-recently-learned/
32•otter-in-a-suit•1w ago•3 comments

Clockss: Digital preservation services run by academic publishers and libraries

https://clockss.org/
22•robtherobber•5d ago•6 comments

American solar farms

https://tech.marksblogg.com/american-solar-farms.html
94•marklit•3h ago•71 comments

Wireguard FPGA

https://github.com/chili-chips-ba/wireguard-fpga
566•hasheddan•20h ago•137 comments

US Junk Bonds Post Worst Losses in Six Months, Spreads Widen

https://www.bloomberg.com/news/articles/2025-10-13/us-junk-bonds-post-worst-losses-in-six-months-...
35•zerosizedweasle•1h ago•21 comments

Putting a dumb weather station on the internet

https://colincogle.name/blog/byo-weather-station/
77•todsacerdoti•5d ago•15 comments

Some graphene firms have reaped its potential but others are struggling

https://www.theguardian.com/business/2025/oct/13/lab-to-fab-are-promises-of-a-graphene-revolution...
33•robaato•4h ago•12 comments

LaTeXpOsEd: A Systematic Analysis of Information Leakage in Preprint Archives

https://arxiv.org/abs/2510.03761
32•oldfuture•4h ago•11 comments

Switch to Jujutsu Already: A Tutorial

https://www.stavros.io/posts/switch-to-jujutsu-already-a-tutorial/
20•birdculture•4h ago•14 comments

Modern Linux tools

https://ikrima.dev/dev-notes/linux/linux-modern-tools/
89•randomint64•3h ago•75 comments

Tauri binding for Python through Pyo3

https://github.com/pytauri/pytauri
126•0x1997•5d ago•34 comments

Making regular GPS ultra-precise

https://norwegianscitechnews.com/2025/10/making-regular-gps-ultra-precise/
21•giuliomagnifico•6d ago•21 comments

Jeffrey Hudson the Court Dwarf of the English Queen Henrietta Maria of France

https://en.wikipedia.org/wiki/Jeffrey_Hudson
30•daverol•5d ago•11 comments

Ask HN: What are you working on? (October 2025)

265•david927•17h ago•725 comments

MicroPythonOS – An Android-like OS for microcontrollers

https://micropythonos.com
131•alefnula•4d ago•35 comments

Nobel Prize in Economic Sciences 2025

https://www.nobelprize.org/prizes/economic-sciences/2025/popular-information/
8•pykello•3h ago•1 comments

Two Paths to Memory Safety: CHERI and OMA

https://ednutting.com/2025/10/05/cheri-vs-oma.html
9•yvdriess•3h ago•6 comments

Control your Canon Camera wirelessly

https://github.com/JulianSchroden/cine_remote
3•nklswbr•5d ago•0 comments

Show HN: Baby's first international landline

https://wip.tf/posts/telefonefix-building-babys-first-international-landline/
164•nbr23•4d ago•46 comments

gsay: Fetch pronunciation of English vocabulary from Google

https://github.com/pvonmoradi/gsay
7•pooyamo•3h ago•0 comments

MPTCP for Linux

https://www.mptcp.dev/
13•SweetSoftPillow•3h ago•2 comments

HTTP3 Explained

https://http3-explained.haxx.se
106•weinzierl•6h ago•48 comments

Three ways formally verified code can go wrong in practice

https://buttondown.com/hillelwayne/archive/three-ways-formally-verified-code-can-go-wrong-in/
150•todsacerdoti•1d ago•90 comments

Emacs agent-shell (powered by ACP)

https://xenodium.com/introducing-agent-shell
195•Karrot_Kream•16h ago•26 comments

Bird photographer of the year gives a lesson in planning and patience

https://www.thisiscolossal.com/2025/09/2025-bird-photographer-of-the-year-contest/
154•surprisetalk•1w ago•33 comments

We need (at least) ergonomic, explicit handles

https://smallcultfollowing.com/babysteps/blog/2025/10/13/ergonomic-explicit-handles/
10•emschwartz•1h ago•0 comments