If I understand the question, let's see if we can illustrate a generic solution that might be applicable to various situations.
Given the rectangular coordinates of a point rotated about an origin, what change in angle of rotation is needed/or allowed for a given constraint in the rectangular height coordinate?
x1 & y1 are the coordinates of starting point
y2 is the given height constraint for the rotated ending point
x2 & x3 are 2 possible x values for given y2 height constraint
a1 is the starting angle of rotation for point (x1, y1)
a2 & a3 are the 2 possible angles to give desired y2
Plan of attack: Use Pythagorean theorem & trigonometry
The length of the radius being rotated does not change, so per Pythagoras we can say:
x1^2 + y1^2 = x2^2 + y2^2 or x2 = sqrt(x1^2 + y1^2 - y2^2)
This gives us the new x2 value for the new desired y2 constraint.
Using trigonometric arctangent, we can determine the old angle of the x1,y1 vector & the new angle of the x2,y2 vector. We subtract the 2 angles to get the required rotation.
Of course there are complications..due to the situation & indicated by the square root function, for a given y2 there are 2 solutions or maybe none. So code must be added to check that the argument passed to sqrt is not negative & if not, then the sqrt result can also be negated to get a negative version. The following code demonstrates all of this & draws a picture similar to the one previously provided. Note that in a full implementation, checks must be added for the other corners, etc.
The A/D keys decrease/increase the height of the y2 constraint. The F/H keys decrease/increase the width of the object (i.e. x1)
Drawing the rotated object/sprite is left as an exercise for the reader.
Enjoy.
//////////////////////////////////////////////////////////////////////////////////////
// Project: Tutorial - Calculate rotation of shape to fill dimensional constraint
// Created: 2015-07-18
// Author: MARDONIX Marty Quire aka Uncle Martin, Tampa Florida
//////////////////////////////////////////////////////////////////////////////////////
// set window properties
SetWindowTitle( "Rotate to Achieve Desired Height" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
// Initialize geometry
BX_WIDE as float = 1.3 // Shape width
BX_HIGH as float = 1.0 // Shape height
BX_HIGH2 as float = 1.25 // Desired height
SCL as float = 300.0 // Scale factor
ORGX as float = 513.0 // Origin x
ORGY as float = 383.0 // Origin Y
do // loop until Escape
// Adjust desired target height due to rotation using keys
if (GetRawKeyState(65)) then BX_HIGH2 = BX_HIGH2+.001 // A
if (GetRawKeyState(68)) then BX_HIGH2 = BX_HIGH2-.001 // D
// Adjust width of shape using keys
if (GetRawKeyState(70)) then BX_WIDE = BX_WIDE+.001 // F
if (GetRawKeyState(72)) then BX_WIDE = BX_WIDE-.001 // H
// Determine coordinates of starting point based on height & width of shape
x1# = -.5 * BX_WIDE
y1# = .5 * BX_HIGH
// Determine desired y coordinate after rotation
y2# = .5 * BX_HIGH2
// if insoluble
if ((x1#^2 + y1#^2 - y2#^2)< 0.0)
// Print error
print("Cannot solve!")
else // solvable
print("Solution:")
// Diagonal for unrotated shape & rotated shape must have the same length
// so, using Pythagoras: x1^2+y1^2 = x2^2+y2^2
// rearrange to calculate new x for new y
x2# = sqrt(x1#^2 + y1#^2 - y2#^2)
// 2 answers due to symmetry & sqrt
x3# = -x2#
// Determine angles
a1# = atan2(y1#, x1#) // Original angle (red)
a2# = atan2(y2#, x2#) // solution A (green)
a3# = atan2(y2#, x3#) // solution B (cyan)
// Subtract to get change in angle or rotation delta
a12# = a2# - a1# // Delta angle A
a13# = a3# - a1# // Delta angle B
// Draw lines indicating rotation of vertex solutions
DrawLine(ORGX, ORGY, x2#*SCL+ORGX, -y2#*SCL+ORGY, 0,255,0) // green rotation solution A
DrawLine(ORGX, ORGY, x3#*SCL+ORGX, -y2#*SCL+ORGY, 0,255,255) // cyan rotation solution B
endif
// Draw line indicating height constraint
DrawLine(ORGX-SCL, -y2#*SCL+ORGY, ORGX+300,-y2#*SCL+ORGY, 255,255,255) // white rotation height constraint
// Draw shape with adjustable width (red)
DrawLine(ORGX, ORGY, x1#*SCL+ORGX, -y1#*SCL+ORGY, 255,0,0) // red unrotated
DrawLine( x1#*SCL+ORGX, y1#*SCL+ORGY, -x1#*SCL+ORGX, y1#*SCL+ORGY, 255,0,0)
DrawLine( x1#*SCL+ORGX, -y1#*SCL+ORGY, -x1#*SCL+ORGX, -y1#*SCL+ORGY, 255,0,0)
DrawLine(-x1#*SCL+ORGX, -y1#*SCL+ORGY, -x1#*SCL+ORGX, y1#*SCL+ORGY, 255,0,0)
DrawLine( x1#*SCL+ORGX, -y1#*SCL+ORGY, x1#*SCL+ORGX, y1#*SCL+ORGY, 255,0,0)
// Display inputs
printc("x1=") : print(x1#)
printc("y1=") : print(y1#)
printc("y2=") : print(y2#)
print("")
// Display results
printc("x2=") : print(x2#)
printc("x3=") : print(x3#)
printc("a1=") : print(a1#)
printc("a2=") : print(a2#)
printc("a3=") : print(a3#)
printc("a12="): print(a12#)
printc("a13="): print(a13#)
Sync() // update display
if (GetRawKeyPressed(27)) then end // Esc key ends program
loop
Code every line like it might be your last...
Someday it will be.