Below two routines:
Private Sub Rotation(Angle As Double)
Private w, w2, r, x0, y0, x, y As Double
w = Panel1.Width
w2 = w / 2 'half width
'center of Panel1, rotation center
x0 = Panel1.Left + w2
y0 = Panel1.Top + w2
r = w
Panel1.Rotation = Angle
Panel2.Rotation = Angle
'new center coordinates of Panel2
x = x0 + r * CosD(Angle)
y = y0 + r * SinD(Angle)
'set Panel2 at its new coordinates
Panel2.Left = x - w2
Panel2.Top = y - w2
End Sub
Private Sub Rotate
For a = 0 To 45 Step 5
Rotation(a)
Sleep(100)
Next
End Sub
Rotation set the two panels at the given angle.
Rotate, rotates the two panels in 5 degree steps from 0 to 45°
The equations assume that:
- both Panels are square with same dimensions.
- the center of rotation is the center of Panel1
Attached the B4J demonstration project.
It is a B4XPages project but only tested with B4J.