iOS Question Panel Rotation and Left and Top position

Alexander Stolte

Expert
Licensed User
Longtime User
I am having a problem positioning a panel correctly with a 60 degree rotation.
There is certainly a formula for this, but I can't find it.

That is my starting position:
1690204967086.png

now i want to rotate the white panel by 60 degrees, the white panel should be with the left corners at the red panel. I have absolutely no idea which formula I need for this...

If i rotate with 60 degrees then it looks like:
1690205129106.png
 

Attachments

  • Test.zip
    3.4 KB · Views: 126
Solution
Try this:

B4X:
    xpnl_Line.Rotation = -60
    
    xpnl_Line.Top = xpnl_Line.Top - SinD(60) * xpnl_Line.Width / 2 + SinD(90 - 60) * xpnl_Line.Height / 2
    xpnl_Line.Left = xpnl_Line.Left - CosD(60) * xpnl_Line.Width / 2 - CosD(90 - 60) * xpnl_Line.Height / 2

angel_

Well-Known Member
Licensed User
Longtime User
Try this:

B4X:
    xpnl_Line.Rotation = -60
    
    xpnl_Line.Top = xpnl_Line.Top - SinD(60) * xpnl_Line.Width / 2 + SinD(90 - 60) * xpnl_Line.Height / 2
    xpnl_Line.Left = xpnl_Line.Left - CosD(60) * xpnl_Line.Width / 2 - CosD(90 - 60) * xpnl_Line.Height / 2
 
Upvote 1
Solution
Top