I have just noticed something that I think has been annoying me on a…  Sally's Journal
[Recent Entries][Archive][Friends][Profile]
12:12 pm
[Link]  I have just noticed something that I think has been annoying me on a subconcious level for years.
If you write things in cartesian coordinates, you write (x,y)
But if you write things in matrix notation, you write (row, column) and if you write out your matrix in a grid... the row number will increase as you go down the grid, and look an awful lot like a y coordinate, and the column number will increase as you go across the grid, and look an awful lot like an x coordinate. So you're almost writing (y,x)
My brain hurts.

 
  From:  pjc50 
Date:  April 5th, 2006 11:31 am (UTC) 

   (Link) 

That too has annoyed me for years, especially in the context of graphics versus text programming  text coordinates are usually (row, column).  From:  atreic 
Date:  April 5th, 2006 11:47 am (UTC) 

   (Link) 

Yes. I was trying to write an array that said if a square had a tile in it or not, and the mapping from the x,y coordinates of the squares to the members of the array was the thing that finally made it click.  From:  smhwpf 
Date:  April 5th, 2006 11:32 am (UTC) 

   (Link) 

Do you know, that had never occurred to me, but it's true! And it probably is one of the things that makes playing with matrix formulae that bit trickier.
For bonus headhurt  I wonder if you'd look at it differently if you wrote in a semitic language (Hebrew, Arabic, etc.) that reads from right to left? Ah.... *that's* why I keep persistently writing it the wrong way round....  From:  phlebas 
Date:  April 5th, 2006 11:37 am (UTC) 

   (Link) 

Or even (ny,x) !!! Don't forget that the 'origin' of matrices is row 1, column 1 not (0,0). Generally it doensn't bother me. It is simply a typing problem. All coordinates have an associated frame which they are relative to that can be expressed notationally. For example in my line of work we generally have world, view and screen spaces which we keep track of by a) prepending w/v/s to the variable [1] and b) making sure that lines which do wFoo = vBar are looked at very carefully and documented.
[1] Horribly Hungarian.  From:  atreic 
Date:  April 5th, 2006 12:08 pm (UTC) 

   (Link) 

This array seems to think its origin is [0][0]... The origin or arrays in computer science[1] is 0 but mathematically one usually has the first element being 1. So the first element of a matrix $A$ with elements $a_{ij}$ is $a_{11}$ but the first element of a Cstyle 2d array float A[N][M] is A[0][0]. Further the element $a_{ij}$ is the jth element in the ith row as is A[i][j] in programming[2].
[1] Not for FORTRAN. It uses the mathematical convention. [2] Again, not for FORTRAN. Whoops. Correct my last statement there. Wonderfully hungarian! OK, if you declare them as different types (wint, vint, etc), your editor would *hopefully* flag it in some way, and maybe even your compiler check if you've been anal enough, but I think that extra letter is surely worth it to be able to see which the variable is  you can't rememeber all the time, and every time you get muddled you lose minutes of productivity :)  From:  simont 
Date:  April 5th, 2006 12:15 pm (UTC) 

   (Link) 

It is a pain, that. I tend to see matrices in particular as a special case: matrices are written as HxW and coordinates within them as (r,c) because that way the nearby dimensions cancel during multiplication: a 3x4 matrix multiplied by a 4x5 one gives a 3x5 one, and an element c_{ij} of the result is given by the sum of a_{ik}b_{kj} over all k. If the dimensions and coordinates were written in x,y order, all that would look much weirder.
(You could of course solve this problem by reversing the conventions of matrix multiplication at the same time, but I don't think the inventors of matrices can reasonably be blamed for not realising that the first way round that sprang to mind would give rise to this confusion. It's a shame, but it's too entrenched to change really.)
Everything other than matrices really ought to be x,y, on the grounds that one should follow a nearuniversal standard unless there's a specific good reason not to. A few things in computing get this wrong, and they annoy me a lot more than matrices because they have no excuse. We could all change over on the same date we switch the playing card suite order and side of the road we drive on :)
But yes, what he said. Though I'm not sure if you *could* rearrange everything to make all coordinates be in that order, or if you end up with some cases that don't work out as well.
Everything other than matrices really ought to be x,y, on the grounds that one should follow a nearuniversal standard unless there's a specific good reason not to.
I can't decide. Probably. Though there's also something to be said for just always specifying. And of course, if your drawing these planes on a computer, you typically prefer pixels[y][x] at least internally, because then your raster lines are stored together internally.
*Actually*  that is somewhat similar to matrices.
Let capital letters be matrices, small letters be column vectors, and subscripts be y,x indices. Vectors and matrices dimension n or nxn.
You often think of A as an function A: v > Av. But you can usefully break this down into n functions, each of which is a row of A, a row vector, which takes v to one element of Av.
If your y subscript is first, you can write the rows as A_{1}: v > (Av)_{1} by leaving off the x subscript.
If you reversed the order, you'd have to say A_{(.),1} to mean the row vector, or have the function be a post multiplier of a row vector by the matrix, allowing column vectors to be the components. Matrices are broken. Just transpose them and it'll be fine...
Of course, there's then the problem with lefthanded vs righthanded coordinate systems (i.e. does y go up or down?) Hell, yeah.
I recently implemented the graphics subsystem for our product. I used cartesian coordinates, with y increasing up the screen.
Now everyone's complaining that they want to lay things out down the screen, so it's having to be changed.
Fortunately, I wrote most of the lowlevel code properly and it's completely agnostic about this, so the change is tidier than it might have been. I thought everyone knew that (0,0) was the topleft corner of the screen...? ;) Glad I'm not the only one who struggles with that :)  From:  arnhem 
Date:  April 5th, 2006 03:12 pm (UTC) 

   (Link) 

A colleague has been getting very irritated by the fact that in his area, the measurement of change of thickness in a lump of stuff you're compressing is (by convention) positive if it's been squashed ... I KNEW I shouldn't have clicked to read the comments ... I didn't even understand matrices at GCSE and now my head has exploded  more with a whimper than a bang, I fear! When I first met matrices, this upset me a lot. I had to mentally store that matrices had their coordinates "the wrong way round".
However, I've now learnt to treat the two systems separately. Cartesian is (x,y), and has its origin in 'the bottom left'. Matrices are (y,x) and have their origins in 'the top left'. And as I'm a C++/C# developer by trade, they all start from (0,0). :)  From:  cowe 
Date:  April 5th, 2006 11:41 pm (UTC) 

   (Link) 

Meh, it's just a rotation. Lie on your side. I remember in year 7 doing map references and latitude and longitude. My memory is that grid references are eastings then northings (so like cartesian coordinates, I think, but I might just be horribly confused) whereas you give latlong which is like matrices (from what you've said). I definitely remember them being different. It's liveable with; as is the fact that the mixer taps have hot and cold the other way round from the nonmixer taps in this house!  From:  jdc39 
Date:  April 6th, 2006 03:33 pm (UTC) 

   (Link) 

I try not to relate the two, though mainly because it took nearly 3 years of undergrad maths to figure out which matrix labels were which.
Every time I've had to code matrix multiplication up the trick is to just be consistent rather than know the convention, e.g. once I scribbled lots of code on paper which happened to be correct but when I began explaining it to someone I was instantly lost.
Because of the difficulty of matrix labels versus knowing Cartesian coordinates for over 10 years, I can't really connect them in my head. I'm okay with remembering row then column for matrices, but I hate looking at computer code dealing with matrices, as I'm never quite sure which way the arrays are specified. 
