ZX News #03
28 февраля 1997

Rotating pictures - rotate the image, the algorithm with respect to a given center.

<b>Rotating pictures</b> - rotate the image, the algorithm with respect to a given center.
(C) 1997 Bob Klubov



          Down with the horizontal!



  This article will talk about two programs that are available 
in the annex, which intended to rotate the image

respect to a given center at a certain angle. Tackle this 
problem prompted me that the majority of all labels (names, 
games, and megadem Other logos) are arranged horizontally or 
vertically, which is already nabilo mouth. Konechnozhe a 
spatial position due to the simplicity drawing, but you need to 
improve the design of their programs. Can not be dismissed, and 
the fact that the coloring Rotate image starts a war for life 
and death with attributes. Well there can not help, twist 
yourself as you want! Still need to stay on here any nuance: 
when rotate the image angle is not a multiple

90 degrees there is insignificant
image distortion. The reason for these distortions can be 
understood if we look 

  1 and read on.

  For example, we turn

  pixel 1 on the peak
  Xela 0 to 45 degrees Po

  clockwise in the pixel

  2. Since the pixel element
  tary element image
  tion, is square, with two of its sides horizontally, and two 
strictly vertical, then pixels 0 and 1 fall strictly within 
their "Hot spot", but the pixel 2, all sides are inclined at 45 
degrees and so there issue arises: which of the four "hole" 
should be placed. In Ideally, the pixel 2 would need to

some way to leave such a
He is a (square, rotated 45 degrees).

  So, in the annex to the magazine, there are two programs:
Rotat0.0 and Rotat1.0. First
of them work faster, but
not very good quality, the second slower
(Very slowly), but with higher quality. The results of both 
programs are shown in Figure 2 (2a rotated by 45

degrees with Rotat0.0 - 2b, with
Rotat1.0 - Fig. 2c).


  And now I try to tell about the program algorithm and why 
they are, strictly speaking, two. Both programs work the same 
externally: 

 1. asked: to show whether the directory?
 2. Enter a name and upload pictures by

    address 16384 and length 6144;
 3. using the keys Q, A, O, P and M

    indicates the center of rotation;
 4. Enter the rotation angle (counterclockwise

    arrows);
 5. Enter a name for the shipment of "rotated
    On "image;
 6. rotate the image;
 7. shipment of the pictures.


  Algorithms also differ somewhat.
And the only difference itself rotate.
In Rotat0.0 rotation is as follows
as follows:

 1. read into memory the coordinates of all

    illuminated points (nx, ny);
 2. clear screen;
 3. each point is rotated by a
    given angle around the center and press
    is the new coordinate (rx, ry).


  But the image with this algorithm is obtained by it to be. 
The explanation for this, I I can not find, so I had to use a 
different algorithm that works as it were, on the contrary. In 
Rotat1.0 rotation is as follows:


 1. take the coordinate of the lower-left point

    (Nx, ny);
 2. rotate the inverse of the
    this, with new coordinates

    (Rx, ry);
 3. Consider, if marred by pixel to
    ordinate (rx, ry). If marred, then

    set point coordinate (nx, ny);
 4. Go to the next point and the transition

    paragraph 1, until all will go to

    point of the screen, and their 256 * 176 pieces.


  When using this algorithm, the image gets better. Longer 
opening hours of the second algorithm due to the fact that it 
loops through all pixels of the screen, not just overexposed, 
as in Rotat0.0. 


                   Yet it should be noted

                   that both programs on

                   97% written in the Basie
                   Ke and in consequence it
                   On strongly inhibit. I

                   not friends with Calculator
                   torus Spectrum, which is why
                   to write all of

                   BASIC.



  Recently, rumors about
that many teams write graphical editors. So try to realize the 
function of image rotation in their works, it is very 
necessary. 


  Yes, I almost forgot: during the rotation
Image program Rotat0.0, new
built directly in the time of turning the program Rotat1.0, new 
built in memory and only at the end is thrown on the screen.

Time of the first program depends on the
number of illuminated pixels, and the time
of the second - always about the same: a little over an hour 
(who taught you so swear!).



  At this time, our air has come to
end. Until next time



  ____________________________________




Other articles:

From the Author - Innovation in the viewer.

Anketirivanie - Answer the 10 questions and takes you to the encyclopedia "SPECCY individuals."

Review magazine - On journals: SPECTROFON, ZX-FORMAT, ADVENTURER, SPECCY, FAULTLESS.

My dog - Fox Terrier - dreams and reality.

ANDY CAPP - Game Description ANDY CAPP.

WEC LE MANS - A small opening WEC LE MANS.

RED HAWK - description of Game RED HAWK.

Rotating pictures - rotate the image, the algorithm with respect to a given center.

Smoothing Images - An algorithm of smoothing of static images.

morph pictures - The effect of soft peretikaniya one image to another.

Last Starfighter - Presentation Lugansk Game - THE LAST STAR FIGHER.

As you know Spectrum - test "How well do you know Spectrum".

Abbreviations - the standard abbreviations (which everyone should know).

War of Fennec - one-day chronicle of war (Game Section Tolkinovskogo Society in action).

RPG - A bit of role-playing games.

clever ideas - Smart thoughts of great men.

Letters from readers - The first responses from readers of the Journal: A Novel Rublachenko, Vyacheslav Sadonenko, Impetus Led.

Report for the year - A year has passed ... since the first issue.

Coming soon - what awaits you in the 4 th issue.

Application - Smagli-3 demo, Andy Capp, Red Hawk!, SGLEXMP, Crystal Dream members in East Ucrainian State University, Screen Editor, Rotate, Morph, Last Star Fighter, UFO-2 Help.

Advertising - Advertising and announcements ...

Authors - The authors of the magazine.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Fun - about hackers.
ZXNet - What is ZXNet: network spektrumistov - Realschikov.
solid jokes - The Adventures of Pinocchio.

В этот день...   23 November