X Y exhange per rotation

Given that all our component offsets per PCB origin are as at 0 rotation, we need to manipulate initial X & Y when we are in a rotation other than 0

Rotation X Y
0 degrees X Y
90 degrees Y -X
180 degrees -X -Y
270 degrees -Y X

Example:

                ' - For each PCB in the array:
                ' - - Define that PCB's origin calculated from the PCB holder origin (PCBArrayOffset)
                ' - - Each PCB origin stored using GCode 'G10 L2 Pnnn Xxxx Yyyy' where:
                ' - - - nnn starts at 101, xxx and yyy is calculated from PCBArrayOffset +/- array X Y
                '       offsets depending on the rotation
                For CurrentPCBX = 1 To PCBArrayCountX
                    For CurrentPCBY = 1 To PCBArrayCountY
                    
                        Select Case CurrentRotation
                            ' Calc PCB offset in the array to sets it origin
                            Case 0
                                CurrentPCBOffsetX = (CurrentPCBX - 1) * PCBOffsetX
                                CurrentPCBOffsetY = (CurrentPCBY - 1) * PCBOffsetY
                            Case 90
                                CurrentPCBOffsetX = (CurrentPCBY - 1) * PCBOffsetY
                                CurrentPCBOffsetY = (CurrentPCBX - 1) * PCBOffsetX * -1
                            Case 180
                                CurrentPCBOffsetX = (CurrentPCBX - 1) * PCBOffsetX * -1
                                CurrentPCBOffsetY = (CurrentPCBY - 1) * PCBOffsetY * -1
                            Case 270
                                CurrentPCBOffsetX = (CurrentPCBY - 1) * PCBOffsetY * -1
                                CurrentPCBOffsetY = (CurrentPCBX - 1) * PCBOffsetX
                        End Select
                
                        GCodeOut ("(" & PCBName & " rot:" & CurrentRotation & " pcb: " & CurrentPCB & " pcbx:" & CurrentPCBX & " pcby:" & CurrentPCBY & ")")
                        GCodeOut ("G10 L2 P" & 100 + CurrentPCB & " X[" & PCBArrayXParameter & " + " & CurrentPCBOffsetX & "] Y[" & PCBArrayXParameter & " + " & CurrentPCBOffsetY & "]")
                        
                        CurrentPCB = CurrentPCB + 1
                       
                    Next CurrentPCBY
                Next CurrentPCBX