Question about the second-dimensional index value in the array ??

Source: Internet
Author: User
Question about the second-dimensional index value in the array ?? Ask a weak question
For example, if there are two pictures in the upper and lower columns and three images of the same size are not listed, I would like to ask what is the first-dimensional index value and the second-dimensional index value of the second image object in the upper column?

Because the following code is displayed in the code of the connected game, it is a bit unclear about the basic knowledge of arrays.

// The index value of the object in the first dimension of the Piece [] [] array
Private int indexX;
// The second-dimensional index value of the object in the Piece [] [] array
Private int indexY;


Reply to discussion (solution)

0 and 1...

What you see is not the php code

Piece. setBeginX (piece. getIndexX () * imageWidth
+ Config. getBeginImageX ());
Piece. setBeginY (piece. getIndexY () * imageHeight
+ Config. getBeginImageY ());

For example, a two-column chart starts with the coordinate (0, 0), and the length and width of each image are 5,
In the code above, the x and y coordinates in the upper left corner of the second image are calculated as 0 and 15.

But the result should be 5 or 10.

No context, cannot be explained

Dizzy
1. are you talking about rows or columns? When you say "up and down", it feels like a row, but the coordinates behind it are like a vertical column.
2. subscripts are generally used to start from 0, that is (this is the serial number, which is different from the following coordinate to distinguish)
(0, 0) (0, 1 )...
(1, 0) (1, 1 )...
The above is a one-dimensional row, two-dimensional is a column; if one-dimensional is a column, two-dimensional is a row, the location map becomes
(0, 0) (1, 0 )...
(0, 1) (1, 1 )...
A few people like to start from 1.

If the upper left corner is the coordinates of [], [] is the upper left corner of (), and [] is ?? The position of the first and last columns is used here.

Sorry, it is the upper and lower lines. each line has three identical images. the length and width of each image are 5.

The position of the two-dimensional array on the coordinate is that the first image in the downlink is closely bound to the X and Y coordinates (the coordinates in the lower left corner of the image are ))

My question: What is the first-dimensional index value and the second-dimensional index value of the second image object in the uplink?

It is not clear because the index value of the second digit of the image object in the array in the following link code

// The index value of the object in the first dimension of the Piece [] [] array
Private int indexX;
// The second-dimensional index value of the object in the Piece [] [] array
Private int indexY;

When you press [y] [x] to organize
[0] [0] [0] [1] [0] [2]
[1] [0] [1] [1] [1] [2]

By [x] [y]
[0] [0] [1] [0] [2] [0]
[1] [0] [1] [1] [2] [1]

You can see that the origin is placed in the upper left corner of the array. Therefore, the image should also place the origin point in the upper left corner to facilitate analysis and computation.
If you place the image origin in the lower left corner
That is, the coordinate system has a vertical flip

What is the first-dimensional index value and the second-dimensional index value of the second image object in the uplink?

Is it 0 and 1?

Is 0 rows and 1 column

It is 0 1.

When you press [y] [x] to organize
[0] [0] [0] [1] [0] [2]
[1] [0] [1] [1] [1] [2]

By [x] [y]
[0] [0] [1] [0] [2] [0]
[1] [0] [1] [1] [2] [1]

The above section is not very clear. why?

When [y] [x] or [x] [y] is used as the organizational unit?

How to organize data is based on your needs
You can use x, y (columns, rows)
Y, x (row, column)

This question hasn't been clarified yet? I thought Xu could explain it to you

Coordinates are fixed x, y

However, the array subscript is determined by the person who writes the program. it can be m, n, or n, m (m indicates rows, n indicates columns)
The minimum value of m or n (that is, the subscript of the first row/column) is also set by the writer. during traversal, you must start from the minimum value.

If one dimension is a column and two dimension is a row, the location map is changed
(0, 0) (1, 0 )...
(0, 1) (1, 1 )...

By [x] [y]
[0] [0] [1] [0] [2] [0]
[1] [0] [1] [1] [2] [1]

Why is one-dimensional column and two-dimensional rows sorted in this order?

According to common sense, is a row or a column in one dimension?

Description by mathematical coordinates
X horizontal axis
Y axis
Coordinate point (x, y)

This is common sense!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.