Module Module1
Public Structure vector
Dim x As Double
Dim y As Double
Dim z As Double
End Structure
Sub Main()
Dim Rotation_A As Double
Dim Rotation_B As Double
Dim Vector_X As vector
Dim Vector_Y As vector
Dim Vector_Z As vector
Dim Vect_temp As vector
Dim Vector_Xafter_rotA As vector
Dim Vector_Yafter_rotA As vector
Dim Vector_Zafter_rotA As vector
Dim Rota_axis As vector
Dim Panel_Y_axis As vector
Dim Tilt As Double
Dim Azimuth As Double
Dim Panel_rot As Double
Vector_X.x = 1
Vector_X.y = 0
Vector_X.z = 0
Vector_Y.x = 0
Vector_Y.y = 1
Vector_Y.z = 0
Vector_Z.x = 0
Vector_Z.y = 0
Vector_Z.z = 1
' Begin part I
' Enter RotationA and B
Rotation_A = 35 * (2 * Math.PI / 360)
Rotation_B = -60 * (2 * Math.PI / 360)
Vector_Xafter_rotA = Euler_Zxz_(Rotation_A, Rotation_B, 0, Vector_X)
Vector_Yafter_rotA = Euler_Zxz_(Rotation_A, Rotation_B, 0, Vector_Y)
Vector_Zafter_rotA = Euler_Zxz_(Rotation_A, Rotation_B, 0, Vector_Z)
' Tilting
Tilt = 90 - Math.Asin(Vector_Yafter_rotA.y) / (2 * Math.PI / 360)
' Azimuth
Azimuth = (Math.Atan2(-Vector_Yafter_rotA.z, -Vector_Yafter_rotA.x) / (2 * Math.PI / 360))
' Panel rotation
Vect_temp = Vec_pr(Vector_Y, Vector_Yafter_rotA)
Vect_temp = Vec_mul(Vect_temp, Vec_mod(Vect_temp) ^ -1)
Panel_rot = Math.Acos(Dot_pr(Vect_temp, Vector_Zafter_rotA))
Panel_rot /= (2 * Math.PI / 360)
' End part I ' Begin part II
' Enter Elevation and Azimuth
Tilt = 80 * (2 * Math.PI / 360)
Azimuth = 10 * (2 * Math.PI / 360)
Panel_Y_axis.y = Math.Sin((Math.PI / 2) - Tilt)
Panel_Y_axis.x = ((Math.Cos(Math.PI + Azimuth)) Mod (2 * Math.PI)) * Math.Cos((Math.PI / 2) - Tilt)
Panel_Y_axis.z = ((Math.Sin(Math.PI + Azimuth)) Mod (2 * Math.PI)) * Math.Cos((Math.PI / 2) - Tilt)
Rota_axis = Vec_pr(Vector_Z, Panel_Y_axis)
Rota_axis = Vec_mul(Rota_axis, Vec_mod(Rota_axis) ^ -1)
Rotation_B = Math.Acos(Dot_pr(Vector_Z, Panel_Y_axis)) - Math.PI / 2
Panel_Y_axis = Vec_add(Vec_mul(Vec_pr(Rota_axis, Panel_Y_axis), Math.Sin(-Rotation_B)), Vec_mul(Panel_Y_axis, Math.Cos(-Rotation_B)))
Rotation_A = Math.Acos(Dot_pr(Vector_X, Panel_Y_axis)) - Math.PI / 2
Rotation_A /= (2 * Math.PI / 360)
Rotation_B /= (2 * Math.PI / 360)
' End part II End Sub
Function Euler_Zxz_(ByVal rot1 As Double, ByVal rot2 As Double, ByVal rot3 As Double, ByVal myvector As vector) As vector
Dim ret_vector As vector
ret_vector.x = (Math.Cos(rot1) * Math.Cos(rot3) - Math.Cos(rot2) * Math.Sin(rot1) * Math.Sin(rot3)) * myvector.x
ret_vector.x += (-Math.Cos(rot1) * Math.Sin(rot3) - Math.Cos(rot3) * Math.Cos(rot2) * Math.Sin(rot1)) * myvector.y
ret_vector.x += (Math.Sin(rot2) * Math.Sin(rot1)) * myvector.z
ret_vector.y = (Math.Cos(rot2) * Math.Cos(rot1) * Math.Sin(rot3) + Math.Cos(rot3) * Math.Sin(rot1)) * myvector.x
ret_vector.y += (Math.Cos(rot1) * Math.Cos(rot2) * Math.Cos(rot3) - Math.Sin(rot1) * Math.Sin(rot3)) * myvector.y
ret_vector.y += (-Math.Cos(rot1) * Math.Sin(rot2)) * myvector.z
ret_vector.z = (Math.Sin(rot3) * Math.Sin(rot2)) * myvector.x
ret_vector.z += (Math.Cos(rot3) * Math.Sin(rot2)) * myvector.y
ret_vector.z += (Math.Cos(rot2)) * myvector.z
Return ret_vector
End Function
Function Vec_pr(ByVal vectorA As vector, ByVal vectorB As vector) As vector
Dim ret_vector As vector
ret_vector.x = vectorA.y * vectorB.z - vectorB.y * vectorA.z
ret_vector.y = vectorA.z * vectorB.x - vectorB.z * vectorA.x
ret_vector.z = vectorA.x * vectorB.y - vectorB.x * vectorA.y
Return ret_vector
End Function
Function Dot_pr(ByVal vectorA As vector, ByVal vectorB As vector) As Double
Dim ret_scalar As Double
ret_scalar = vectorA.x * vectorB.x
ret_scalar += vectorA.y * vectorB.y
ret_scalar += vectorA.z * vectorB.z
Return ret_scalar
End Function
Function Vec_mod(ByVal vectorA As vector) As Double
Return Math.Sqrt(Dot_pr(vectorA, vectorA))
End Function
Function Vec_mul(ByVal vectorA As vector, ByVal fact As Double) As vector
Dim Ret_vector As vector
Ret_vector.x = vectorA.x * fact
Ret_vector.y = vectorA.y * fact
Ret_vector.z = vectorA.z * fact
Return Ret_vector
End Function
Function Vec_add(ByVal vectorA As vector, ByVal vectorB As vector) As vector
Dim Ret_vector As vector
Ret_vector.x = vectorA.x + vectorB.x
Ret_vector.y = vectorA.y + vectorB.y
Ret_vector.z = vectorA.z + vectorB.z
Return Ret_vector
End Function
End Module