public RotateOperation(short _sourceAddress, short _targetAddress, RotationDirection _direction, Register.RegisterFileMap _registerFileMap, short _address) : base(_registerFileMap, CYCLES, _address) { this.data = _registerFileMap.Get(_sourceAddress); this.targetAddress = _targetAddress; this.direction = _direction; }
IEnumerator shiftAnimation(RotationDirection direction) { Quaternion from = Quaternion.identity; Quaternion to = Quaternion.AngleAxis((int) direction / 5, Vector3.forward); // Shift 18 deg for (float i = 0.0f; i < 1.0f; i += Time.deltaTime / shiftDuration) { shiftRotation = Quaternion.Slerp(from, to, Mathf.Sin(i * Mathf.PI)); yield return new WaitForSeconds(0); } shiftRotation = Quaternion.identity; }
public StoneCircle(float radius, int RuneCount, RotationDirection rotationDirection, Texture texture) { // Sprite Stuff Sprite = new Sprite(texture); Sprite.Origin = (Vector2)Sprite.Texture.Size / 2F; Sprite.Scale = Vector2.One * 0.08F; // Rotation this.Radius = radius; this.Rotation = 0F; this.Direction = rotationDirection == RotationDirection.Clockwise ? -1F : 1F; RotationSpeed = Direction * Rand.Value(0.0005F, 0.001F); // Create Runes CreateRunes(RuneCount); SetRunesAccordingToRotation(); }
public Laser(Level level, int x, int y, bool createdByEvent, bool vertical, bool flashing, RotationDirection rotationDir) { this.level = level; this.position = RectangleExtensions.GetBottomCenter(level.GetBounds(x, y)); this.tileCoords = new Vector2(x, y); this.createdByEvent = createdByEvent; this.vertical = vertical; this.flashing = flashing; this.rotationDir = rotationDir; // If not flashing laser is always on if (!flashing) laserOn = true; // Rotate tile to use as either horizontal or vertical (so only need to store one image file) if (vertical) rotationAngle = 0; else { rotationAngle = MathHelper.ToRadians(90); } LoadContent(); }
public GameObject() { m_sprite = null; m_position = new Vector2(0, 0); m_offset = new Vector2(0, 0); m_velocity = new Vector2(0, 0); m_maximumVelocity = 1; m_acceleration = 0; m_maximumAcceleration = 1; m_rotation = 0; m_rotationSpeed = 0; m_maximumRotationSpeed = 1; m_rotationDirection = RotationDirection.None; m_size = new Vector2(0, 0); m_scale = new Vector2(1, 1); m_scaleSpeed = 0; m_scaleDirection = ScaleDirection.None; updateInitialValues(); }
private void tryRotate(RotationDirection direction) { if (canRotate(direction)) { Debug.Log("Can rotate, beginning..."); beginRotation(direction); } else { cameraScript.shift(direction); } }
/// <summary> /// Paints GameObject from containg Prefab into a given position within the selected layers. /// The PrefabBrush overrides this to provide Prefab painting functionality. /// </summary> /// <param name="grid">Grid used for layout.</param> /// <param name="brushTarget">Target of the paint operation. By default the currently selected GameObject.</param> /// <param name="position">The coordinates of the cell to paint data to.</param> public override void Rotate(RotationDirection direction, GridLayout.CellLayout layout) { m_Rotation = Quaternion.Euler(0f, 0f, direction == RotationDirection.Clockwise ? m_Rotation.eulerAngles.z + 90f : m_Rotation.eulerAngles.z - 90f); }
private void beginRotation(RotationDirection direction) { effectsPlayer.rotate(); targetRotation = currentRotation + (int) direction; currentRotationDirection = direction; Quaternion from = Quaternion.AngleAxis(currentRotation, Vector3.forward); Quaternion to = Quaternion.AngleAxis(targetRotation, Vector3.forward); // Need to "restore" speed after rotation. Store it here. preRotationVelocity = Mathf.Sqrt(Vector2.SqrMagnitude(rigidbody2D.velocity)); StartCoroutine (rotationAnimation(from, to)); }
/// <summary> /// Ensures the faces on either side of the given index (as well as the given index face) are calculated and in the view port. /// </summary> /// <remarks>If the n-gon we have laid out is under 5 sides then this method will only ensure the given face index and either /// the next or previous face (depending on rotation direction) are calculated. If the n-gon has more than five side it will /// ensure the both sides of the given face index have been calculated.</remarks> private void EnsureSurroundingFacesCalculated(int faceIndex, RotationDirection rotationDirection) { int previousIndex = AdjustIndex(faceIndex, RotationDirection.Backwards); int nextIndex = AdjustIndex(faceIndex, RotationDirection.Forward); EnsureFaceCalculated(faceIndex); if (Items.Count < 5) { EnsureFaceCalculated((rotationDirection == RotationDirection.Forward) ? nextIndex : previousIndex); } else { EnsureFaceCalculated(previousIndex); EnsureFaceCalculated(nextIndex); } }
public static TransformSequence <T> Spin <T>(this TransformSequence <T> t, double revolutionDuration, RotationDirection direction, float startRotation, int numRevolutions) where T : Drawable => t.Loop(0, numRevolutions, d => d.RotateTo(startRotation).RotateTo(startRotation + (direction == RotationDirection.Clockwise ? 360 : -360), revolutionDuration));
//[SerializeField] RotationDirection rotationDirection; //[SerializeField] Tetramino.TetraminoType tetraminoType; //[ContextMenu("Test")] //public void Test() //{ // Vector2Int[] tetraminoRotatedPoses = Tetramino.GetPoses(tetraminoType, rotationDirection); // Vector2Int[] tetraminoPoses = Tetramino.GetPoses(tetraminoType, RotationDirection.None); // Vector2Int[] rotationVectorPoses = new Vector2Int[4]; // Vector2 rotationPoint = new Tetramino(tetraminoType).rotationPoint; // for (int i = 0; i < 4; i++) // { // Vector2 rotated = RotateVector.Rotate(tetraminoPoses[i] - rotationPoint, rotationDirection); // rotationVectorPoses[i] = VectorUtil.V2_V2Int(rotated + rotationPoint); // } // Debug.Log("RotateVector:"); // Debug.Log(string.Join("\t", rotationVectorPoses)); // Debug.Log("TetraminoRotate:"); // Debug.Log(string.Join("\t", tetraminoRotatedPoses)); //} private static string TetraminoString(Tetramino.TetraminoType tetraminoType, RotationDirection rotationDirection) { Vector2Int[] tetraminoRotatedPoses = TetraminoTransformUtil.GetPoses(tetraminoType, rotationDirection); return(string.Join("\t", tetraminoRotatedPoses)); }
// HELPERS static void UpdateRotationState(RotationDirection direction, GameObject robotPart) { ArticulationJointController jointController = robotPart.GetComponent <ArticulationJointController>(); jointController.rotationState = direction; }
public BaseOperation getNextOperation(short _codeAdress) { this.address = _codeAdress; // mask Operation-Byte --> xxxx xxxx 0000 0000 short operation = (short)((short)programMemory[_codeAdress] & 0xFF00); // mask Parameter-Byte --> 0000 0000 xxxx xxxx short parameter = (short)((short)programMemory[_codeAdress] & 0x00FF); if (parameter < 0) throw new Exception("negative parameter"); switch (operation) { /* ------------------------------------------------------ */ /* -------- ARITHMETIC OPERATIONS ----------------------- */ case ParserConstants.ADDWF: // arithmetical operator ArithOp = ArithmeticOperator.PLUS; // target address target = getTargetAddress(parameter); // operating bytes byte1 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); byte2 = registerFileMap.Get(getAddressFromParameter(parameter)); return new ArithmeticOperation(byte1, byte2, ArithOp, target, registerFileMap, address); case ParserConstants.ADDLW_1: case ParserConstants.ADDLW_2: ArithOp = ArithmeticOperator.PLUS; target = RegisterConstants.WORKING_REGISTER_ADDRESS; byte1 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); byte2 = getLiteralFromParameter(parameter); return new ArithmeticOperation(byte1, byte2, ArithOp, target, registerFileMap, address); case ParserConstants.INCF: ArithOp = ArithmeticOperator.PLUS; target = getTargetAddress(parameter); byte1 = 0x01; byte2 = registerFileMap.Get(getAddressFromParameter(parameter)); return new ArithmeticOperation(byte1, byte2, ArithOp, target, registerFileMap, address); case ParserConstants.SUBWF: ArithOp = ArithmeticOperator.MINUS; target = getTargetAddress(parameter); byte1 = registerFileMap.Get(getAddressFromParameter(parameter)); byte2 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new ArithmeticOperation(byte1, byte2, ArithOp, target, registerFileMap, address); case ParserConstants.SUBLW_1: case ParserConstants.SUBLW_2: ArithOp = ArithmeticOperator.MINUS; target = RegisterConstants.WORKING_REGISTER_ADDRESS; byte1 = getLiteralFromParameter(parameter); byte2 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new ArithmeticOperation(byte1, byte2, ArithOp, target, registerFileMap, address); case ParserConstants.DECF: ArithOp = ArithmeticOperator.MINUS; target = getTargetAddress(parameter); byte1 = registerFileMap.Get(getAddressFromParameter(parameter)); byte2 = 0x01; return new ArithmeticOperation(byte1, byte2, ArithOp, target, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- BIT OPERATIONS ------------------------------ */ case ParserConstants.BCF_1: case ParserConstants.BCF_2: case ParserConstants.BCF_3: case ParserConstants.BCF_4: // bit operator BitOp = BitOperator.BITCLEAR; // target address target = getAddressFromParameter(parameter); // bit-number bit = getBitNumberFromOperationCall(operation, parameter); return new BitOperation(target, bit, BitOp, registerFileMap, address); case ParserConstants.BSF_1: case ParserConstants.BSF_2: case ParserConstants.BSF_3: case ParserConstants.BSF_4: BitOp = BitOperator.BITSET; target = getAddressFromParameter(parameter); bit = getBitNumberFromOperationCall(operation, parameter); return new BitOperation(target, bit, BitOp, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- CALL OPERATIONS ----------------------------- */ case ParserConstants.CALL_1: case ParserConstants.CALL_2: case ParserConstants.CALL_3: case ParserConstants.CALL_4: case ParserConstants.CALL_5: case ParserConstants.CALL_6: case ParserConstants.CALL_7: case ParserConstants.CALL_8: target = getTargetAddress(operation, parameter); return new CallOperation(target, operationStack, programCounter, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- GOTO OPERATION ------------------------------ */ case ParserConstants.GOTO_1: case ParserConstants.GOTO_2: case ParserConstants.GOTO_3: case ParserConstants.GOTO_4: case ParserConstants.GOTO_5: case ParserConstants.GOTO_6: case ParserConstants.GOTO_7: case ParserConstants.GOTO_8: target = getTargetAddress(operation, parameter); return new GotoOperation(target, programCounter, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- CLEAR OPERATIONS ---------------------------- */ case ParserConstants.CLRF_CLRW: target = getTargetAddress(parameter); return new ClearOperation(target, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- COMPLEMENT OPERATIONS ----------------------- */ case ParserConstants.COMF: target = getTargetAddress(parameter); if (target == RegisterConstants.WORKING_REGISTER_ADDRESS) return new ComplementOperation(getAddressFromParameter(parameter), target, registerFileMap, address); else return new ComplementOperation(target, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- LOGIC OPERATIONS ---------------------------- */ case ParserConstants.ANDWF: LogOp = LogicOperator.AND; target = getTargetAddress(parameter); byte1 = registerFileMap.Get(getAddressFromParameter(parameter)); byte2 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new LogicOperation(byte1, byte2, LogOp, target, registerFileMap, address); case ParserConstants.ANDLW: LogOp = LogicOperator.AND; target = RegisterConstants.WORKING_REGISTER_ADDRESS; byte1 = getLiteralFromParameter(parameter); byte2 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new LogicOperation(byte1, byte2, LogOp, target, registerFileMap, address); case ParserConstants.IORWF: LogOp = LogicOperator.IOR; target = getTargetAddress(parameter); byte1 = registerFileMap.Get(getAddressFromParameter(parameter)); byte2 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new LogicOperation(byte1, byte2, LogOp, target, registerFileMap, address); case ParserConstants.IORLW: LogOp = LogicOperator.IOR; target = RegisterConstants.WORKING_REGISTER_ADDRESS; byte1 = getLiteralFromParameter(parameter); byte2 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new LogicOperation(byte1, byte2, LogOp, target, registerFileMap, address); case ParserConstants.XORWF: LogOp = LogicOperator.XOR; target = getTargetAddress(parameter); byte1 = registerFileMap.Get(getAddressFromParameter(parameter)); byte2 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new LogicOperation(byte1, byte2, LogOp, target, registerFileMap, address); case ParserConstants.XORLW: LogOp = LogicOperator.XOR; target = RegisterConstants.WORKING_REGISTER_ADDRESS; byte1 = getLiteralFromParameter(parameter); byte2 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new LogicOperation(byte1, byte2, LogOp, target, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- MOVE OPERATIONS ----------------------------- */ case ParserConstants.MOVF: target = getTargetAddress(parameter); source = getAddressFromParameter(parameter); return new MoveOperation(source, target, registerFileMap, address); case ParserConstants.MOVLW_1: case ParserConstants.MOVLW_2: case ParserConstants.MOVLW_3: case ParserConstants.MOVLW_4: byte1 = getLiteralFromParameter(parameter); target = RegisterConstants.WORKING_REGISTER_ADDRESS; return new MoveOperation(byte1, target, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- ROTATE OPERATIONS --------------------------- */ case ParserConstants.RLF: RotDir = RotationDirection.LEFT; target = getTargetAddress(parameter); source = getAddressFromParameter(parameter); return new RotateOperation(source, target, RotDir, registerFileMap, address); case ParserConstants.RRF: RotDir = RotationDirection.RIGHT; target = getTargetAddress(parameter); source = getAddressFromParameter(parameter); return new RotateOperation(source, target, RotDir, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- SWAP OPERATIONS ----------------------------- */ case ParserConstants.SWAPF: target = getTargetAddress(parameter); source = getAddressFromParameter(parameter); return new SwapOperation(source, target, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- BIT TEST OPERATIONS ----------------------------- */ case ParserConstants.DECFSZ: TestOp = TestOperator.DECFSZ; target = getTargetAddress(parameter); source = getAddressFromParameter(parameter); return new TestOperation(source, TestOp, target, programCounter, registerFileMap, address); case ParserConstants.INCFSZ: TestOp = TestOperator.INCFSZ; target = getTargetAddress(parameter); source = getAddressFromParameter(parameter); return new TestOperation(source, TestOp, target, programCounter, registerFileMap, address); case ParserConstants.BTFSC_1: case ParserConstants.BTFSC_2: case ParserConstants.BTFSC_3: case ParserConstants.BTFSC_4: BitTestOp = BitTestOperator.BTFSC; source = getAddressFromParameter(parameter); bit = getBitNumberFromOperationCall(operation, parameter); return new BitTestOperation(source, bit, BitTestOp, programCounter, registerFileMap, address); case ParserConstants.BTFSS_1: case ParserConstants.BTFSS_2: case ParserConstants.BTFSS_3: case ParserConstants.BTFSS_4: BitTestOp = BitTestOperator.BTFSS; source = getAddressFromParameter(parameter); bit = getBitNumberFromOperationCall(operation, parameter); return new BitTestOperation(source, bit, BitTestOp, programCounter, registerFileMap, address); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* -------- RETURN OPERATIONS --------------------------- */ case ParserConstants.RETLW_1: case ParserConstants.RETLW_2: case ParserConstants.RETLW_3: case ParserConstants.RETLW_4: RetOp = ReturnOperator.RETLW; byte1 = getLiteralFromParameter(parameter); return new ReturnOperation(programCounter, operationStack, RetOp, byte1, registerFileMap, address); /* ------------------------------------------------------ */ case 0x0000: if(parameter > 127) { // MOVWF target = getAddressFromParameter(parameter); byte1 = registerFileMap.Get(RegisterConstants.WORKING_REGISTER_ADDRESS); return new MoveOperation(byte1, target, registerFileMap, address); } switch (parameter) { case ParserConstants.CLRWDT: return new ClearWdtOperation(pic, registerFileMap, address); case ParserConstants.RETFIE: RetOp = ReturnOperator.RETFIE; return new ReturnOperation(programCounter, operationStack, RetOp, registerFileMap, address); case ParserConstants.RETURN: RetOp = ReturnOperator.RETURN; return new ReturnOperation(programCounter, operationStack, RetOp, registerFileMap, address); case ParserConstants.SLEEP: return new SleepOperation(pic, registerFileMap, address); case ParserConstants.NOP_1: case ParserConstants.NOP_2: case ParserConstants.NOP_3: case ParserConstants.NOP_4: return new NopOperation(registerFileMap, address); default: break; } break; default: throw new Exception("unknown operation"); } throw new Exception("unknown error"); }
public static CubeRotation ByAxis(Axis axis, RotationDirection direction) { return AllRotations.Single(r => r.Axis == axis && r.Direction == direction && r.Count == 1); }
/// <summary> /// Initializes a new instance of the <see cref="RotationEventArgs"/> class. /// </summary> /// <param name="direction">The direction of the rotation event.</param> public RotationEventArgs(RotationDirection direction) : base() { this._direction = direction; }
public static RotationDirection Reverse(RotationDirection direction) { return direction == RotationDirection.Clockwise ? RotationDirection.AntiClockwise : RotationDirection.Clockwise; }
/// <summary> /// Initializes a new <see cref="RotaryEncoderRotatedEventArgs"/> instance. /// </summary> /// <param name="direction"> /// The direction of rotation. /// </param> public RotaryEncoderRotatedEventArgs(RotationDirection direction) { this.Direction = direction; }
private void Rotation(RotationDirection direction) { const float dAngle = 150.0f; switch (direction) { case RotationDirection.left: currentRotationAngle += dAngle * Time.deltaTime; if (currentRotationAngle > rotationRange.max) { currentRotationAngle = rotationRange.max; isRuntime = false; } break; case RotationDirection.right: currentRotationAngle -= dAngle * Time.deltaTime; if (currentRotationAngle < rotationRange.min) { currentRotationAngle = rotationRange.min; isRuntime = false; } break; } transform.eulerAngles = new Vector3(0.0f, 0.0f, currentRotationAngle); }
public override void OnEnter() { base.OnEnter(); int target; var azimuth = Machine.HardwareStatus.CurrentAzimuth; /* * If the Dome Support Ring is open and we are in the Home position, * then rotation is disallowed. However, if the current azimuth equals * the target azimuth (i.e. no rotation required) then we allow the operation * to continue, so that shutter operations can complete even when DSR is open. */ if (Machine.DomeSupportRingOpen) { if (Machine.InHomeRange(azimuth) && azimuth != Machine.TargetAzimuthTicks) { Transition(new StateSendStatus(Machine)); return; } } if (Machine.TargetAzimuthTicks < Machine.HardwareStatus.CurrentAzimuth) { target = Machine.TargetAzimuthTicks + 360; } else { target = Machine.TargetAzimuthTicks; } var clockwiseDistance = target - azimuth; var counterclockwiseDistance = 360 - clockwiseDistance; // Figure out the absolute number of ticks to be moved and the direction of rotation. int delta; MotorConfiguration azimuthMotorConfiguration; if (target == azimuth) { direction = RotationDirection.Clockwise; delta = 0; azimuthMotorConfiguration = MotorConfiguration.Stopped; //ToDo: Should we emit a "R" at this point if no movement is going to happen? } else if (clockwiseDistance <= counterclockwiseDistance) { direction = RotationDirection.Clockwise; azimuthMotorConfiguration = MotorConfiguration.Forward; delta = clockwiseDistance; Machine.WriteLine("R"); } else { direction = RotationDirection.CounterClockwise; azimuthMotorConfiguration = MotorConfiguration.Reverse; delta = counterclockwiseDistance; Machine.WriteLine("L"); } Log.Debug("Rotating {0} delta={1} ticks", direction, delta); var motorEventArgs = new MotorConfigurationEventArgs { AzimuthMotor = azimuthMotorConfiguration, ShutterMotor = MotorConfiguration.Stopped }; Machine.InvokeMotorConfigurationChanged(motorEventArgs); rotationTimer.Interval = Machine.RealTime ? Properties.Settings.Default.RotationRateMsPerTick : 1; rotationTimer.Elapsed += RotationTimerElapsed; rotationTimer.Start(); }
private IEnumerator SwapCups() { ShuffleMaster.Instance.CupsMoveable = false; if (m_AdjacentCup == null) { //no swapping needed. transform.localPosition = m_OriginalPosition; yield return(null); } if (m_AdjacentCup != null) { RotationDirection dir = RotationDirection.none; RotationLane lan = RotationLane.none; //swapping needed if (m_Lifted) { int index_a = Array.IndexOf(ShuffleMaster.Instance.Cups, gameObject); int index_b = Array.IndexOf(ShuffleMaster.Instance.Cups, m_AdjacentCup); int distance = Mathf.Abs(index_a - index_b); if (index_a < index_b) { dir = RotationDirection.left; lan = RotationLane.front; } if (index_b < index_a) { dir = RotationDirection.right; lan = RotationLane.back; } //Cups are near to each other if (distance == 1) { yield return(StartCoroutine(ShuffleMaster.Instance.Cups[index_b].gameObject.GetComponent <DragMe>().MoveCupLinear(m_OriginalPosition, 0.5f))); yield return(StartCoroutine(MoveCupLinear(ShuffleMaster.Instance.Cups[index_b].GetComponent <DragMe>().m_OriginalPosition, 0.5f))); GameObject other_cup = ShuffleMaster.Instance.Cups[index_b]; ShuffleMaster.Instance.Cups[index_b] = gameObject; ShuffleMaster.Instance.Cups[index_a] = other_cup; gameObject.GetComponent <DragMe>().resetOriginalPosition(); other_cup.GetComponent <DragMe>().resetOriginalPosition(); if (m_ball != null) { m_ball.GetComponent <Renderer>().enabled = true; } } //Cups are far to each other if (distance == 2) { yield return(StartCoroutine(ShuffleMaster.Instance.Cups[index_b].gameObject.GetComponent <DragMe>().MoveCupCircular(m_OriginalPosition, 0.5f, dir, lan))); yield return(StartCoroutine(MoveCupLinear(ShuffleMaster.Instance.Cups[index_b].GetComponent <DragMe>().m_OriginalPosition, 0.5f))); GameObject other_cup = ShuffleMaster.Instance.Cups[index_b]; ShuffleMaster.Instance.Cups[index_b] = gameObject; ShuffleMaster.Instance.Cups[index_a] = other_cup; gameObject.GetComponent <DragMe>().resetOriginalPosition(); other_cup.GetComponent <DragMe>().resetOriginalPosition(); if (m_ball != null) { m_ball.GetComponent <Renderer>().enabled = true; } } } } m_Lifted = false; m_AdjacentCup = null; //gameObject.layer = LayerMask.NameToLayer("Default"); ShuffleMaster.Instance.CupsMoveable = true; yield return(null); }
/// <summary> /// Rotates the active block. /// </summary> /// <param name="rotDirection">Direction the block should be rotated in.</param> public void RotateActiveBlock(RotationDirection rotDirection) { Orientation targetOrientation = activeBlock.GetNewOrientation(rotDirection); Point kickValue = new Point(0,0); Boolean isValid = false; //Retrieve the kickdata for the desired rotation. Point[] kickData = wallKickData.GetKickData( activeBlock.BlockType, activeBlock.Orientation, targetOrientation ); foreach (Point p in kickData) { //The position of the rotated block, considering wall kick data. Point newPosition = new Point( activeBlockPosition.X + p.X, activeBlockPosition.Y + p.Y ); //A copy of the block so we can apply modifications, without changing the original object. Block rotatedBlock = (Block)activeBlock.Clone(); rotatedBlock.Orientation = targetOrientation; //Check if the rotated block is valid. If it is, store offset values and exit loop. if (BlockPositionIsValid( rotatedBlock, newPosition )) { //If a valid position is found, use this kickdata value for offsetting the block. isValid = true; kickValue = p; break; } } //Check if rotation is valid before applying. if (isValid) { //Apply the orientation changes. activeBlock.Orientation = targetOrientation; //Apply the offset to the block position. activeBlockPosition.X += kickValue.X; activeBlockPosition.Y += kickValue.Y; } }
// Instantiates a flashing laser tile and puts it in the level. public Tile LoadLaserTile(int x, int y, bool createdByEvent, bool vertical, bool flashing, RotationDirection rotationDir) { lasers.Add(new Laser(this, x, y, createdByEvent, vertical, flashing, rotationDir)); return new Tile(null, TileCollision.Passable); }
public virtual void Rotate(RotationDirection rotDir) { }
/// <summary> /// Gets the orientation of a block after a rotation. /// </summary> /// <param name="rotDirection">Direction the block should be rotated in.</param> public Orientation GetNewOrientation(RotationDirection rotDirection) { Orientation newOrientation = new Orientation(); switch (rotDirection) { case RotationDirection.ClockWise: if ((int)orientation == shapes.Count - 1) { newOrientation = 0; } else { newOrientation = orientation + 1; } break; case RotationDirection.CounterClockWise: if (orientation == 0) { newOrientation = (Orientation)shapes.Count - 1; } else { newOrientation = orientation - 1; } break; } return newOrientation; }
/// <summary> /// Rotates the brush in the given direction. /// </summary> /// <param name="direction">Direction to rotate by.</param> /// <param name="layout">Cell Layout for rotating.</param> public override void Rotate(RotationDirection direction, GridLayout.CellLayout layout) { var angle = layout == GridLayout.CellLayout.Hexagon ? 60f : 90f; m_Rotation = Quaternion.Euler(0f, 0f, direction == RotationDirection.Clockwise ? m_Rotation.eulerAngles.z + angle : m_Rotation.eulerAngles.z - angle); }
void GetInput() { forwardInput = 0;// Input.GetAxis("Horizontal"); if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { forwardInput = -1; } if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) { forwardInput = 1; } if (grounded) { if (facingForward && forwardInput < 0) { transform.rotation *= Quaternion.AngleAxis(-180, Vector3.up); facingForward = false; } else if (!facingForward && forwardInput > 0) { transform.rotation *= Quaternion.AngleAxis(180, Vector3.up); facingForward = true; } } wasGrounded = false; if (Input.GetKeyUp(KeyCode.E)) { //Changing GravityDirection sets gravityChanged to true GravityDirection = GravityDirection.TurnClockwise(); lastTurnDirection = RotationDirection.Clockwise; startRotationTime = Time.realtimeSinceStartup; if (grounded) { wasGrounded = true; //transform.position += transform.localScale.y * transform.up.normalized; grounded = false; } lastVelocity = rBody.velocity; rBody.velocity = Vector3.zero; forwardInput = 0; } if (Input.GetKeyUp(KeyCode.Q)) { //Changing GravityDirection sets gravityChanged to true GravityDirection = GravityDirection.TurnCounterClockwise(); lastTurnDirection = RotationDirection.CounterClockwise; startRotationTime = Time.realtimeSinceStartup; if (grounded) { wasGrounded = true; //transform.position += transform.localScale.y * transform.up.normalized; grounded = false; } lastVelocity = rBody.velocity; rBody.velocity = Vector3.zero; forwardInput = 0; } }
private void SetRotationDirection(RotationDirection direction) { CounterClockwiseAnnunciator.Mute = direction != RotationDirection.CounterClockwise; ClockwiseAnnunciator.Mute = direction != RotationDirection.Clockwise; }
private bool canRotate(RotationDirection direction) { if (currentRotationDirection != RotationDirection.None) return false; // If not finished rotating, ignore new requests // If trying to rotate clockwise, check for cliff ahead if (direction == RotationDirection.Clockwise) { // Check for wall first because that check is more accurate return !checkForUpcomingWall() && checkForUpcomingCliff(); } else if (direction == RotationDirection.Anticlockwise) { return checkForUpcomingWall(); } return false; }
public Slice_sequence Run(Branch root, double tool_r, double max_ted, double min_ted, RotationDirection dir) { _min_ted = min_ted; _max_ted = max_ted; _tool_r = tool_r; _dir = dir; Slice root_slice = new Slice(root.Start, Get_radius(root.Start), _dir == RotationDirection.Unknown ? RotationDirection.CCW : _dir); _sequence.Add(root_slice); trace_branch(root, root_slice); return(_sequence); }
public static CompositeBodyTransform RotateTransform(JointType jointType, int degrees, BodyPlaneType plane, RotationDirection direction) { return(new CompositeBodyTransform(jointType, new RotateJointTransform(degrees, plane, direction))); }
/// <summary> /// Ensures that every member along a rotation path has had its mesh face constructed and placed in the viewport. /// </summary> private void EnsurePathCalculated(int rotationCount, RotationDirection rotationDirection) { //start ensuring visibility on the face after the current one in the direction of rotation int current = AdjustIndex(this.currentFaceIndex, rotationDirection); for (int i = 0; i < rotationCount; i++) { EnsureFaceCalculated(current); current = AdjustIndex(current, rotationDirection); } //for n-gons greater than 4 sides we need to ensure that the faces on both sides of the current face are calculated //even though we are only rotating in one direction. Otherwise you get a weird view on that missing side since it is //partially visible when we zoom out, we also need to do the same thing for the target face so its "next" side //isn't missing if (Items.Count > 4) { EnsureSurroundingFacesCalculated(this.currentFaceIndex, rotationDirection); EnsureFaceCalculated(current); } }
public virtual void Rotate(RotationDirection direction) { // Do nothing! }
static public CardinalOrdinalDirection GetNext(this CardinalOrdinalDirection item, RotationDirection direction) { switch (direction) { case RotationDirection.Clockwise: return(item.GetClockwiseNext()); case RotationDirection.CounterClockwise: return(item.GetCounterClockwiseNext()); } throw new UnaccountedBranchException("direction", direction); }
// // ANIMATION COROUTINES // IEnumerator rotationAnimation(Quaternion from, Quaternion to) { immune = true; for (float i = 0.0f; i < 1.0f; i += Time.deltaTime / rotationTime) { transform.rotation = Quaternion.Slerp(from, to, i); yield return new WaitForSeconds(0); } currentRotation = targetRotation; currentRotationDirection = RotationDirection.None; transform.rotation = to; // Restore pre-rotation speed rigidbody2D.velocity = transform.right * preRotationVelocity * postRotationBoostFraction; immune = false; }
/// <summary> /// Rotates the segments of a given channel in the VisiLED controller. /// </summary> /// <param name="channel">The channel to apply the rotation too.</param> /// <param name="direction">The direction of rotation (CW or CCW)</param> /// <param name="count">How many segments to rotate by, 1 segment by default.</param> public void Rotate(Channel channel, RotationDirection direction, int count = 1) { CurrentConnection?.Rotate(channel, direction, count); }
public static BodyTransform RotateTransform(JointType jointType, int angle, BodyPlaneType plane, RotationDirection direction) { return new BodyTransform(jointType, new RotateJointTransform(angle, plane, direction)); }
/// <summary> /// When the <c>RotationDirection</c> changed /// </summary> /// <param name="obj">The <c>ViewFlipper</c></param> /// <param name="oldValue">Old value</param> /// <param name="newValue">New value</param> private static void RotationDirectionChanged(BindableObject obj, RotationDirection oldValue, RotationDirection newValue) { ViewFlipper flipper = obj as ViewFlipper; if (flipper == null || flipper.BackView == null) return; flipper.SetBackviewRotation(); }
private static async Task MoveWhiteFromMiddleLayer(CubeConfiguration<FaceColour> configuration, FaceType faceType, ICollection<IRotation> solution, RelativePosition relativePosition, Edge edge, RotationDirection downDirection) { var joiningFace = FaceRules.FaceAtRelativePositionTo(faceType, relativePosition); var joiningColour = configuration.Faces[joiningFace].GetEdge(edge).Centre(); var faceWithJoiningColour = FaceRules.GetFaceOfColour(joiningColour, configuration); var relativePostion = FaceRules.RelativePositionBetweenFaces(faceWithJoiningColour, joiningFace); switch (relativePostion) { case RelativePosition.Same: await CommonActions.ApplyAndAddRotation(Rotations.ByFace(joiningFace, downDirection), solution, configuration).ConfigureAwait(false); break; case RelativePosition.Left: case RelativePosition.Right: case RelativePosition.Opposite: // TODO: ROTATE SO THAT WE ARE ONLY DOING RIGHT... MOVES await CommonActions.ApplyAndAddRotation(Rotations.ByFace(joiningFace, RotationDirectionEx.Reverse(downDirection)), solution, configuration).ConfigureAwait(false); await CommonActions.ApplyAndAddRotation(Rotations.UpperAntiClockwise, solution, configuration).ConfigureAwait(false); await CommonActions.ApplyAndAddRotation(Rotations.ByFace(joiningFace, downDirection), solution, configuration).ConfigureAwait(false); await CheckTopFaceForWhite(configuration, joiningFace, solution).ConfigureAwait(false); break; } }
/// <summary> /// Finds the adjacent surface to the one that the player is on. /// </summary> /// <param name="origin">The place from which the scanning ray is cast</param> /// <param name="direction"></param> /// <param name="turnDirection"></param> public void FindAdjacentSurface(Vector3 origin, Vector3 direction, RotationDirection turnDirection) { RaycastHit hit; float distance = direction.magnitude; // use recursion to raycast vectors to find the adjacent wall Debug.DrawRay(origin, direction, Color.green, Time.deltaTime); if (Physics.Raycast(origin, direction, out hit, distance) && (hit.collider.gameObject.GetComponent <MeshCollider>() != null)) { // normal vector of raycasthit Debug.DrawRay(hit.point, hit.normal); Ray adjSurfaceRay; switch (turnDirection) { case RotationDirection.XZClockwise: adjSurfaceRay = new Ray(hit.point, Vector3.Cross(hit.normal, Vector3.up)); break; case RotationDirection.XZCounterClockwise: adjSurfaceRay = new Ray(hit.point, Vector3.Cross(Vector3.up, hit.normal)); break; case RotationDirection.YZClockwise: adjSurfaceRay = new Ray(hit.point, Vector3.Cross(-hit.normal, transform.right)); break; case RotationDirection.YZCounterClockwise: adjSurfaceRay = new Ray(hit.point, Vector3.Cross(transform.right, -hit.normal)); break; default: adjSurfaceRay = new Ray(); break; } Debug.DrawRay(adjSurfaceRay.origin, adjSurfaceRay.direction, Color.cyan); int turns = turnCount; turnCount = 0; AssignAdjacentSurface(new AdjacentSurface(adjSurfaceRay, -hit.normal, turns, hit.distance), turnDirection); } else { turnCount++; if (turnCount < 4) { // find next vector info now Vector3 lastOrigin = origin; origin = origin + direction; Vector3 lastDirection = lastOrigin - origin; Vector3 nextDirection = Vector3.zero; switch (turnDirection) { case RotationDirection.XZClockwise: nextDirection = Vector3.Cross(lastDirection, Vector3.up).normalized *distance; break; case RotationDirection.XZCounterClockwise: nextDirection = Vector3.Cross(Vector3.up, lastDirection).normalized *distance; break; case RotationDirection.YZClockwise: nextDirection = Vector3.Cross(lastDirection, transform.right).normalized *distance; if (turnCount == 3) { // special Case: at top tip of a C-shaped scan looking for wall to climb onto, // Need to check if there is a slanted-eaved roof to climb onto the edge of. // upward rappel movement puts the player on side of eave and triggers climbing // need to scan diagonally forward down nextDirection = Vector3.Reflect((lastDirection + nextDirection).normalized, lastDirection); } break; case RotationDirection.YZCounterClockwise: nextDirection = Vector3.Cross(transform.right, lastDirection).normalized *distance; // TODO: write code to make a diagonal upwards forward check for turncount 3 to find // a ceiling under the wall the player is climbing on. Could possibly be another wall // to rappel onto? if (turnCount == 3) { nextDirection = Vector3.Reflect((lastDirection + nextDirection).normalized, lastDirection); } break; default: nextDirection = Vector3.zero; break; } FindAdjacentSurface(origin, nextDirection, turnDirection); } turnCount = 0; AssignAdjacentSurface(null, turnDirection); } }
public RotateJointTransform(int degrees, BodyPlaneType plane, RotationDirection rotationDirection = RotationDirection.Clockwise) : base(joint => { double cosInput = TrigonometryHelper.GetCosine(degrees); double sinInput = TrigonometryHelper.GetSine(degrees); if (rotationDirection == RotationDirection.CounterClockwise) sinInput = -sinInput; var cos = Z3Math.Real(cosInput); var sin = Z3Math.Real(sinInput); var sinNeg = Z3Math.Real(-sinInput); Z3Point3D result = new Z3Point3D(joint.X, joint.Y, joint.Z); switch (plane) { case BodyPlaneType.Frontal: result.Y = Z3Math.Add(Z3Math.Mul(cos, joint.Y), Z3Math.Mul(sin, joint.Z)); result.Z = Z3Math.Add(Z3Math.Mul(sinNeg, joint.Y), Z3Math.Mul(cos, joint.Z)); break; case BodyPlaneType.Sagittal: result.X = Z3Math.Add(Z3Math.Mul(cos, joint.X), Z3Math.Mul(sin, joint.Y)); result.Y = Z3Math.Add(Z3Math.Mul(sinNeg, joint.X), Z3Math.Mul(cos, joint.Y)); break; case BodyPlaneType.Horizontal: result.X = Z3Math.Add(Z3Math.Mul(cos, joint.X), Z3Math.Mul(sin, joint.Z)); result.Z = Z3Math.Add(Z3Math.Mul(sinNeg, joint.X), Z3Math.Mul(cos, joint.Z)); break; default: break; } return result; }) { }
// change what the values are restored to on a reset public virtual void updateInitialValues() { m_initialPosition = new Vector2(m_position.X, m_position.Y); m_initialVelocity = new Vector2(m_velocity.X, m_velocity.Y); m_initialAcceleration = m_acceleration; m_initialRotation = m_rotation; m_initialRotationSpeed = m_rotationSpeed; m_initialRotationDirection = m_rotationDirection; m_initialScale = new Vector2(m_scale.X, m_scale.Y); m_initialScaleSpeed = m_scaleSpeed; m_initialScaleDirection = m_scaleDirection; }
public void shift(RotationDirection direction) { StartCoroutine(shiftAnimation(direction)); }
public void AddMove(AnimationSpecification animationSpecification) { RotationDirection rotationDirection = animationSpecification.rotationDirection; CubeAxis cubeAxis = animationSpecification.cubeAxis; CubeSlices cubeSlices = animationSpecification.cubeSlices; MoveType moveType = animationSpecification.moveType; string s = ""; switch (cubeAxis) { case CubeAxis.x: s = "x"; break; case CubeAxis.y: s = "y"; break; case CubeAxis.z: s = "z"; break; } switch (cubeSlices) { case CubeSlices.s0: s += "0"; break; case CubeSlices.s01: s += "01"; break; case CubeSlices.s1: s += "1"; break; case CubeSlices.s2: s += "2"; break; case CubeSlices.s3: s += "3"; break; case CubeSlices.s34: s += "34"; break; case CubeSlices.s4: s += "4"; break; case CubeSlices.s01234: s += "01234"; break; } if (rotationDirection == RotationDirection.reverse) { s += "R"; } if (moveType == MoveType.doubleMove) { s += "D"; } GameObject g1 = Instantiate(prefab); g1.gameObject.transform.SetParent(contentRect, false); g1.SetActive(true); var g1m = g1.GetComponent <MyMove>(); g1m.text.text = " " + s; Canvas.ForceUpdateCanvases(); contentObj.GetComponent <VerticalLayoutGroup>().CalculateLayoutInputVertical(); contentObj.GetComponent <ContentSizeFitter>().SetLayoutVertical(); sr.content.GetComponent <VerticalLayoutGroup>().CalculateLayoutInputVertical(); sr.content.GetComponent <ContentSizeFitter>().SetLayoutVertical(); sr.normalizedPosition = new Vector2(0, 0); _numMoves++; SetTitle(); }
public virtual bool OnRotate(RotationDirection direction) { return(false); }
public override void Rotate(RotationDirection direction, Grid.CellLayout layout) { Debug.Log("Rotate not supported for GridObjects, set their initial orientation on the editor instead"); }
public Slice(Slice parent, Point2F center, double radius, RotationDirection dir, double tool_r, Point2F magnet) { _parent = parent; _ball = new Circle2F(center, radius); double dist = Point2F.Distance(center, parent.Center); double delta_r = this.Radius - parent.Radius; double coarse_ted = dist + delta_r; // 1) one ball is inside other, no intersections // 2) balls are spaced too far and do not intersect, TED is 0, distance is positive // 3) balls are intersect, TED is valid if (dist <= Math.Abs(delta_r)) { _placement = Slice_placement.INSIDE_ANOTHER; return; } if (dist >= this.Radius + parent.Radius) { _placement = Slice_placement.TOO_FAR; return; } // TED can't be more >= tool diameter, this check prevents fails during the calculation of real angle-based TED if (coarse_ted > tool_r * 1.999) { _placement = Slice_placement.TOO_FAR; return; } Line2F insects = _parent.Ball.CircleIntersect(this._ball); if (insects.p1.IsUndefined || insects.p2.IsUndefined) { // try to return meaningful result even if CB routine had failed (unlikely) Logger.err("no intersections found there intersections should be (_parent.Ball.CircleIntersect(_ball))"); _placement = (dist <= this.Radius || dist <= parent.Radius) ? Slice_placement.INSIDE_ANOTHER : Slice_placement.TOO_FAR; return; } _placement = Slice_placement.NORMAL; Vector2d v_move = new Vector2d(_parent.Center, this.Center); Vector2d v1 = new Vector2d(_parent.Center, insects.p1); RotationDirection default_dir = v_move.Det(v1) > 0 ? RotationDirection.CW : RotationDirection.CCW; if (dir == RotationDirection.Unknown) { if (magnet.IsUndefined) { dir = RotationDirection.CCW; // just something } else { if (insects.p1.DistanceTo(magnet) < insects.p2.DistanceTo(magnet)) // match, use existing dir { dir = default_dir; } else { dir = (default_dir == RotationDirection.CCW) ? RotationDirection.CW : RotationDirection.CCW; // flip } } } Arc2F arc; if (default_dir == dir) { arc = new Arc2F(this.Center, insects.p1, insects.p2, dir); } else { arc = new Arc2F(this.Center, insects.p2, insects.p1, dir); } _segments.Add(arc); calc_teds(tool_r); if (_mid_ted <= 0) { Logger.warn("forced to patch mid_ted"); _mid_ted = coarse_ted; // shouldn't be, but ok } _max_ted = Math.Max(_mid_ted, _entry_ted); }
//rotate the rotating child object in a given direction at a frequency given in degrees per second public void RotateCharacter(RotationDirection newRotationDirection, float rotationSpeed) { rotatingChildObject.transform.Rotate(new Vector3(0, 0, (rotationSpeed * RotationDirectionEnumToFloat(newRotationDirection) * Time.fixedDeltaTime))); }
public Slice(Point2F center, double radius, RotationDirection dir) { _ball = new Circle2F(center, radius); _placement = Slice_placement.NORMAL; create_arc_circle(new Point2F(center.X + radius, center.Y), dir); }
public RotaryEncoderPositionChangedEventArgs(RotationDirection direction) { RotationDirection = direction; }
static private double angle_between_vectors(Vector2d v0, Vector2d v1, RotationDirection dir) { double angle = v0.Ccw_angle_to(v1); return((dir == RotationDirection.CCW) ? angle : (2.0 * Math.PI - angle)); }
private HashSet<Move> getNextPossibleMoves(HashSet<Move>moves, Move m, RotationDirection direction) { //HashSet<Move> iMoves = new HashSet<Move>(moves); Dictionary<Move, List<List<Move>>> substitutions = new Dictionary<Move, List<List<Move>>> { {Move.F, new List<List<Move>>{ new List<Move>{Move.U, Move.L, Move.U, Move.R}, new List<Move>{Move.U, Move.R, Move.D, Move.R}, new List<Move>{Move.D, Move.R, Move.D, Move.L}, new List<Move>{Move.D, Move.L, Move.U, Move.L}, new List<Move>{Move.U, Move.M, Move.E, Move.R}, new List<Move>{Move.E, Move.R, Move.M, Move.D}, new List<Move>{Move.M, Move.D, Move.L, Move.E}, new List<Move>{Move.L, Move.E, Move.U, Move.M}, }}, {Move.B, new List<List<Move>>{ new List<Move>{Move.R, Move.U, Move.L, Move.U}, new List<Move>{Move.R, Move.D, Move.R, Move.U}, new List<Move>{Move.L, Move.D, Move.R, Move.D}, new List<Move>{Move.L, Move.U, Move.L, Move.D}, new List<Move>{Move.R, Move.E, Move.M, Move.U}, new List<Move>{Move.D, Move.M, Move.R, Move.E}, new List<Move>{Move.E, Move.L, Move.D, Move.M}, new List<Move>{Move.M, Move.U, Move.E, Move.L}, }}, {Move.U, new List<List<Move>>{ new List<Move>{Move.B, Move.L, Move.B, Move.R}, new List<Move>{Move.B, Move.R, Move.F, Move.R}, new List<Move>{Move.F, Move.R, Move.F, Move.L}, new List<Move>{Move.F, Move.L, Move.B, Move.L}, new List<Move>{Move.B, Move.M, Move.S, Move.R}, new List<Move>{Move.S, Move.R, Move.M, Move.F}, new List<Move>{Move.M, Move.F, Move.L, Move.S}, new List<Move>{Move.L, Move.S, Move.B, Move.M}, }}, {Move.D, new List<List<Move>>{ new List<Move>{Move.R, Move.B, Move.L, Move.B}, new List<Move>{Move.R, Move.F, Move.R, Move.B}, new List<Move>{Move.L, Move.F, Move.R, Move.F}, new List<Move>{Move.L, Move.B, Move.L, Move.F}, new List<Move>{Move.R, Move.S, Move.M, Move.B}, new List<Move>{Move.F, Move.M, Move.R, Move.S}, new List<Move>{Move.S, Move.L, Move.F, Move.M}, new List<Move>{Move.M, Move.B, Move.S, Move.L}, }}, {Move.L, new List<List<Move>>{ new List<Move>{Move.B, Move.U, Move.F, Move.U}, new List<Move>{Move.F, Move.U, Move.F, Move.D}, new List<Move>{Move.F, Move.D, Move.B, Move.D}, new List<Move>{Move.B, Move.D, Move.B, Move.U}, new List<Move>{Move.S, Move.U, Move.E, Move.F}, new List<Move>{Move.E, Move.F, Move.D, Move.S}, new List<Move>{Move.D, Move.S, Move.B, Move.E}, new List<Move>{Move.B, Move.E, Move.S, Move.U}, }}, {Move.R, new List<List<Move>>{ new List<Move>{Move.U, Move.F, Move.U, Move.B}, new List<Move>{Move.D, Move.F, Move.U, Move.F}, new List<Move>{Move.D, Move.B, Move.D, Move.F}, new List<Move>{Move.U, Move.B, Move.D, Move.B}, new List<Move>{Move.F, Move.E, Move.U, Move.S}, new List<Move>{Move.S, Move.D, Move.F, Move.E}, new List<Move>{Move.E, Move.B, Move.S, Move.D}, new List<Move>{Move.U, Move.S, Move.E, Move.B}, }}, {Move.M, new List<List<Move>>{ new List<Move>{Move.U, Move.F, Move.D, Move.F}, new List<Move>{Move.D, Move.F, Move.D, Move.B}, new List<Move>{Move.B, Move.D, Move.B, Move.U}, new List<Move>{Move.B, Move.U, Move.F, Move.U}, new List<Move>{Move.E, Move.F, Move.D, Move.S}, new List<Move>{Move.D, Move.S, Move.B, Move.E}, new List<Move>{Move.B, Move.E, Move.U, Move.S}, new List<Move>{Move.U, Move.S, Move.E, Move.F}, }}, {Move.E, new List<List<Move>>{ new List<Move>{Move.L, Move.F, Move.R, Move.F}, new List<Move>{Move.R, Move.F, Move.R, Move.B}, new List<Move>{Move.R, Move.B, Move.L, Move.B}, new List<Move>{Move.L, Move.B, Move.L, Move.F}, new List<Move>{Move.M, Move.F, Move.R, Move.S}, new List<Move>{Move.R, Move.S, Move.B, Move.M}, new List<Move>{Move.B, Move.M, Move.L, Move.S}, new List<Move>{Move.L, Move.S, Move.M, Move.F}, }}, {Move.S, new List<List<Move>>{ new List<Move>{Move.U, Move.R, Move.D, Move.R}, new List<Move>{Move.D, Move.R, Move.D, Move.L}, new List<Move>{Move.D, Move.L, Move.U, Move.L}, new List<Move>{Move.U, Move.L, Move.U, Move.R}, new List<Move>{Move.M, Move.U, Move.E, Move.R}, new List<Move>{Move.E, Move.R, Move.M, Move.D}, new List<Move>{Move.M, Move.D, Move.E, Move.L}, new List<Move>{Move.E, Move.L, Move.M, Move.U}, }}, }; foreach (List<Move> s in substitutions[m]) { if (direction == RotationDirection.ClockWise) { if (moves.Contains(s[0]) && moves.Contains(s[1])) { moves.Remove(s[0]); moves.Add(s[2]); moves.Remove(s[1]); moves.Add(s[3]); break; } } else { if (moves.Contains(s[2]) && moves.Contains(s[3])) { moves.Remove(s[2]); moves.Add(s[0]); moves.Remove(s[3]); moves.Add(s[1]); break; } } } /* if (moves.Count != 3) { if(true){} } */ return moves; }
// simple Archimedean spiral: // r = a * theta + c // // in cartesian coordinates: // x = center_x + (a * theta + c) * cos(theta) // y = center_y + (a * theta + c) * sin(theta) // // tangent vector (derivate relative to theta): // x' = a * cos(theta) - sin(theta) * r // y' = a * sin(theta) + cos(theta) * r // we output biarcs to approximate spiral, 6 biarcs (12 arcs) per loop. // real number of biarcs would be more, since in general case there would be incomplete loops // last biarc is exact to the endpoint // if start tangent is defined, spiral will start from it (spacing will be reduced a little to make a fit). // otherwise start tangent is choosed automatically and spacing is exact. public static List <Biarc2d> Gen_archimedean_spiral(Point2F center, Point2F end, Vector2d start_tangent, double spacing, RotationDirection dir) { double r_max = center.DistanceTo(end); Vector2d v_end = new Vector2d(center, end); double theta_end = v_end.Ccw_angle; double theta_step = 2 * Math.PI / 6; double a = spacing / (2 * Math.PI); double theta_start; if (dir == RotationDirection.CW) { a = -a; theta_step = -theta_step; } if (double.IsNaN(start_tangent.X)) { theta_start = theta_end - r_max / a; } else { theta_start = start_tangent.Ccw_angle; double candidate_a; if (dir == RotationDirection.CCW) { while (theta_start >= theta_end) { theta_start -= 2 * Math.PI; } while (true) { candidate_a = r_max / (theta_end - theta_start); if (candidate_a <= a) { break; } theta_start -= 2 * Math.PI; } } else { while (theta_start <= theta_end) { theta_start += 2 * Math.PI; } while (true) { candidate_a = r_max / (theta_end - theta_start); if (candidate_a >= a) { break; } theta_start += 2 * Math.PI; } } a = candidate_a; } int nsegments = (int)Math.Floor((theta_end - theta_start) / theta_step); double c = -theta_start * a; Point2F p1 = new Point2F(); Vector2d t1 = new Vector2d(); List <Biarc2d> spiral = new List <Biarc2d>(); for (int segidx = 0; segidx < nsegments; segidx++) { double theta = theta_start + segidx * theta_step; double r = a * theta + c; double sin = Math.Sin(theta); double cos = Math.Cos(theta); Point2F p2 = center + new Point2F(r * cos, r * sin); Vector2d t2 = new Vector2d(a * cos - r * sin, a * sin + r * cos).Unit(); if (dir == RotationDirection.CW) { t2 = t2.Inverted(); } if (segidx != 0) { spiral.Add(new Biarc2d(p1, t1, p2, t2)); } p1 = p2; t1 = t2; } Vector2d t_end = v_end.Normal().Unit(); if (dir == RotationDirection.CW) { t_end = t_end.Inverted(); } spiral.Add(new Biarc2d(p1, t1, end, t_end)); return(spiral); }
/// <summary> /// 指定された方向にテトリミノを回転させます。 /// </summary> /// <param name="direction">回転方向</param> public void RotationTetrimino(RotationDirection direction) => this.Field.RotationTetrimino(direction);
internal Wrapper(RotationDirection dir) { this.value = dir; }
public void PlacePrefabs() { if (prefab == null) { prefab = Resources.Load("Prefabs/Low Poly/Concrete Barrier") as GameObject; } for (int i = transform.GetChild(1).childCount - 1; i >= 0; i--) { DestroyImmediate(transform.GetChild(1).GetChild(i).gameObject); } if (fillGap == true && rotationDirection != PrefabLineCreator.RotationDirection.left && rotationDirection != PrefabLineCreator.RotationDirection.right) { rotationDirection = PrefabLineCreator.RotationDirection.left; } if (transform.GetChild(0).childCount > 2) { PointPackage currentPoints = CalculatePoints(); for (int j = 0; j < currentPoints.prefabPoints.Length; j++) { GameObject placedPrefab; if (j == 0 && startPrefab != null) { placedPrefab = Instantiate(startPrefab); } else if (j == currentPoints.prefabPoints.Length - 1 && endPrefab != null) { placedPrefab = Instantiate(endPrefab); } else { placedPrefab = Instantiate(prefab); } placedPrefab.transform.SetParent(transform.GetChild(1)); placedPrefab.transform.position = Misc.GetCenter(currentPoints.startPoints[j], currentPoints.endPoints[j]); placedPrefab.name = "Prefab"; placedPrefab.layer = globalSettings.roadLayer; placedPrefab.transform.localScale = new Vector3(scale, scale, scale); Vector3 left = Misc.CalculateLeft(currentPoints.startPoints[j], currentPoints.endPoints[j]); Vector3 forward = new Vector3(left.z, 0, -left.x); if (rotateAlongCurve == true) { if (rotationDirection == PrefabLineCreator.RotationDirection.forward) { placedPrefab.transform.rotation = Quaternion.Euler(Quaternion.LookRotation(forward).eulerAngles.x, Quaternion.LookRotation(forward).eulerAngles.y + Random.Range(-yRotationRandomization / 2, yRotationRandomization / 2), Quaternion.LookRotation(forward).eulerAngles.z); } else if (rotationDirection == PrefabLineCreator.RotationDirection.backward) { placedPrefab.transform.rotation = Quaternion.Euler(Quaternion.LookRotation(-forward).eulerAngles.x, Quaternion.LookRotation(-forward).eulerAngles.y + Random.Range(-yRotationRandomization / 2, yRotationRandomization / 2), Quaternion.LookRotation(-forward).eulerAngles.z); } else if (rotationDirection == PrefabLineCreator.RotationDirection.left) { placedPrefab.transform.rotation = Quaternion.Euler(Quaternion.LookRotation(left).eulerAngles.x, Quaternion.LookRotation(left).eulerAngles.y + Random.Range(-yRotationRandomization / 2, yRotationRandomization / 2), Quaternion.LookRotation(left).eulerAngles.z); } else if (rotationDirection == PrefabLineCreator.RotationDirection.right) { placedPrefab.transform.rotation = Quaternion.Euler(Quaternion.LookRotation(-left).eulerAngles.x, Quaternion.LookRotation(-left).eulerAngles.y + Random.Range(-yRotationRandomization / 2, yRotationRandomization / 2), Quaternion.LookRotation(-left).eulerAngles.z); } } if (bendObjects == true) { Mesh mesh = GameObject.Instantiate(placedPrefab.GetComponent <MeshFilter>().sharedMesh); Vector3[] vertices = mesh.vertices; float distanceToChange = Mathf.Abs((Quaternion.Euler(0, -placedPrefab.transform.rotation.eulerAngles.y, 0) * placedPrefab.transform.position).z - (Quaternion.Euler(0, -placedPrefab.transform.rotation.eulerAngles.y, 0) * currentPoints.prefabPoints[j]).z); Vector3 controlPoint; if (currentPoints.rotateTowardsLeft[j] == false) { distanceToChange = -distanceToChange; } controlPoint = mesh.bounds.center + new Vector3(0, 0, distanceToChange * 4); for (var i = 0; i < vertices.Length; i++) { float distance = Mathf.Abs(vertices[i].x - mesh.bounds.min.x); float distanceCovered = (distance / mesh.bounds.size.x); Vector3 lerpedPoint = Misc.Lerp3(new Vector3(-mesh.bounds.extents.x, 0, 0), controlPoint, new Vector3(mesh.bounds.extents.x, 0, 0), distanceCovered); vertices[i].z = vertices[i].z - (lerpedPoint).z; } mesh.vertices = vertices; mesh.RecalculateBounds(); placedPrefab.GetComponent <MeshFilter>().sharedMesh = mesh; // Change collider to match System.Type type = placedPrefab.GetComponent <Collider>().GetType(); if (type != null) { DestroyImmediate(placedPrefab.GetComponent <Collider>()); placedPrefab.AddComponent(type); } } if (yModification != PrefabLineCreator.YModification.none) { Vector3[] vertices = placedPrefab.GetComponent <MeshFilter>().sharedMesh.vertices; float startHeight = currentPoints.startPoints[j].y; float endHeight = currentPoints.endPoints[j].y; for (var i = 0; i < vertices.Length; i++) { if (yModification == PrefabLineCreator.YModification.matchTerrain) { RaycastHit raycastHit; if (Physics.Raycast(placedPrefab.transform.position + (placedPrefab.transform.rotation * vertices[i] * scale) + new Vector3(0, terrainCheckHeight, 0), Vector3.down, out raycastHit, 100f, ~(1 << globalSettings.ignoreMouseRayLayer | 1 << globalSettings.roadLayer))) { vertices[i].y += (raycastHit.point.y - placedPrefab.transform.position.y) / scale; } } else if (yModification == PrefabLineCreator.YModification.matchCurve) { float time = Misc.Remap(vertices[i].x, placedPrefab.GetComponent <MeshFilter>().sharedMesh.bounds.min.x, placedPrefab.GetComponent <MeshFilter>().sharedMesh.bounds.max.x, 0, 1); if (rotationDirection == PrefabLineCreator.RotationDirection.right) { time = 1 - time; } vertices[i].y += (Mathf.Lerp(startHeight, endHeight, time) - placedPrefab.transform.position.y) / scale; } } Mesh mesh = Instantiate(placedPrefab.GetComponent <MeshFilter>().sharedMesh); mesh.vertices = vertices; placedPrefab.GetComponent <MeshFilter>().sharedMesh = mesh; placedPrefab.GetComponent <MeshFilter>().sharedMesh.RecalculateBounds(); // Change collider to match System.Type type = placedPrefab.GetComponent <Collider>().GetType(); if (type != null) { DestroyImmediate(placedPrefab.GetComponent <Collider>()); placedPrefab.AddComponent(type); } } if (fillGap == true && j > 0) { // Add last vertices List <Vector3> lastVertexPositions = new List <Vector3>(); Vector3[] lastVertices = transform.GetChild(1).GetChild(j - 1).GetComponent <MeshFilter>().sharedMesh.vertices; for (int i = 0; i < lastVertices.Length; i++) { if (Mathf.Abs(lastVertices[i].x - GetMaxX()) < 0.001f) { lastVertexPositions.Add((transform.GetChild(1).GetChild(j - 1).transform.rotation *(scale * lastVertices[i])) + transform.GetChild(1).GetChild(j - 1).transform.position); } } // Move current vertices to last ones Mesh mesh = Instantiate(placedPrefab.GetComponent <MeshFilter>().sharedMesh); Vector3[] vertices = mesh.vertices; for (int i = 0; i < vertices.Length; i++) { if (Mathf.Abs(vertices[i].x - GetMinX()) < 0.001f) { Vector3 nearestVertex = Vector3.zero; float currentDistance = float.MaxValue; for (int k = 0; k < lastVertexPositions.Count; k++) { float localZ = (Quaternion.Euler(0, -(transform.GetChild(1).GetChild(j - 1).transform.rotation.eulerAngles.y), 0) * (lastVertexPositions[k] - transform.GetChild(1).GetChild(j - 1).transform.position)).z; float zDifference = Mathf.Abs(localZ - (vertices[i].z * scale)); if (zDifference < 0.001f) { if (yModification == PrefabLineCreator.YModification.none) { if (Mathf.Abs(lastVertexPositions[k].y - ((vertices[i].y * scale) + placedPrefab.transform.position.y)) < currentDistance) { nearestVertex = lastVertexPositions[k]; currentDistance = Mathf.Abs(lastVertexPositions[k].y - ((vertices[i].y * scale) + placedPrefab.transform.position.y)); } } else { float calculatedDistance = Vector3.Distance(lastVertexPositions[k], (placedPrefab.transform.rotation * (scale * vertices[i])) + placedPrefab.transform.position); if (calculatedDistance < currentDistance) { currentDistance = calculatedDistance; nearestVertex = lastVertexPositions[k]; } } } } if (nearestVertex != Vector3.zero) { float scaleModifier = 1 / scale; vertices[i] = Quaternion.Euler(0, -placedPrefab.transform.rotation.eulerAngles.y, 0) * (nearestVertex - placedPrefab.transform.position) * scaleModifier; } } } mesh.vertices = vertices; placedPrefab.GetComponent <MeshFilter>().sharedMesh = mesh; placedPrefab.GetComponent <MeshFilter>().sharedMesh.RecalculateBounds(); // Change collider to match System.Type type = placedPrefab.GetComponent <Collider>().GetType(); if (type != null) { DestroyImmediate(placedPrefab.GetComponent <Collider>()); placedPrefab.AddComponent(type); } } } } }
/// <summary> /// Constructor for SensorVectorEventArgs objects. /// </summary> /// <param name="lastValue">Last sensor value sent through the eventing mechanism.</param> /// <param name="currentValue">Current sensor reading.</param> public RotaryTurnedEventArgs(RotationDirection direction) { Direction = direction; }
/// <summary> /// Rotate <see cref="numRevolutions"/> times with provided parameters. /// </summary> /// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns> public static TransformSequence <T> Spin <T>(this T drawable, double revolutionDuration, RotationDirection direction, float startRotation, int numRevolutions) where T : Drawable => drawable.Delay(0).Spin(revolutionDuration, direction, startRotation, numRevolutions);
/// <summary> /// Adjusts the given index based on the given rotation direction handling wrapping the count to make sure it is never less than /// 0 or greater than (Items.Count-1) /// </summary> private int AdjustIndex(int index, RotationDirection rotationDirection) { int newIndex; if (rotationDirection == RotationDirection.Forward) { newIndex = (index + 1) % Items.Count; } else { newIndex = (index != 0) ? index - 1 : Items.Count - 1; } return newIndex; }
public Slice_sequence Run(List <Point2F> points, double tool_r, double slice_radius, RotationDirection dir) { Slice root_slice = new Slice(points[0], slice_radius, dir == RotationDirection.Unknown ? RotationDirection.CCW : dir); _sequence.Add(root_slice); for (int i = 1; i < points.Count; i++) { Slice new_slice = new Slice(_sequence.Last_slice, points[i], slice_radius, dir, tool_r, _sequence.Last_slice.End); if (new_slice.Placement != Slice_placement.NORMAL) { throw new Exception("bad slice placement"); } if (true) { new_slice.Refine(_sequence.Find_slices_colliding_with(new_slice), tool_r, tool_r); } if (i == 1) { Logger.log("changing startpoint of root slice"); _sequence.Root_slice.Change_startpoint(new_slice.Start); new_slice.Append_leadin_and_leadout(0, Slice_leadout_angle); } else { new_slice.Append_leadin_and_leadout(Slice_leadin_angle, Slice_leadout_angle); } _sequence.Add(new_slice); } return(_sequence); }
private void rotateU(RotationDirection d) { CubeFace t; List<List<int>> substitutions = new List<List<int>> { new List<int>{9, 3, 9, 5}, new List<int>{9, 5, 11, 5}, new List<int>{11, 5, 11, 3}, new List<int>{11, 3, 9, 3}, new List<int>{9, 4, 10, 5}, new List<int>{10, 5, 11, 4}, new List<int>{11, 4, 10, 3}, new List<int>{10, 3, 9, 4}, }; if (d == RotationDirection.ClockWise) { t = projection[3, 0]; projection[3, 0] = projection[8, 3]; projection[8, 3] = projection[5, 8]; projection[5, 8] = projection[0, 5]; projection[0, 5] = t; t = projection[4, 0]; projection[4, 0] = projection[8, 4]; projection[8, 4] = projection[4, 8]; projection[4, 8] = projection[0, 4]; projection[0, 4] = t; t = projection[5, 0]; projection[5, 0] = projection[8, 5]; projection[8, 5] = projection[3, 8]; projection[3, 8] = projection[0, 3]; projection[0, 3] = t; } else { t = projection[3, 0]; projection[3, 0] = projection[0, 5]; projection[0, 5] = projection[5, 8]; projection[5, 8] = projection[8, 3]; projection[8, 3] = t; t = projection[4, 0]; projection[4, 0] = projection[0, 4]; projection[0, 4] = projection[4, 8]; projection[4, 8] = projection[8, 4]; projection[8, 4] = t; t = projection[5, 0]; projection[5, 0] = projection[0, 3]; projection[0, 3] = projection[3, 8]; projection[3, 8] = projection[8, 5]; projection[8, 5] = t; } rotateFace(substitutions, d); }