/// <summary> /// Initializes a new instance of the <see cref="RigidRegistration"/> class and sets a mapping algorithm and max number of iterations. /// </summary> /// <param name="pointMapping">The mapping algorithm.</param> /// <param name="numberOfIterations">The number of iterations.</param> public RigidRegistration(IPointMapping pointMapping, int numberOfIterations) { Log.Info("Creating rigid registration."); this.pointMapping = pointMapping; this.rotation = new Kabsch(); this.numberOfIterations = numberOfIterations; }
/// <summary>Called every frame.</summary> protected override sealed void SetIntermediateState(IModel model, long currentTimeInMicroseconds) { float progress = (float)(currentTimeInMicroseconds - beginTimeInMicroseconds) / (float)duration; Die[] dice = model.CurrentGameBox.CurrentGame.DiceHands[diceHandIndex].Dice; dice[dieIndex].Position = new PointF( initialPosition.X + (finalPosition.X - initialPosition.X) * progress, initialPosition.Y + (finalPosition.Y - initialPosition.Y) * progress); int revolutions = 3; float rollingAngle = -progress * 2.0f * (float)Math.PI * revolutions; IRotation rolling = model.ComputeRotationFromAxis( finalPosition.Y - initialPosition.Y, finalPosition.X - initialPosition.X, 0.0f, rollingAngle); dice[dieIndex].Orientation = initialOrientation.InterpolateWith(finalOrientation, progress).ComposeWith(rolling); dice[dieIndex].Size = (progress > 0.5f ? finalSize : initialSize + (finalSize - initialSize) * progress * 2.0f); if (progress > 0.5f && audioTrack != AudioTrack.None) { IAudioManager audioManager = model.AudioManager; if (!soundPlaying) { audioManager.PlayAudioTrack(audioTrack); soundPlaying = true; } audioManager.SetAudioTrackOrigin(audioTrack, dice[dieIndex].Position); } }
public int GetPart2ManhattanDistance() { var shipCoordinates = new Point(0, 0); var waypoint = new Point(10, 1); foreach (IInstruction instruction in Instructions) { if (instruction is IDirection) { IDirection direction = instruction as IDirection; Point waypointMovement = direction.Execute(); waypoint.X += waypointMovement.X; waypoint.Y += waypointMovement.Y; } if (instruction is IMovement) { IMovement movement = instruction as IMovement; Point shipMovement = movement.Part2Execute(waypoint); shipCoordinates.X += shipMovement.X; shipCoordinates.Y += shipMovement.Y; } if (instruction is IRotation) { IRotation rotation = instruction as IRotation; waypoint = rotation.Part2Execute(waypoint); } } return(Math.Abs(shipCoordinates.X) + Math.Abs(shipCoordinates.Y)); }
public Turtle(ITable table, IRotation rotation, Position position, Angle rotationAngle) { _table = table; _rotation = rotation; _currentPosition = position; _rotationAngle = rotationAngle; }
public void Setup() { movement = Substitute.For <IMovement>(); rotation = Substitute.For <IRotation>(); handler = new Handler(movement, rotation); }
public int GetPart1ManhattanDistance() { var shipCoordinates = new Point(0, 0); var currentDirection = ShipDirection.Direction.East; foreach (IInstruction instruction in Instructions) { if (instruction is IDirection) { IDirection direction = instruction as IDirection; Point newCoordinate = direction.Execute(); shipCoordinates.X += newCoordinate.X; shipCoordinates.Y += newCoordinate.Y; } if (instruction is IMovement) { IMovement movement = instruction as IMovement; Point newCoordinate = movement.Part1Execute(currentDirection); shipCoordinates.X += newCoordinate.X; shipCoordinates.Y += newCoordinate.Y; } if (instruction is IRotation) { IRotation rotation = instruction as IRotation; currentDirection = rotation.Part1Execute(currentDirection); } } return(Math.Abs(shipCoordinates.X) + Math.Abs(shipCoordinates.Y)); }
public IPlayerContorllable ReloadShip(IMove moveImplementation, IRotation rotationImplemetation, ShipModel model) { _model = model; _moveImpementation = moveImplementation; _rotationImplementation = rotationImplemetation; return(this); }
private void Start() { //get the animator animator = GetComponent <Animator>(); //get interfaces _vision = GetComponent <IVision>(); _health = GetComponent <IHealth>(); _sfxController = GetComponent <ISfxController>(); _pathFinding = GetComponent <IPathFinding>(); _movement = GetComponent <IMovement>(); _rotation = GetComponent <IRotation>(); _simpleDamageDisplayManager = GetComponent <IDamageDisplayManager>(); //initial properties _normalSpeed = _movement.GetSpeed(); //initial states _isAgro = false; _isAttacking = false; _isAttackCoolingDown = false; invisible = false; //register event listener EventSystem.Current.RegisterEventListener <BulletHitCtx>(OnBulletHit); }
private void Start() { //get interfaces _vision = GetComponent <IVision>(); _health = GetComponent <IHealth>(); _sfxController = GetComponent <ISfxController>(); _pathFinding = GetComponent <IPathFinding>(); _movement = GetComponent <IMovement>(); _rotation = GetComponent <IRotation>(); _damageDisplayManager = GetComponent <IDamageDisplayManager>(); //get the animator if (animator == null) { animator = GetComponent <Animator>(); } //initial properties _lastSeenPlayerPos = new Vector3(); //initial _isAgro = false; _hasLastPlayerPos = false; _isAttacking = false; _isAttackCoolingDown = false; invisible = false; //register event listener EventSystem.Current.RegisterEventListener <BulletHitCtx>(OnBulletHit); }
public RotateCommand(IRotation rotation, IUnit player, IMazeViewData mazeView, IMazeNodeData nodeData, IAxisFactory factory) { fRotation = rotation; fPlayer = player; fMazeView = mazeView; fNodesByLocation = nodeData.NodesByLocation; fAxisFactory = factory; }
internal Ship(IMove moveImplementation, IRotation rotationImplemetation, IShipWeapon weapon, ShipModel model) { _model = model; _moveImpementation = moveImplementation; _rotationImplementation = rotationImplemetation; _weapon = weapon; _weapon.EquipWeapon(_model.BarrelPosition); _weapon.Activate(); }
public void RotateView(IRotation rotation, IUnit player, IMazeViewData mazeView, Dictionary <ILocation, INode> nodesByLocation) { player.ViewingAxis = GetFreeRotationAxis(mazeView); DoMoveViewToOrigin(mazeView, nodesByLocation); DoRotate(rotation, mazeView, nodesByLocation); player.ViewingAxis = GetFreeRotationAxis(mazeView); DoMoveViewToPlayer(player, mazeView, nodesByLocation); }
public MovementInput(ICharacterModel character) { _horizontal = new PCUserAxisInputHorizontal(); _vertical = new PCUserAxisInputVertical(); _movePlayer = new Movement(character); _rotationPlayer = new Rotation(character); _direction = Vector3.zero; }
private void DoRotate(IRotation rotation, IMazeViewData mazeView, IReadOnlyDictionary <ILocation, INode> nodesByLocation) { IAxis axis = rotation.GetRotationAxis(mazeView); double angle = DegreesToRadial(rotation.GetAngle()); Matrix <double> rotationMatrix = axis.GetRotationMatrix(angle); DoRotateView(rotationMatrix, mazeView, nodesByLocation); ApplyRotation(mazeView.MovementCube, rotationMatrix); rotation.SetRotationAxisForDirection(mazeView, GetFreeRotationAxis(mazeView)); }
/// <summary>Constructor</summary> public ResetDieAnimation( int diceHandIndex, int dieIndex, PointF initialPosition, PointF finalPosition, IRotation initialOrientation, IRotation finalOrientation, float initialSize, float finalSize) { this.diceHandIndex = diceHandIndex; this.dieIndex = dieIndex; this.initialPosition = initialPosition; this.finalPosition = finalPosition; this.initialOrientation = initialOrientation; this.finalOrientation = finalOrientation; this.initialSize = initialSize; this.finalSize = finalSize; }
public Ship(IMove moveImplementation, IRotation rotationImplementation, IShoot shootImplementation, Transform transform, ITransformRegistry transformRegistry, Stat health, ShipMarkUp shipGameObjectMarkUp) { _moveImplementation = moveImplementation; _rotationImplementation = rotationImplementation; shooter = shootImplementation; GameTransform = transform; TransformRegistryBind = transformRegistry; TransformRegistryBind.RegisterTransform(this, GameTransform); StatHolder = new StatHolder(); healthStat = health; healthStat.CurrentChanged += ProcessHealthChange; StatHolder.AddStat(StatType.Health, healthStat); colliderListener = shipGameObjectMarkUp.ColliderListener; colliderListener.EnterCollider += ProcessCollisions; }
/// <summary>Constructor</summary> public CastDieAnimation( int diceHandIndex, int dieIndex, PointF initialPosition, PointF finalPosition, IRotation initialOrientation, IRotation finalOrientation, float initialSize, float finalSize, AudioTrack audioTrack) { this.diceHandIndex = diceHandIndex; this.dieIndex = dieIndex; this.initialPosition = initialPosition; this.finalPosition = finalPosition; this.initialOrientation = initialOrientation; this.finalOrientation = finalOrientation; this.initialSize = initialSize; this.finalSize = finalSize; this.audioTrack = audioTrack; }
private async Task RunStep(IRotation rotation, int solutionCount) { WriteLine("Executing step {0}/{1}: {2}", ++m_currentStep, solutionCount, rotation); var cubeRotation = rotation as CubeRotation; var faceRotation = rotation as FaceRotation; var tasks = new List<Task>(); if (cubeRotation != null) { tasks.Add(m_configuration.RotateCube(cubeRotation)); if (m_display != null) tasks.Add(m_display.RotateCube(cubeRotation)); } if (faceRotation != null) { tasks.Add(m_configuration.Rotate(faceRotation)); if (m_display != null) tasks.Add(m_display.Rotate(faceRotation)); } await Task.WhenAll(tasks).ConfigureAwait(true); }
public static async Task ApplyAndAddRotation(IRotation rotation, ICollection<IRotation> rotations, IRotatable configuration) { if (rotation == null) return; rotations.Add(rotation); var cubeRotation = rotation as CubeRotation; var faceRotation = rotation as FaceRotation; if (cubeRotation != null) { await configuration.RotateCube(cubeRotation).ConfigureAwait(false); } if (faceRotation != null) { await configuration.Rotate(faceRotation).ConfigureAwait(false); } }
public static Quaternion Create(IRotation rotation) => QuaternionUtil.Create(rotation.XRadians, rotation.YRadians, rotation.ZRadians);
public Car(IRotation rotation) { this.Rotation = rotation; }
public RotationTest() { this._rotation = new Rotation(); }
/// <summary>Displays the next frame.</summary> public override void Render(IGraphics graphics, long currentTimeInMicroseconds) { if (model.CurrentGameBox.Reference == model.GameLibrary.DefaultGameBox) { // display "dice" logo IRotation rotation1 = model.ComputeRotationYawPitchRoll( 0.750000000f + 0.1f * (float)Math.Cos((float)Math.PI * 2.0f * (currentTimeInMicroseconds % (long)7000000) / 7000000.0f), 0.521750554f + 0.1f * (float)Math.Cos((float)Math.PI * 2.0f * (currentTimeInMicroseconds % (long)5000000) / 5000000.0f), 0.339836909f + 0.1f * (float)Math.Cos((float)Math.PI * 2.0f * (currentTimeInMicroseconds % (long)9000000) / 9000000.0f)); IRotation rotation2 = model.ComputeRotationYawPitchRoll( 0.750000000f + 0.1f * (float)Math.Cos((float)Math.PI * 2.0f * (currentTimeInMicroseconds % 9000000) / 9000000.0f), 2.356194490f + 0.1f * (float)Math.Cos((float)Math.PI * 2.0f * (currentTimeInMicroseconds % 7000000) / 7000000.0f), 3.141592654f + 0.1f * (float)Math.Cos((float)Math.PI * 2.0f * (currentTimeInMicroseconds % 5000000) / 5000000.0f)); Rectangle gameDisplayArea = view.GameDisplayAreaInPixels; logoMesh.Render( new PointF(gameDisplayArea.X + gameDisplayArea.Width * 0.43f, gameDisplayArea.Y + gameDisplayArea.Height * 0.35f), gameDisplayArea.Height * 0.1f, rotation1.ToRotationMatrix(), (uint)Color.LightGreen.ToArgb(), 0xff000000); logoMesh.Render( new PointF(gameDisplayArea.X + gameDisplayArea.Width * 0.57f, gameDisplayArea.Y + gameDisplayArea.Height * 0.45f), gameDisplayArea.Height * 0.1f, rotation2.ToRotationMatrix(), (uint)Color.Salmon.ToArgb(), 0xff000000); } else { DiceHand[] diceHands = model.CurrentGameBox.CurrentGame.DiceHands; if (diceHands.Length > 0) { // check for mouse roll over int rolledOverDiceHandIndex = 0; int rolledOverDiceCount = 0; if (model.ThisPlayer.CursorLocation is IDiceBagCursorLocation) { IDiceBagCursorLocation diceBagMouseLocation = (IDiceBagCursorLocation)model.ThisPlayer.CursorLocation; rolledOverDiceHandIndex = diceBagMouseLocation.DiceHandIndex; rolledOverDiceCount = diceBagMouseLocation.DiceCount; } // render background //IImage image = graphics.CreateMonochromaticImage(0xFFFFFFFF); float scale = view.GameDisplayAreaInPixels.Height / 1200.0f; //image.Render(new RectangleF(area.X + 7.0f * scale, area.Y + 6.0f * scale, area.Width - 14.0f * scale, area.Height - 12.0f * scale), 0xb0f0c67d); frameImageElements[0].Render(new RectangleF(area.X, area.Y, 11.0f * scale, 10.0f * scale)); frameImageElements[1].Render(new RectangleF(area.X + 11.0f * scale, area.Y, area.Width - 22.0f * scale, 10.0f * scale)); frameImageElements[2].Render(new RectangleF(area.Right - 11.0f * scale, area.Y, 11.0f * scale, 10.0f * scale)); frameImageElements[3].Render(new RectangleF(area.X, area.Y + 10.0f * scale, 11.0f * scale, area.Height - 20.0f * scale)); frameImageElements[4].Render(new RectangleF(area.X + 11.0f * scale, area.Y + 10.0f * scale, area.Width - 22.0f * scale, area.Height - 20.0f * scale)); frameImageElements[5].Render(new RectangleF(area.Right - 11.0f * scale, area.Y + 10.0f * scale, 11.0f * scale, area.Height - 20.0f * scale)); frameImageElements[6].Render(new RectangleF(area.X, area.Bottom - 10.0f * scale, 11.0f * scale, 10.0f * scale)); frameImageElements[7].Render(new RectangleF(area.X + 11.0f * scale, area.Bottom - 10.0f * scale, area.Width - 22.0f * scale, 10.0f * scale)); frameImageElements[8].Render(new RectangleF(area.Right - 11.0f * scale, area.Bottom - 10.0f * scale, 11.0f * scale, 10.0f * scale)); float singleLineHeight = area.Width * 0.2f; // idle dice for (int diceHandIndex = 0; diceHandIndex < diceHands.Length; ++diceHandIndex) { DiceHand diceHand = diceHands[diceHandIndex]; for (int dieIndex = 0; dieIndex < diceHand.Dice.Length; ++dieIndex) { if (!diceHand.BeingCast || dieIndex >= diceHand.DiceCountBeingCast) { Die die = diceHand.Dice[dieIndex]; IDieMesh dieMesh = die.DieMesh; float size = die.Size * (!diceHand.BeingCast && (model.ThisPlayer.PieceBeingDragged == null && model.ThisPlayer.StackBeingDragged == null) && (rolledOverDiceHandIndex == diceHandIndex && rolledOverDiceCount > dieIndex) ? 1.40f : 1.0f); dieMesh.Render( die.Position, size, die.Orientation.ToRotationMatrix(), die.Color, die.Pips); } } } // shadows of dice being cast for (int diceHandIndex = 0; diceHandIndex < diceHands.Length; ++diceHandIndex) { DiceHand diceHand = diceHands[diceHandIndex]; for (int dieIndex = 0; dieIndex < diceHand.Dice.Length; ++dieIndex) { if (diceHand.BeingCast && dieIndex < diceHand.DiceCountBeingCast) { Die die = diceHand.Dice[dieIndex]; IDieMesh dieMesh = die.DieMesh; float size = die.Size; dieMesh.RenderShadow( die.Position, size, die.Orientation.ToRotationMatrix(), 0x40000000); } } } // dice being cast for (int diceHandIndex = 0; diceHandIndex < diceHands.Length; ++diceHandIndex) { DiceHand diceHand = diceHands[diceHandIndex]; for (int dieIndex = 0; dieIndex < diceHand.Dice.Length; ++dieIndex) { if (diceHand.BeingCast && dieIndex < diceHand.DiceCountBeingCast) { Die die = diceHand.Dice[dieIndex]; IDieMesh dieMesh = die.DieMesh; float size = die.Size; dieMesh.Render( die.Position, size, die.Orientation.ToRotationMatrix(), die.Color, die.Pips); } } } } } }
public EnemyController(IMove move, IRotation rotation, IShooting shooting) { _move = move; _rotation = rotation; _shooting = shooting; }
/// <summary>Constructor.</summary> public DiceBag(IModel model, View view) : base(view) { this.model = model; // precalculate each face orientation float pi = (float)Math.PI; float atanSqrtTwo = (float)Math.Atan(Math.Sqrt(2.0)); float acosMinusOneThird = (float)Math.Acos(-1.0 / 3.0); float dihedralAngle = (float)Math.Acos(-Math.Sqrt(5.0) / 5.0); float halfPentagonAngle = (float)(Math.PI / 5.0); float piMinusDihedralAngle = (float)(Math.PI - Math.Acos(-Math.Sqrt(5) / 3.0)); faceOrientations = new IRotation[6][] { new IRotation[4] { /*1*/ model.ComputeRotationYawPitchRoll(0.0f, -atanSqrtTwo, pi * 0.25f), /*2*/ model.ComputeRotationYawPitchRoll(0.0f, -atanSqrtTwo, pi * -0.75f), /*3*/ model.ComputeRotationYawPitchRoll(0.0f, pi - atanSqrtTwo, pi * 0.75f), /*4*/ model.ComputeRotationYawPitchRoll(0.0f, pi - atanSqrtTwo, pi * -0.25f) }, new IRotation[6] { /*1*/ model.ComputeRotationYawPitchRoll(0.0f, 0.0f, 0.0f), /*2*/ model.ComputeRotationYawPitchRoll(pi * 0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi * 0.5f)), /*3*/ model.ComputeRotationYawPitchRoll(0.0f, pi * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi * -0.5f)), /*4*/ model.ComputeRotationYawPitchRoll(0.0f, pi * -0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi)), /*5*/ model.ComputeRotationYawPitchRoll(pi * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi)), /*6*/ model.ComputeRotationYawPitchRoll(pi, 0.0f, pi * 0.5f) }, new IRotation[8] { /*1*/ model.ComputeRotationYawPitchRoll(pi * 0.25f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (acosMinusOneThird - pi) * 0.5f, 0.0f)), /*2*/ model.ComputeRotationYawPitchRoll(pi * 0.25f, 0.0f, pi).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (acosMinusOneThird - pi) * 0.5f, 0.0f)), /*3*/ model.ComputeRotationYawPitchRoll(pi * -0.25f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (acosMinusOneThird - pi) * 0.5f, 0.0f)), /*4*/ model.ComputeRotationYawPitchRoll(pi * -0.25f, 0.0f, pi).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (acosMinusOneThird - pi) * 0.5f, 0.0f)), /*5*/ model.ComputeRotationYawPitchRoll(pi * -0.75f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (acosMinusOneThird - pi) * 0.5f, 0.0f)), /*6*/ model.ComputeRotationYawPitchRoll(pi * -0.75f, 0.0f, pi).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (acosMinusOneThird - pi) * 0.5f, 0.0f)), /*7*/ model.ComputeRotationYawPitchRoll(pi * 0.75f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (acosMinusOneThird - pi) * 0.5f, 0.0f)), /*8*/ model.ComputeRotationYawPitchRoll(pi * 0.75f, 0.0f, pi).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (acosMinusOneThird - pi) * 0.5f, 0.0f)) }, new IRotation[10] { /*1*/ model.ComputeRotationYawPitchRoll(0.0f, pi * -0.75f, pi * 0.5f), /*2*/ model.ComputeRotationYawPitchRoll(0.0f, pi * 0.25f, pi * 0.1f), /*3*/ model.ComputeRotationYawPitchRoll(0.0f, pi * -0.75f, pi * -0.3f), /*4*/ model.ComputeRotationYawPitchRoll(0.0f, pi * 0.25f, pi * -0.7f), /*5*/ model.ComputeRotationYawPitchRoll(0.0f, pi * -0.75f, pi * -0.7f), /*6*/ model.ComputeRotationYawPitchRoll(0.0f, pi * 0.25f, pi * -0.3f), /*7*/ model.ComputeRotationYawPitchRoll(0.0f, pi * -0.75f, pi * 0.1f), /*8*/ model.ComputeRotationYawPitchRoll(0.0f, pi * 0.25f, pi * 0.5f), /*9*/ model.ComputeRotationYawPitchRoll(0.0f, pi * -0.75f, pi * 0.9f), /*0*/ model.ComputeRotationYawPitchRoll(0.0f, pi * 0.25f, pi * 0.9f) }, new IRotation[12] { /*1*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, halfPentagonAngle * -0.5f)), /*2*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * 0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, (float)Math.PI * 0.5f)), /*3*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle, halfPentagonAngle * 0.5f)), /*4*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle + (float)Math.PI, (float)Math.PI - halfPentagonAngle * 0.5f)), /*5*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle + (float)Math.PI, halfPentagonAngle * -1.5f)), /*6*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle + (float)Math.PI, halfPentagonAngle * -3.5f)), /*7*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle, halfPentagonAngle * 1.5f + (float)Math.PI)), /*8*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle, halfPentagonAngle * -1.5f)), /*9*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle, (float)Math.PI - halfPentagonAngle * 0.5f)), /*10*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle + (float)Math.PI, halfPentagonAngle * 0.5f)), /*11*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, dihedralAngle, (float)Math.PI * 0.5f)), /*12*/ model.ComputeRotationYawPitchRoll(((float)Math.PI - dihedralAngle) * -0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, (float)Math.PI, halfPentagonAngle * -0.5f)) }, new IRotation[20] { /*1*/ model.ComputeRotationYawPitchRoll(0.0f, piMinusDihedralAngle * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, -pi / 3.0f)), /*2*/ model.ComputeRotationYawPitchRoll(0.0f, pi + piMinusDihedralAngle * -0.5f, 0.0f), /*3*/ model.ComputeRotationYawPitchRoll(0.0f, piMinusDihedralAngle * -0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, -piMinusDihedralAngle, pi / -3.0f)), /*4*/ model.ComputeRotationYawPitchRoll(pi * 0.5f + piMinusDihedralAngle * 0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi * -5.0f / 6.0f)), /*5*/ model.ComputeRotationYawPitchRoll(piMinusDihedralAngle * 0.5f, pi * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi * -5.0f / 6.0f)), /*6*/ model.ComputeRotationYawPitchRoll(piMinusDihedralAngle * 0.5f, pi * -0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi * -5.0f / 6.0f)), /*7*/ model.ComputeRotationYawPitchRoll(0.0f, piMinusDihedralAngle * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, -piMinusDihedralAngle, pi * -2.0f / 3.0f)), /*8*/ model.ComputeRotationYawPitchRoll(0.0f, pi + piMinusDihedralAngle * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, -piMinusDihedralAngle, pi * -2.0f / 3.0f)), /*9*/ model.ComputeRotationYawPitchRoll(0.0f, piMinusDihedralAngle * -0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, -piMinusDihedralAngle, pi / 3.0f)), /*10*/ model.ComputeRotationYawPitchRoll(pi * -0.5f - piMinusDihedralAngle * 0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi * 5.0f / 6.0f)), /*11*/ model.ComputeRotationYawPitchRoll(pi * 0.5f - piMinusDihedralAngle * 0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi / 6.0f)), /*12*/ model.ComputeRotationYawPitchRoll(0.0f, pi - piMinusDihedralAngle * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, -piMinusDihedralAngle, pi / -3.0f)), /*13*/ model.ComputeRotationYawPitchRoll(0.0f, piMinusDihedralAngle * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, -piMinusDihedralAngle, pi * 2.0f / 3.0f)), /*14*/ model.ComputeRotationYawPitchRoll(0.0f, pi + piMinusDihedralAngle * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, -piMinusDihedralAngle, pi * 2.0f / 3.0f)), /*15*/ model.ComputeRotationYawPitchRoll(piMinusDihedralAngle * -0.5f, pi * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi * 5.0f / 6.0f)), /*16*/ model.ComputeRotationYawPitchRoll(piMinusDihedralAngle * -0.5f, pi * -0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi * 5.0f / 6.0f)), /*17*/ model.ComputeRotationYawPitchRoll(pi * -0.5f + piMinusDihedralAngle * 0.5f, 0.0f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, -pi / 6.0f)), /*18*/ model.ComputeRotationYawPitchRoll(0.0f, pi - piMinusDihedralAngle * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, -piMinusDihedralAngle, pi / 3.0f)), /*19*/ model.ComputeRotationYawPitchRoll(0.0f, piMinusDihedralAngle * -0.5f, 0.0f), /*20*/ model.ComputeRotationYawPitchRoll(0.0f, pi + piMinusDihedralAngle * 0.5f, 0.0f).ComposeWith(model.ComputeRotationYawPitchRoll(0.0f, 0.0f, pi / 3.0f)) } }; }
// Start is called before the first frame update void Start() { rotation = GetComponent <IRotation>(); }
public static IFinMatrix4x4 FromRotation(IRotation rotation) => MatrixTransformUtil.FromRotation(QuaternionUtil.Create(rotation));
/// <summary>Interpolates between two rotations in 3D space, using spherical linear interpolation.</summary> /// <param name="finalRotation">Another rotation.</param> /// <param name="coefficient">Parameter that indicates how far to interpolate between the rotations.</param> /// <returns>The interpolation rotation.</returns> public IRotation InterpolateWith(IRotation finalRotation, float coefficient) { return(new Rotation(Quaternion.Slerp(q, ((Rotation)finalRotation).q, coefficient))); }
/// <summary>Computes the composition of two rotations in 3D space.</summary> /// <param name="secondRotation">Another rotation.</param> /// <returns>The composition rotation.</returns> public IRotation ComposeWith(IRotation secondRotation) { return(new Rotation(Quaternion.Multiply(q, ((Rotation)secondRotation).q))); }
public Ship(IMove moveImplementation, IRotation rotationImplementation) { _moveImplementation = moveImplementation; _rotationImplementation = rotationImplementation; }
/// <summary>Cast a set of dice, all from the same dice hand.</summary> /// <param name="diceHandIndex">Index of the dice hand.</param> /// <param name="diceResults">Result of each of the dice cast.</param> public void CastDice(int diceHandIndex, int[] diceResults) { DiceHand[] diceHands = model.CurrentGameBox.CurrentGame.DiceHands; diceHands[diceHandIndex].DiceCountBeingCast = diceResults.Length; Die[] dice = diceHands[diceHandIndex].Dice; // TODO : sort dice according to result from highest to lowest. PointF[] finalPositions = new PointF[diceResults.Length]; const int audioTracksMaxCount = 5; AudioTrack[] audioTracks = new AudioTrack[Math.Min(diceResults.Length, audioTracksMaxCount)]; for (int i = 0; i < diceResults.Length; ++i) { float finalSize = dice[0].Size * 1.40f * 2.5f; PointF finalPosition; bool diceOverlap; do { finalPosition = new PointF( model.RandomNumberGenerator.GenerateSingle(castingArea.X, castingArea.Right), model.RandomNumberGenerator.GenerateSingle(castingArea.Y, castingArea.Bottom)); diceOverlap = false; for (int j = 0; j < i; ++j) { if ((finalPosition.X - finalPositions[j].X) * (finalPosition.X - finalPositions[j].X) + (finalPosition.Y - finalPositions[j].Y) * (finalPosition.Y - finalPositions[j].Y) < 6.0f * finalSize * finalSize) { diceOverlap = true; break; } } } while(diceOverlap); finalPositions[i] = finalPosition; if (i < audioTracksMaxCount) { bool audioTrackAlreadyUsed; do { audioTracks[i] = AudioTrack.Die0 + model.RandomNumberGenerator.GenerateInt32(0, 6); audioTrackAlreadyUsed = false; for (int j = 0; j < i; ++j) { if (audioTracks[j] == audioTracks[i]) { audioTrackAlreadyUsed = true; break; } } } while(audioTrackAlreadyUsed); } DiceType diceType = diceHands[diceHandIndex].DiceType; IRotation finalOrientation = faceOrientations[(int)diceType][diceResults[i] - 1].ComposeWith( model.ComputeRotationFromAxis(0.0f, 0.0f, 1.0f, model.RandomNumberGenerator.GenerateSingle((float)-Math.PI, (float)Math.PI))); model.AnimationManager.LaunchAnimationSequence( new CastDieAnimation(diceHandIndex, i, dice[i].DockedPosition, finalPosition, dice[i].Orientation, finalOrientation, dice[i].DockedSize, finalSize, (i < audioTracksMaxCount ? audioTracks[i] : AudioTrack.None)), new IdleAnimation(1000000L), new ResetDieAnimation(diceHandIndex, i, finalPosition, dice[i].DockedPosition, finalOrientation, faceOrientations[(int)diceType][diceResults[i] - 1], finalSize, dice[i].DockedSize)); } }
public MatrixOperations(IRotation rotation) { this._rotation = rotation; }
private Task StartRotating(IRotation rotation) { m_rotationTask = new TaskCompletionSource<object>(); m_timesRun = 0; m_currentRotation = rotation; SetNextRotation(); return m_rotationTask.Task; }