[Cuis] Array2D newSize:
Juan Vuletich
juan at jvuletich.org
Thu Jul 16 08:14:17 CDT 2015
Hi Dan,
On 7/15/2015 12:54 PM, Dan Norton wrote:
> Maybe it's my dyslexia, but isn't this backward?
It is not you. It is the unfortunate fact that 2 conventions exist for this
> "Array2D newSize: 2 at 3" produces an array with 3 rows and 2 columns:
> | nil nil |
> | nil nil |
> | nil nil |
Yes. 2 at 3 is a point with x=2 and y=3. x is usually regarded as the
horizontal coordinate and y as the vertical coordinate. This is the
universal convention for pixels in Displays and Forms and for
mathematical points in the Cartesian plane.
> IMO it should be:
> | nil nil nil |
> | nil nil nil |
Yes. That's why Array2D class also has #height:width: and #width:height.
Matrices are usually accessed with i, j; where i is the row and j the
column. Array2D instances have #x:y: and #i:j: , and the order of the
arguments is swapped. So you can pick the convention that bests suits
what you are doing.
> For example, in Squeak, "MatrixTransform2x3 identity" produces:
> MatrixTransform2x3(
> 1.0 0.0 0.0
> 0.0 1.0 0.0
> )
Yes. It uses the matrix convention.
> Please correct me if I'm wrong.
>
> - Dan
>
HTH.
In addition to all this Matrices have origin (1,1), while the
mathematical plane and Forms have origin (0,0). But Matrices and Forms
have the origin at the topLeft, while the mathematical plane has the
origin at the bottomLeft (or at the center if you allow negative
coordinates).
To make things even more complicated, when mapping the mathematical
plane to a Form, you can map integer numbers in the plane to the center
of the pixels (the convention that makes most sense to me) or to pixel
corners (as Squeak / Cuis Rectangles do).
All unnecesary complications, but that we can't avoid.
Cheers,
Juan Vuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150716/e4446f52/attachment-0004.html>
More information about the Cuis
mailing list