Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

I am engaged on implementing the backend logic behind the classical tetris sport, and I am a bit confused on how a rotation is carried out. I perceive that you may apply a rotation matrix, however I nonetheless have some questions which might be maybe higher defined with an instance.

In my implementation, I take advantage of sq. matrices of 0s and 1s to characterize the form. e.g., I take advantage of a 4×4 matrix with a single row crammed to characterize the lengthy horizontal block:
$$
start{bmatrix}
1 & 1 & 1 & 1
0 & 0 & 0 & 0
0 & 0 & 0 & 0
0 & 0 & 0 & 0
finish{bmatrix}
$$

And for every block, I additionally maintain observe of the underside proper location of the 4×4 matrix relative to the situation of the sport board.

The query I’ve is, if you apply a rotation (on this case it will flip right into a vertical block), do you need to repair some heart? In that case, how is that this heart of rotation outlined?

e.g., I may outline the middle of rotation of the above as the highest left ingredient, so apply 90 diploma clockwise rotation would yield:

$$
start{bmatrix}
1 & 0 & 0 & 0
1 & 0 & 0 & 0
1 & 0 & 0 & 0
1 & 0 & 0 & 0
finish{bmatrix}
$$

However you would additionally make any of the opposite 15 components the middle of rotation, although it in all probability makes probably the most sense to make one of many 4 components of the unique block the middle of rotation. I believe the problem right here is that for the opposite 3 components, in case you make any of them the middle of rotation, a part of the rotated block goes to lie exterior the prevailing 4×4 window. So how is one thing like this prescribed in an implementation?

Alternatively you possibly can swap the indices as in Tetris – Rotations utilizing Linear Algebra (Rotation Matrices) with out utilizing a middle of rotation, however I am undecided which method makes probably the most sense. Swapping indices is actually a lot simpler to implement.

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *