public void RotateComponent() { var d1 = SpaceEngineersApi.GetCubeDefinition(new MyObjectBuilderType(typeof(MyObjectBuilder_Thrust)), MyCubeSize.Large, "LargeBlockLargeThrust"); Assert.AreEqual("DisplayName_Block_LargeThrust", d1.DisplayName, "Must match"); Assert.AreEqual(MyCubeSize.Large, d1.CubeSize, "Must match"); Assert.AreEqual(3, d1.Size.X, "Must match"); Assert.AreEqual(2, d1.Size.Y, "Must match"); Assert.AreEqual(4, d1.Size.Z, "Must match"); //======// var orient = new SerializableBlockOrientation(Base6Directions.Direction.Forward, Base6Directions.Direction.Up); var f = Base6Directions.GetVector(orient.Forward); var u = Base6Directions.GetVector(orient.Up); var m = Matrix.CreateFromDir(f, u); var q = Quaternion.CreateFromRotationMatrix(m); var nf = Base6Directions.GetForward(q); var nu = Base6Directions.GetUp(q); // Test that Space Engineers orientation methods are working as expected. Forward is still Forward, Up is still Up. Assert.AreEqual(nf, orient.Forward, "Initial Orientation Forward must match."); Assert.AreEqual(nu, orient.Up, "Initial Orientation Forward must match."); //======// var v = d1.Size.ToVector3(); var fV1 = Vector3.Transform(v, m); // Orientation of Forward/Up should provide the exact same dimentions as the original Component above. Assert.AreEqual(3, fV1.X, "Must match"); Assert.AreEqual(2, fV1.Y, "Must match"); Assert.AreEqual(4, fV1.Z, "Must match"); //======// var newOrient = new SerializableBlockOrientation(Base6Directions.Direction.Down, Base6Directions.Direction.Right); var newM = Matrix.CreateFromDir(Base6Directions.GetVector(newOrient.Forward), Base6Directions.GetVector(newOrient.Up)); var fV2 = Vector3.Transform(v, newM); // The reoriented Component size should now have changed. Assert.AreEqual(2, fV2.X, "Must match"); Assert.AreEqual(4, fV2.Y, "Must match"); Assert.AreEqual(3, fV2.Z, "Must match"); //======// // Reducing complexity of code with Extension. var direction = new SerializableBlockOrientation(Base6Directions.Direction.Down, Base6Directions.Direction.Right); var fV3 = d1.Size.Transform(direction); // The reoriented Component size should now have changed. Assert.AreEqual(2, fV3.X, "Must match"); Assert.AreEqual(4, fV3.Y, "Must match"); Assert.AreEqual(3, fV3.Z, "Must match"); }
public static Vector3I Transform(this SerializableVector3I size, SerializableBlockOrientation orientation) { var matrix = Matrix.CreateFromDir(Base6Directions.GetVector(orientation.Forward), Base6Directions.GetVector(orientation.Up)); var rotation = Quaternion.CreateFromRotationMatrix(matrix); return Vector3I.Transform(size.ToVector3I(), rotation); }
private static SerializableBlockOrientation MirrorCubeOrientation(string subtypeName, SerializableBlockOrientation orientation, Mirror xMirror, Mirror yMirror, Mirror zMirror) { if (xMirror != Mirror.None) { #region X Symmetry mapping if (CornerRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Forward_Right]; } } else if (WindowFlatRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Down_Left]; } } else if (WindowCornerRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Up_Forward]; } } else if (WindowEdgeRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Left_Up]; } } else if (TubeCurvedRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Down_Left]; default: return orientation; } } else { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Up_Left]; } } #endregion } else if (yMirror != Mirror.None) { #region Y Symmetry mapping if (CornerRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Up_Backward]; } } else if (WindowFlatRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Down_Left]; } } else if (WindowCornerRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Down_Forward]; } } else if (WindowEdgeRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Right_Down]; } } else if (TubeCurvedRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Left_Down]; default: return orientation; } } else { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Down_Right]; } } #endregion } else if (zMirror != Mirror.None) { #region Z Symmetry mapping if (CornerRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Down_Forward]; } } else if (WindowFlatRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Right_Up]; //U case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Up_Left]; } } else if (WindowCornerRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Up_Backward]; } } else if (WindowEdgeRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Right_Up]; } } else if (TubeCurvedRotationBlocks.Contains(subtypeName)) { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Up_Right]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Down_Right]; default: return orientation; } } else { var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); switch (cubeType.Key) { case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Forward_Down]; case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Forward_Left]; case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Forward_Right]; case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Forward_Up]; case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Down_Forward]; case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Down_Backward]; case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Down_Left]; case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Down_Right]; case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Backward_Down]; case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Backward_Left]; case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Backward_Right]; case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Backward_Up]; case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Left_Forward]; case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Left_Down]; case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Left_Backward]; case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Left_Up]; case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Right_Forward]; case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Right_Down]; case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Right_Backward]; case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Right_Up]; case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Up_Forward]; case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Up_Backward]; case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Up_Left]; case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Up_Right]; } } //var cubeType = BaseOrientations.FirstOrDefault(x => x.Value.Forward == orientation.Forward && x.Value.Up == orientation.Up); //switch (cubeType.Key) //{ // case OrientType.Axis24_Backward_Down: return BaseOrientations[OrientType.Axis24_Backward_Down]; // case OrientType.Axis24_Backward_Left: return BaseOrientations[OrientType.Axis24_Backward_Left]; // case OrientType.Axis24_Backward_Right: return BaseOrientations[OrientType.Axis24_Backward_Right]; // case OrientType.Axis24_Backward_Up: return BaseOrientations[OrientType.Axis24_Backward_Up]; // case OrientType.Axis24_Down_Backward: return BaseOrientations[OrientType.Axis24_Down_Backward]; // case OrientType.Axis24_Down_Forward: return BaseOrientations[OrientType.Axis24_Down_Forward]; // case OrientType.Axis24_Down_Left: return BaseOrientations[OrientType.Axis24_Down_Left]; // case OrientType.Axis24_Down_Right: return BaseOrientations[OrientType.Axis24_Down_Right]; // case OrientType.Axis24_Forward_Down: return BaseOrientations[OrientType.Axis24_Forward_Down]; // case OrientType.Axis24_Forward_Left: return BaseOrientations[OrientType.Axis24_Forward_Left]; // case OrientType.Axis24_Forward_Right: return BaseOrientations[OrientType.Axis24_Forward_Right]; // case OrientType.Axis24_Forward_Up: return BaseOrientations[OrientType.Axis24_Forward_Up]; // case OrientType.Axis24_Left_Backward: return BaseOrientations[OrientType.Axis24_Left_Backward]; // case OrientType.Axis24_Left_Down: return BaseOrientations[OrientType.Axis24_Left_Down]; // case OrientType.Axis24_Left_Forward: return BaseOrientations[OrientType.Axis24_Left_Forward]; // case OrientType.Axis24_Left_Up: return BaseOrientations[OrientType.Axis24_Left_Up]; // case OrientType.Axis24_Right_Backward: return BaseOrientations[OrientType.Axis24_Right_Backward]; // case OrientType.Axis24_Right_Down: return BaseOrientations[OrientType.Axis24_Right_Down]; // case OrientType.Axis24_Right_Forward: return BaseOrientations[OrientType.Axis24_Right_Forward]; // case OrientType.Axis24_Right_Up: return BaseOrientations[OrientType.Axis24_Right_Up]; // case OrientType.Axis24_Up_Backward: return BaseOrientations[OrientType.Axis24_Up_Backward]; // case OrientType.Axis24_Up_Forward: return BaseOrientations[OrientType.Axis24_Up_Forward]; // case OrientType.Axis24_Up_Left: return BaseOrientations[OrientType.Axis24_Up_Left]; // case OrientType.Axis24_Up_Right: return BaseOrientations[OrientType.Axis24_Up_Right]; //} #endregion } return orientation; }
public static Vector3D Transform(this Vector3D vector, SerializableBlockOrientation orientation) { var matrix = MatrixD.CreateFromDir(Base6Directions.GetVector(orientation.Forward), Base6Directions.GetVector(orientation.Up)); return Vector3D.Transform(vector, matrix); }