SkyLakeOver

Vector Angle

Dec 3rd, 2021
681
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IMyCockpit  Cockpit_Builder;
  2.         IMyTextSurface CockpitLCD;
  3.         // IMyMotorStator Rotor_Main;
  4.         IMyMotorStator Rotor_Cockpit;
  5.         IMyPistonBase  Piston_09;
  6.         IMyInteriorLight Light_01;
  7.  
  8.         public Program()
  9.         {
  10.             // Rotor_Main = GridTerminalSystem.GetBlockWithName("Терц_Кран_Ротор_База") as IMyMotorStator;
  11.             Rotor_Cockpit = GridTerminalSystem.GetBlockWithName("Терц_Кран_Ротор_Кокпит") as IMyMotorStator;
  12.             Cockpit_Builder = GridTerminalSystem.GetBlockWithName("Терц_Кран_Кокпит_Паяльный") as IMyCockpit;
  13.             CockpitLCD = Cockpit_Builder.GetSurface(0) as IMyTextSurface;
  14.            // Piston_01 = GridTerminalSystem.GetBlockWithName("Терц_Кран_Поршень_Горизонт_01") as IMyPistonBase;
  15.             Piston_09 = GridTerminalSystem.GetBlockWithName("Терц_Кран_Поршень_Горизонт_09") as IMyPistonBase;
  16.             Light_01 = GridTerminalSystem.GetBlockWithName("Терц_Кран_Лампа_01") as IMyInteriorLight;
  17.  
  18.            
  19.             Runtime.UpdateFrequency = UpdateFrequency.Update10;
  20.         }
  21.  
  22.         public void Main(string argument)
  23.         {
  24.             Vector3 Cockpit_Position = Cockpit_Builder.CubeGrid.GetPosition();
  25.             //Vector3 Rotor_Main_Position = Rotor_Main.CubeGrid.GetPosition();
  26.             Vector3 Rotor_Cockpit_Position = Rotor_Cockpit.CubeGrid.GetPosition();
  27.             Vector3 Light_Position = Light_01.CubeGrid.GetPosition();
  28.             Vector3 Piston_09_Position = Piston_09.CubeGrid.GetPosition();
  29.             Vector2 Bilder_Vector_X, Bilder_Vector_Offset_X;    
  30.             Bilder_Vector_X.X = Piston_09_Position.Y - Light_Position.Y;
  31.             Bilder_Vector_X.Y = Piston_09_Position.Z - Light_Position.Z;
  32.             Bilder_Vector_Offset_X.X = Cockpit_Position.Y - Rotor_Cockpit_Position.Y;
  33.             Bilder_Vector_Offset_X.Y = Cockpit_Position.Z - Rotor_Cockpit_Position.Z;
  34.             float Cockpit_Offset;
  35.             Cockpit_Offset = (float)Math.Acos(((Bilder_Vector_X.X * Bilder_Vector_Offset_X.X)+(Bilder_Vector_X.Y * Bilder_Vector_Offset_X.Y)) / (Math.Sqrt((Bilder_Vector_X.X* Bilder_Vector_X.X)+(Bilder_Vector_X.Y * Bilder_Vector_X.Y)) * Math.Sqrt((Bilder_Vector_Offset_X.X * Bilder_Vector_Offset_X.X) + (Bilder_Vector_Offset_X.Y * Bilder_Vector_Offset_X.Y))));
  36.  
  37.             //CockpitLCD.WriteText("Лампа: "+ "\n"+"X:"+ Light_Position.X.ToString()+"\n"+ "Y:" + Light_Position.Y.ToString() + "\n" + "Z:" + Light_Position.Z.ToString() + "\n"+
  38.             //   "Поршень_09: " + "\n" + "X:" + Piston_09_Position.X.ToString() + "\n" + "Y:" + Piston_09_Position.Y.ToString() + "\n" + "Z:" + Piston_09_Position.Z.ToString() + "\n", false);
  39.  
  40.             CockpitLCD.WriteText("Угол стрелы: " + Cockpit_Offset.ToString() +"\n", false);
  41.  
  42.         }
RAW Paste Data