play with image rotations in degrees ILI9341_t3n

jean

Active member
sorry for english translation online
I'm currently having fun playing with ILI9341_t3n on a 240 x 320px screen, I shift an image of width X and height Y from left to right and from top to bottom see diagonally.
I would like to make rotations with the axis of rotation positioned on the screen so random on the image.

I understood that it was necessary to make a matice, to define the point of arrival and to go to seek the corresponding point in the starting image to avoid the holes.

do you think this can be interesting?:rolleyes:
 
hello grease_lighting, yes it can do a lot of calculation ... probably for this reason nobody does it but I told myself to see the speed of this library and the asynchronous mode ... why not.
Actually I have an image of 720X866 pixels which moves without any problem, see even too fast
 
Hello MarkT ,
thank you for this information, I did not know, I will watch it with passion this weekend, moreover, with this method, we must be able to keep a certain fluidity.
 
Hello, here is my little help function of the web but I have two problems.
1 / I have the impression that it does not turn degree by degree.
2 / how should I proceed to read the image I have in the program?
Code:
void rotation_image(){
    int largeur = 720 / 2; //taille de limage et centre
    int hauteur = 866 / 2; //taille de limage et centre
    int x =0;
    int y =0;
    int x2 = 0;
    int y2 = 0;
    double anglevariable=0;
    double sin2 = 0;
    double cos2 = 0;
  for(int i=0; i<360;i++){//faire une rotation de 360 degres
  display.fillScreen(BLACK); 
  //Serial.println(i);
anglevariable=i;
sin2 = sin(-anglevariable);
cos2 = cos(-anglevariable);
for(int x = 0; x < 720; x++) {
  for(int y = 0; y < 866; y++) {
    
   x2 = x - largeur;
   y2 = y - hauteur;
    int nouveaux = (int)round((cos2 * x2 - sin2 * y2) + largeur);
    int nouveauy = (int)round((sin2 * x2 + cos2 * y2) + hauteur);

    if(nouveaux >= 0 && nouveaux < 720 && nouveauy >= 0 && nouveauy < 866) {
      display.drawPixel(nouveaux,nouveauy,RED);
      //display.writeRect(0, 0, 720, 866, (uint16_t*)ecran2); ???????
         } else {
      display.drawPixel(nouveaux,nouveauy,ORANGE);
     
     }
   }
  }delay(1000);
 }
}
or how to implement the function which is in pascal?
https://www.ocf.berkeley.edu/~fricke/projects/israel/paeth/rotation_by_shearing.html
 
It doesn't rotate by degrees because the trig functions you are calling take their input in radians. Try anglevariable = i * PI / 180.;

As for reading a texture, perhaps it's easier to point you at some code which does that. Every 2 seconds that swaps between nearest-neighbour and bilinear sampling. I did everything using fixed-point maths because that code targets AVR, but on Teensy 4 I would probably use floats.

By multiplying the rotation matrix by a scaling factor, you get what is often called a rotzoomer. Searching that term may lead to articles that help with your understanding.

And, yes, I find this kind of thing very interesting. :D
 
Hi sutaburosu,
thank you for your help
yes indeed, it works better in degrees rather when radian, that's already a good thing:rolleyes:
Mais je suis encore loin du resultat rechercher, il y a encore du boulot mais peut de temps de libre en ce moment.
 
Back
Top