.pio/libdeps/m5stack-core2/M5Core2/src/utility/Sprite.cpp
void TFT_eSprite::getRotatedBounds(float sina, float cosa, int16_t w, int16_t h, int16_t xp, int16_t yp,
                                   int16_t *min_x, int16_t *min_y, int16_t *max_x, int16_t *max_y)
{
  w -= xp; // w is now right edge coordinate relative to xp
  h -= yp; // h is now bottom edge coordinate relative to yp

  // Calculate new corner coordinates
  int16_t x0 = -xp * cosa - yp * sina;
  int16_t y0 =  xp * sina - yp * cosa;

  int16_t x1 =  w * cosa - yp * sina;
  int16_t y1 = -w * sina - yp * cosa;

  int16_t x2 =  h * sina + w * cosa;
  int16_t y2 =  h * cosa - w * sina;

  int16_t x3 =  h * sina - xp * cosa;
  int16_t y3 =  h * cosa + xp * sina;

  // Find bounding box extremes, enlarge box to accomodate rounding errors
  *min_x = x0-2;
  if (x1 < *min_x) *min_x = x1-2;
  if (x2 < *min_x) *min_x = x2-2;
  if (x3 < *min_x) *min_x = x3-2;

  *max_x = x0+2;
  if (x1 > *max_x) *max_x = x1+2;
  if (x2 > *max_x) *max_x = x2+2;
  if (x3 > *max_x) *max_x = x3+2;

  *min_y = y0-2;
  if (y1 < *min_y) *min_y = y1-2;
  if (y2 < *min_y) *min_y = y2-2;
  if (y3 < *min_y) *min_y = y3-2;

  *max_y = y0+2;
  if (y1 > *max_y) *max_y = y1+2;
  if (y2 > *max_y) *max_y = y2+2;
  if (y3 > *max_y) *max_y = y3+2;

}
/***************************************************************************************
** Function name:           rotatedBounds
** Description:             Get bounding box of a rotated Sprite wrt pivot
*************************************************************************************x*/
Function name:           rotatedBounds
Description:             Get bounding box of a rotated Sprite wrt pivot
x
Function name : rotatedBounds Description : Get bounding box of a rotated Sprite wrt pivot x
void TFT_eSprite::getRotatedBounds(float sina, float cosa, int16_t w, int16_t h, int16_t xp, int16_t yp,
                                   int16_t *min_x, int16_t *min_y, int16_t *max_x, int16_t *max_y)
{
  w -= xp; 
  h -= yp; 
  int16_t x0 = -xp * cosa - yp * sina;
  int16_t y0 =  xp * sina - yp * cosa;
  int16_t x1 =  w * cosa - yp * sina;
  int16_t y1 = -w * sina - yp * cosa;
  int16_t x2 =  h * sina + w * cosa;
  int16_t y2 =  h * cosa - w * sina;
  int16_t x3 =  h * sina - xp * cosa;
  int16_t y3 =  h * cosa + xp * sina;
  *min_x = x0-2;
  if (x1 < *min_x) *min_x = x1-2;
  if (x2 < *min_x) *min_x = x2-2;
  if (x3 < *min_x) *min_x = x3-2;
  *max_x = x0+2;
  if (x1 > *max_x) *max_x = x1+2;
  if (x2 > *max_x) *max_x = x2+2;
  if (x3 > *max_x) *max_x = x3+2;
  *min_y = y0-2;
  if (y1 < *min_y) *min_y = y1-2;
  if (y2 < *min_y) *min_y = y2-2;
  if (y3 < *min_y) *min_y = y3-2;
  *max_y = y0+2;
  if (y1 > *max_y) *max_y = y1+2;
  if (y2 > *max_y) *max_y = y2+2;
  if (y3 > *max_y) *max_y = y3+2;
}
void TFT_eSprite :: getRotatedBounds ( float sina , float cosa , int16_t w , int16_t h , int16_t xp , int16_t yp , int16_t * min_x , int16_t * min_y , int16_t * max_x , int16_t * max_y ) { w -= xp ; h -= yp ; int16_t x0 = - xp * cosa - yp * sina ; int16_t y0 = xp * sina - yp * cosa ; int16_t x1 = w * cosa - yp * sina ; int16_t y1 = - w * sina - yp * cosa ; int16_t x2 = h * sina + w * cosa ; int16_t y2 = h * cosa - w * sina ; int16_t x3 = h * sina - xp * cosa ; int16_t y3 = h * cosa + xp * sina ; * min_x = x0 - 2 ; if ( x1 < * min_x ) * min_x = x1 - 2 ; if ( x2 < * min_x ) * min_x = x2 - 2 ; if ( x3 < * min_x ) * min_x = x3 - 2 ; * max_x = x0 + 2 ; if ( x1 > * max_x ) * max_x = x1 + 2 ; if ( x2 > * max_x ) * max_x = x2 + 2 ; if ( x3 > * max_x ) * max_x = x3 + 2 ; * min_y = y0 - 2 ; if ( y1 < * min_y ) * min_y = y1 - 2 ; if ( y2 < * min_y ) * min_y = y2 - 2 ; if ( y3 < * min_y ) * min_y = y3 - 2 ; * max_y = y0 + 2 ; if ( y1 > * max_y ) * max_y = y1 + 2 ; if ( y2 > * max_y ) * max_y = y2 + 2 ; if ( y3 > * max_y ) * max_y = y3 + 2 ; }
Function name:           rotatedBounds
Description:             Get bounding box of a rotated Sprite wrt pivot
x
Function name : rotatedBounds Description : Get bounding box of a rotated Sprite wrt pivot x
// w is now right edge coordinate relative to xp // h is now bottom edge coordinate relative to yp // Calculate new corner coordinates // Find bounding box extremes, enlarge box to accomodate rounding errors