Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's not a 3d matrix. It's a 3x3 matrix. To do 3d transformations you need a 4x4 matrix.



OK, then I'm confused about this:

"For example, a point in space is a 3×1 matrix. To transform it, you multiply it by a 3×3 transformation matrix."

It seems we're transforming a point in 3D space using a 3x3 matrix, no?


I am sorry for the confusion in my article. I should have probably clarified that this is a 2D point in a 2D space. To make the transformations work correctly you need to represent a 2D point as a 3x1 matrix. And if you want to perform the same in a 3D space, then a 3D point should be represented as a 4x1 matrix, where the last row is always 1.


As a sibling comment mentioned, translation is not linear so say you want to move your box a bit to the left. You can't do this by multiplication by any 2x2 matrix. This is because what you need is an affine transform and what you have is a linear transform. So you can scale things, rotate them and shear them (squish them along the diagonals) but what you can


...do is pop up a dimension, shear in that dimension, then project into your original dimension. This will make sense if we think of an example.

Say we're working in 2d and have a unit square starting at the origin and we want to translate it right by 1. This is not possible with any kind of matrix multiplication by a 2x2 matrix. That's easy to confirm if you just try it but trivially the lower right hand corner is on the origin and anything you multiply by zero is going to be zero. So any 2x2 matrix you multiply the coordinates of your square by is going to result in something where that point is still at the origin.

So instead what you do is pop your square up a dimension into 3D. So now you have a unit cube. If you do a shear of the unit cube by 1 in the x direction (which is a 3x3 matrix multiplication), you can take the projection ("shadow") of the top face of the cube to get back into 2D and you'll find it's where you wanted it (moved over by 1).

<meta-point: apologies - my original response seems to have been chopped in half. I didn't mean to submit in this form and I was in meetings etc so it's too old to edit now>




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: