private float GetRotate(VRageMath.Vector3 axis) { if (!XUtils.Directions.Contains(axis)) { throw new Exception("Invalid axis vector used: " + axis); } VRageMath.Matrix local = new VRageMath.Matrix(); referenceBlock.Orientation.GetMatrix(out local); axis = VRageMath.Vector3.Transform(axis, local); float totalValue = 0; for (int i = 0; i < gyroscopeBlocks.Count; ++i) { IMyGyro gyro = gyroscopeBlocks[i] as IMyGyro; gyro.Orientation.GetMatrix(out local); VRageMath.Matrix toGyro = VRageMath.Matrix.Transpose(local); VRageMath.Vector3 transformedAxis = VRageMath.Vector3.Transform(axis, toGyro); GyroAction action = GyroAction.getActionAroundAxis(transformedAxis); float value = gyro.GetValue <float>(action.Name); totalValue += action.Reversed ? -value : value; } return(totalValue); }