Whiplash141

Whip's ApplyGyroOverride Method v9

Oct 15th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. //Whip's ApplyGyroOverride Method v9 - 8/19/17
  2. void ApplyGyroOverride(double pitch_speed, double yaw_speed, double roll_speed, List<IMyTerminalBlock> gyro_list, IMyTerminalBlock reference)
  3. {
  4.     var rotationVec = new Vector3D(-pitch_speed, yaw_speed, roll_speed);
  5.    
  6.     var shipMatrix = reference.WorldMatrix;
  7.     var relativeRotationVec = Vector3D.TransformNormal(rotationVec, shipMatrix);
  8.  
  9.     foreach (IMyGyro thisGyro in gyro_list)
  10.     {
  11.         var gyroMatrix = thisGyro.WorldMatrix;
  12.         var transformedRotationVec = Vector3D.TransformNormal(relativeRotationVec, Matrix.Transpose(gyroMatrix));
  13.  
  14.         thisGyro.Pitch = (float)transformedRotationVec.X; //because keen does some weird stuff with signs
  15.         thisGyro.Yaw = (float)transformedRotationVec.Y;
  16.         thisGyro.Roll = (float)transformedRotationVec.Z;
  17.         thisGyro.GyroOverride = true;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment