Sub Project_7_EN(ByVal VecType, m, n, m1, n1 As Integer) ' 07_Rotation of a vector_EN ' Updated: 26/03/24 ' Created by: Ariel R. Becerra (21/11/23) ' Modified by: _________________ ' This is the code of your new project. ' Steps to embed the code to ScienSolar: ' Note 1: The number 7 in the name of this function must match the one in the list of the CONFIG sheet for this project. If not, please correct it. ' Note 2: This code will be integrated into the main code to automate the download of the project. ' Note 3: The formulas and cell values generated here correspond only to the first 30 columns from INICIO to the right in the sheet. All your formulas and values are recommended to be written in these columns. ' Step 1. Go to the CONFIG sheet and add a short name and the number of your new project to the last row in the projects list. ' Step 2. Make sure that the list of projects in CONFIG sheet has the correct ascending numbering. ' Step 4. Open the VBA editor (Alt + F11 in Windows or Fn + Option + F11 in macOS). To avoid mistakes, make sure you only have one workbook open. ' Step 5. On the left, in the project explorer, select a non full module (or add a new one). ' Step 6. Select all the code in this file, copy and paste it at the end of the existing code in the module (or in the new one). ' Step 7. To load the project and to check it in a new sheet, go to the CONFIG sheet and click the New Sheet button, then select the project from the list and click the +Vector button. ' Step 8. Click any XYZ button to get the project in the coordinate system. Enjoy it! ' Visit www.sciensolar.com for news and updates of ? ScienSolar. Cells(m1 - 1, n1 + 2).FormulaR1C1 = "1" Cells(m1 + 0, n1 + 2).FormulaR1C1 = "=CONFIG!R3C4" Cells(m1 + 0, n1 + 3).FormulaR1C1 = "850" Cells(m1 + 0, n1 + 6).FormulaR1C1 = "=CONFIG!R3C8" Cells(m1 + 0, n1 + 7).FormulaR1C1 = "8" Cells(m1 + 0, n1 + 8).FormulaR1C1 = "Ariel R. Becerra (21/11/23)" Cells(m1 + 1, n1 + 2).FormulaR1C1 = "=CONFIG!R4C4" Cells(m1 + 1, n1 + 3).FormulaR1C1 = "400" Cells(m1 + 1, n1 + 4).FormulaR1C1 = "=CONFIG!R4C6" Cells(m1 + 1, n1 + 5).FormulaR1C1 = "0" Cells(m1 + 1, n1 + 6).FormulaR1C1 = "=CONFIG!R4C8" Cells(m1 + 1, n1 + 7).FormulaR1C1 = "45" Cells(m1 + 2, n1 + 2).FormulaR1C1 = "=CONFIG!R5C4" Cells(m1 + 2, n1 + 3).FormulaR1C1 = "20" Cells(m1 + 2, n1 + 4).FormulaR1C1 = "=CONFIG!R5C6" Cells(m1 + 2, n1 + 5).FormulaR1C1 = "15" Cells(m1 + 2, n1 + 6).FormulaR1C1 = "=CONFIG!R5C8" Cells(m1 + 2, n1 + 7).FormulaR1C1 = "2160" Cells(m1 + 3, n1 + 0).FormulaR1C1 = "a" Cells(m1 + 3, n1 + 2).FormulaR1C1 = "=CONFIG!R6C4" Cells(m1 + 3, n1 + 3).FormulaR1C1 = "200" Cells(m1 + 3, n1 + 4).FormulaR1C1 = "=CONFIG!R6C6" Cells(m1 + 3, n1 + 5).FormulaR1C1 = "15" Cells(m1, n1 + 9).FormulaR1C1 = "HELP" Dim HELPtxt As String HELPtxt = "ROTACI" & ChrW(211) & "N DE UN VECTOR ALREDEDOR DE UN VECTOR UNITARIO" & Chr(10) & _ " (See english version at the end)" & Chr(10) & _ " Modifique los valores del vector en las celdas G11, G12 y G13 observe los resultados oprimiendo el bot" & ChrW(243) & "n Run. Esto lo puede ver desde diferentes perspectivas con los botones de coordenadas XYZ, YZ, XZ, XY." & Chr(10) & _ " (ENGLISH)" & Chr(10) & _ " ROTATION OF A VECTOR ABOUT A UNIT VECTOR" & Chr(10) & _ " Modify the values " & ChrW(233) & "" & ChrW(233) & "of the auxiliary vector a in cells G11, G12 y G13 and observe the results by pressing the Run button. You can see this from different perspectives with the XYZ, YZ, XZ, XY coordinate buttons." & Chr(10) & _ " " & Chr(10) & _ " " Cells(m1, n1 + 9).Comment.Text Text:=HELPtxt If m = m1 + 0 Then ' vector 4 Cells(m + 3, n + -1).FormulaR1C1 = "1" Cells(m + 3, n + 0).FormulaR1C1 = "a" Cells(m + 3, n + 2).FormulaR1C1 = "=CONFIG!R6C4" Cells(m + 3, n + 3).FormulaR1C1 = "200" Cells(m + 3, n + 4).FormulaR1C1 = "=CONFIG!R6C6" Cells(m + 3, n + 5).FormulaR1C1 = "15" Cells(m + 4, n + -1).FormulaR1C1 = "1" Cells(m + 4, n + 0).FormulaR1C1 = "183" Cells(m + 4, n + 2).FormulaR1C1 = "ROTATION AROUND AN AXIS WITH UNIT VECTOR" Cells(m + 4, n + 12).FormulaR1C1 = "ROTATION AROUND AN AXIS WITH UNIT VECTOR" Cells(m + 4, n + 24).FormulaR1C1 = "INSTRUCTIONS" Cells(m + 5, n + -1).FormulaR1C1 = "1" Cells(m + 5, n + 0).FormulaR1C1 = "4" Cells(m + 5, n + 1).FormulaR1C1 = "0.3" Cells(m + 6, n + -1).FormulaR1C1 = "aox" Cells(m + 6, n + 0).FormulaR1C1 = "aoy" Cells(m + 6, n + 1).FormulaR1C1 = "aoz" Cells(m + 7, n + -1).FormulaR1C1 = "3" Cells(m + 7, n + 0).FormulaR1C1 = "3" Cells(m + 7, n + 1).FormulaR1C1 = "=R[-7]C+R[-9]C" Cells(m + 7, n + 4).FormulaR1C1 = "Coordinates of radius r:" Cells(m + 7, n + 21).FormulaR1C1 = "The model shows the equations for the construction of a vector that rotates around a" Cells(m + 8, n + -1).FormulaR1C1 = "ax" Cells(m + 8, n + 0).FormulaR1C1 = "ay" Cells(m + 8, n + 1).FormulaR1C1 = "az" Cells(m + 8, n + 2).FormulaR1C1 = "=IF(R[-4]C[-1]>1,"" <-- Variable coordinates"","""")" Cells(m + 8, n + 4).FormulaR1C1 = " x =" Cells(m + 8, n + 5).FormulaR1C1 = "2" Cells(m + 8, n + 21).FormulaR1C1 = "unit vector. This model can be used as a starting point for the construction of other " Cells(m + 9, n + -1).FormulaR1C1 = "0" Cells(m + 9, n + 0).FormulaR1C1 = "0" Cells(m + 9, n + 1).FormulaR1C1 = "4" Cells(m + 9, n + 2).FormulaR1C1 = "<< ---" Cells(m + 9, n + 4).FormulaR1C1 = " y =" Cells(m + 9, n + 5).FormulaR1C1 = "4" Cells(m + 9, n + 21).FormulaR1C1 = "mathematical or physical models. The initial position and axis coordinates are entered in:" Cells(m + 10, n + -1).FormulaR1C1 = "1" Cells(m + 10, n + 0).FormulaR1C1 = "0" Cells(m + 10, n + 1).FormulaR1C1 = "1" Cells(m + 10, n + 4).FormulaR1C1 = " z =" Cells(m + 10, n + 5).FormulaR1C1 = "0" Cells(m + 11, n + -1).FormulaR1C1 = "1" Cells(m + 11, n + 0).FormulaR1C1 = "0" Cells(m + 11, n + 1).FormulaR1C1 = "1" Cells(m + 11, n + 4).FormulaR1C1 = "=IF(R[-1]C[-4]>0,""<-- use these cells."","""")" Cells(m + 11, n + 22).FormulaR1C1 = "a_ox in cell A10" Cells(m + 3, n + 1).Interior.Color = "36799" Cells(m + 3, n + 1).Font.Size = "11" Cells(m + 3, n + 1).Font.name = "Calibri" Cells(m + 4, n - 1).Value = 1 Cells(m1 + 1, n1 + 1).Value = "u" Call AddNewVector End If ' vector ends If m = m1 + 9 Then ' vector 3 Cells(m + 3, n + -1).FormulaR1C1 = "2" Cells(m + 3, n + 0).FormulaR1C1 = "u" Cells(m + 3, n + 4).FormulaR1C1 = "Fix trajectory (1 or 2):" Cells(m + 3, n + 22).FormulaR1C1 = "a_oy in cell B10" Cells(m + 4, n + -1).FormulaR1C1 = "1" Cells(m + 4, n + 0).FormulaR1C1 = "183" Cells(m + 4, n + 2).FormulaR1C1 = "=SIN(RADIANS(R[-11]C[5]))" Cells(m + 4, n + 5).FormulaR1C1 = "1" Cells(m + 4, n + 22).FormulaR1C1 = "a_oz in cell C10" Cells(m + 5, n + -1).FormulaR1C1 = "1" Cells(m + 5, n + 0).FormulaR1C1 = "1" Cells(m + 5, n + 1).FormulaR1C1 = "0.3" Cells(m + 5, n + 2).FormulaR1C1 = "=1-COS(RADIANS(R[-12]C[5]))" Cells(m + 6, n + -1).FormulaR1C1 = "uox" Cells(m + 6, n + 0).FormulaR1C1 = "uoy" Cells(m + 6, n + 1).FormulaR1C1 = "uoz" Cells(m + 6, n + 22).FormulaR1C1 = "a_x in cell A12" Cells(m + 7, n + -1).FormulaR1C1 = "=R[-7]C+R[-9]C" Cells(m + 7, n + 0).FormulaR1C1 = "=R[-7]C+R[-9]C" Cells(m + 7, n + 1).FormulaR1C1 = "=R[-7]C+R[-9]C" Cells(m + 7, n + 22).FormulaR1C1 = "a_y in cell B12" Cells(m + 8, n + -1).FormulaR1C1 = "ux" Cells(m + 8, n + 0).FormulaR1C1 = "uy" Cells(m + 8, n + 1).FormulaR1C1 = "uz" Cells(m + 8, n + 2).FormulaR1C1 = "=IF(R[-4]C[-1]>1,"" <-- Variable coordinates"","""")" Cells(m + 8, n + 22).FormulaR1C1 = "a_z in cell C12" Cells(m + 9, n + -1).FormulaR1C1 = "=R[-9]C/SQRT(R[-9]C^2+R[-9]C[1]^2+R[-9]C[2]^2)" Cells(m + 9, n + 0).FormulaR1C1 = "=R[-9]C/SQRT(R[-9]C[-1]^2+R[-9]C^2+R[-9]C[1]^2)" Cells(m + 9, n + 1).FormulaR1C1 = "=R[-9]C/SQRT(R[-9]C[-2]^2+R[-9]C[-1]^2+R[-9]C^2)" Cells(m + 9, n + 2).FormulaR1C1 = "(Eq-6-1)" Cells(m + 10, n + -1).FormulaR1C1 = "1" Cells(m + 10, n + 0).FormulaR1C1 = "0" Cells(m + 10, n + 1).FormulaR1C1 = "1" Cells(m + 10, n + 4).FormulaR1C1 = "=IF(RC[-4]>0,"" For aditional formula (FA),"","""")" Cells(m + 10, n + 21).FormulaR1C1 = "The vector to rotate r_P is vector number 3 and its coordinates are set in cells G11, G12" Cells(m + 11, n + -1).FormulaR1C1 = "3" Cells(m + 11, n + 0).FormulaR1C1 = "0" Cells(m + 11, n + 1).FormulaR1C1 = "1" Cells(m + 11, n + 4).FormulaR1C1 = "=IF(R[-1]C[-4]>0,""<-- use these cells."","""")" Cells(m + 11, n + 21).FormulaR1C1 = "and G13. The rotated vector r about the unit vector u is the number 4 and the equations for its" Cells(m + 3, n + 1).Interior.Color = "255" Cells(m + 3, n + 1).Font.Size = "11" Cells(m + 3, n + 1).Font.name = "Calibri" Cells(m + 4, n - 1).Value = 1 Cells(m1 + 1, n1 + 1).Value = "" Call AddNewVector End If ' vector ends If m = m1 + 18 Then ' vector 2 Cells(m + 3, n + -1).FormulaR1C1 = "3" Cells(m + 3, n + 21).FormulaR1C1 = "coordinates are found according to the rotation formula for the new vector:" Cells(m + 4, n + -1).FormulaR1C1 = "1" Cells(m + 4, n + 0).FormulaR1C1 = "183" Cells(m + 5, n + -1).FormulaR1C1 = "1" Cells(m + 5, n + 0).FormulaR1C1 = "1" Cells(m + 5, n + 1).FormulaR1C1 = "1" Cells(m + 5, n + 27).FormulaR1C1 = "(Eq-7-1)" Cells(m + 6, n + -1).FormulaR1C1 = "roox" Cells(m + 6, n + 0).FormulaR1C1 = "rooy" Cells(m + 6, n + 1).FormulaR1C1 = "rooz" Cells(m + 7, n + -1).FormulaR1C1 = "=R[-18]C+R[-16]C" Cells(m + 7, n + 0).FormulaR1C1 = "=R[-18]C+R[-16]C" Cells(m + 7, n + 1).FormulaR1C1 = "=R[-18]C+R[-16]C" Cells(m + 7, n + 21).FormulaR1C1 = "where theta is the angle to rotate." Cells(m + 8, n + -1).FormulaR1C1 = "Coordenadas del vector" Cells(m + 8, n + 0).FormulaR1C1 = "y" Cells(m + 8, n + 1).FormulaR1C1 = "z" Cells(m + 8, n + 2).FormulaR1C1 = "=IF(R[-4]C[-1]>1,"" <-- Variable coordinates"","""")" Cells(m + 8, n + 21).FormulaR1C1 = "(Detailed explanation of the mathematics is in the manual)." Cells(m + 9, n + -1).FormulaR1C1 = "=R[-19]C[6]" Cells(m + 9, n + 0).FormulaR1C1 = "=R[-18]C[5]" Cells(m + 9, n + 1).FormulaR1C1 = "=R[-17]C[4]" Cells(m + 9, n + 2).FormulaR1C1 = "<< ---" Cells(m + 9, n + 21).FormulaR1C1 = "Use the Run Simulation buttons to view the vector rotation." Cells(m + 10, n + -1).FormulaR1C1 = "1" Cells(m + 10, n + 0).FormulaR1C1 = "0" Cells(m + 10, n + 1).FormulaR1C1 = "1" Cells(m + 10, n + 4).FormulaR1C1 = "=IF(RC[-4]>0,"" For aditional formula (FA),"","""")" Cells(m + 10, n + 21).FormulaR1C1 = "Use G16=2 to freeze the vector path after running the simulation." Cells(m + 11, n + -1).FormulaR1C1 = "0" Cells(m + 11, n + 0).FormulaR1C1 = "0" Cells(m + 11, n + 1).FormulaR1C1 = "1" Cells(m + 11, n + 4).FormulaR1C1 = "=IF(R[-1]C[-4]>0,""<-- use these cells."","""")" Cells(m + 11, n + 21).FormulaR1C1 = "Press the button located at D40 to see the equations of the components of the vector r." Cells(m + 3, n + 1).Interior.Color = "12611584" Cells(m + 3, n + 1).Font.Size = "11" Cells(m + 3, n + 1).Font.name = "Calibri" Cells(m + 4, n - 1).Value = 1 Cells(m1 + 1, n1 + 1).Value = "r" Call AddNewVector End If ' vector ends If m = m1 + 27 Then ' vector 1 Cells(m + 3, n + -1).FormulaR1C1 = "4" Cells(m + 3, n + 0).FormulaR1C1 = "r" Cells(m + 4, n + -1).FormulaR1C1 = "1" Cells(m + 4, n + 0).FormulaR1C1 = "183" Cells(m + 4, n + 21).FormulaR1C1 = "EXAMPLE 1. Obtain the simulation of a point particle that is rotating around the y axis with a radius r=5" Cells(m + 5, n + -1).FormulaR1C1 = "1" Cells(m + 5, n + 0).FormulaR1C1 = "1" Cells(m + 5, n + 1).FormulaR1C1 = "0.3" Cells(m + 5, n + 21).FormulaR1C1 = "originating at y_0=4. " Cells(m + 6, n + -1).FormulaR1C1 = "rox" Cells(m + 6, n + 0).FormulaR1C1 = "roy" Cells(m + 6, n + 1).FormulaR1C1 = "roz" Cells(m + 6, n + 21).FormulaR1C1 = "Solution: Start from the current model and modify the orientation" Cells(m + 7, n + -1).FormulaR1C1 = "=R[-9]C" Cells(m + 7, n + 0).FormulaR1C1 = "=R[-9]C" Cells(m + 7, n + 1).FormulaR1C1 = "=R[-9]C" Cells(m + 7, n + 21).FormulaR1C1 = "of the axis and the radius, to do this, enter A10=0, B10=0 and C10=0. The center of rotation is located at" Cells(m + 8, n + -1).FormulaR1C1 = "rx" Cells(m + 8, n + 0).FormulaR1C1 = "ry" Cells(m + 8, n + 1).FormulaR1C1 = "rz" Cells(m + 8, n + 2).FormulaR1C1 = "=IF(R[-4]C[-1]>1,"" <-- Variable coordinates"","""")" Cells(m + 8, n + 21).FormulaR1C1 = "B12=4 and the radius of rotation at G11=5, G12=0, G13=0. Press Run to see the rotation." Cells(m + 9, n + -1).FormulaR1C1 = "=R[-9]C+R[-22]C[3]*(R[-18]C[1]*R[-18]C*R[-9]C[1]-R[-18]C[1]*R[-18]C[1]*R[-9]C+R[-18]C[2]*R[-18]C*R[-9]C[2]-R[-18]C[2]*R[-18]C[2]*R[-9]C)+R[-23]C[3]*(R[-18]C[1]*R[-9]C[2]-R[-18]C[2]*R[-9]C[1])" Cells(m + 9, n + 0).FormulaR1C1 = "=R[-9]C+R[-22]C[2]*(-R[-18]C[-1]*R[-18]C[-1]*R[-9]C+R[-18]C[-1]*R[-18]C*R[-9]C[-1]+R[-18]C[1]*R[-18]C*R[-9]C[1]-R[-18]C[1]*R[-18]C[1]*R[-9]C)+R[-23]C[2]*(-R[-18]C[-1]*R[-9]C[1]+R[-18]C[1]*R[-9]C[-1])" Cells(m + 9, n + 1).FormulaR1C1 = "=R[-9]C+R[-22]C[1]*(-R[-18]C[-2]*R[-18]C[-2]*R[-9]C+R[-18]C[-2]*R[-18]C*R[-9]C[-2]-R[-18]C[-1]*R[-18]C[-1]*R[-9]C+R[-18]C[-1]*R[-18]C*R[-9]C[-1])+R[-23]C[1]*(R[-18]C[-2]*R[-9]C[-1]-R[-18]C[-1]*R[-9]C[-2])" Cells(m + 9, n + 2).FormulaR1C1 = "(Eq-7-2)" Cells(m + 9, n + 21).FormulaR1C1 = "To add a particle, verify that you have not selected any projects in the project list and" Cells(m + 10, n + -1).FormulaR1C1 = "1" Cells(m + 10, n + 0).FormulaR1C1 = "0" Cells(m + 10, n + 1).FormulaR1C1 = "=R[-24]C[4]" Cells(m + 10, n + 4).FormulaR1C1 = "=IF(RC[-4]>0,"" For aditional formula (FA),"","""")" Cells(m + 10, n + 21).FormulaR1C1 = "Press the +Vector button. In the pop-up window indicate the name Q for the new vector, then" Cells(m + 11, n + -1).FormulaR1C1 = "2" Cells(m + 11, n + 0).FormulaR1C1 = "0" Cells(m + 11, n + 1).FormulaR1C1 = "1" Cells(m + 11, n + 4).FormulaR1C1 = "=IF(R[-1]C[-4]>0,""<-- use these cells."","""")" Cells(m + 11, n + 21).FormulaR1C1 = "with B43=146 convert the vector to a point; change the color of the new vector to red" Cells(m + 3, n + 1).Interior.Color = "12611584" Cells(m + 3, n + 1).Font.Size = "11" Cells(m + 3, n + 1).Font.name = "Calibri" Cells(m + 4, n - 1).Value = 1 Cells(m1 + 1, n1 + 1).Value = "" Cells(m1 + 2, n1 - 1).Value = 4 End If ' vector ends If m = m1 + 27 Then Cells(m + 12, n + 21).FormulaR1C1 = "and with C50=8 increase the particle size, and C35=1, to hide the radius. Press Run and you can" Cells(m + 13, n + 21).FormulaR1C1 = "observe the particle rotating around the y axis. Rotate it from different planes. Enter" Cells(m + 14, n + 21).FormulaR1C1 = "C49=2 and press Run to view the particle trajectory; repeat the operation with C49=1." Call BlackWhiteDesk Call PutEqBut End If ' actualizar hoja End Sub