Ejemplo n.º 1
0
 private void SetPostion(VectorPosition position)
 {
     this.SetVisibility(position.IsVisible);
     this.SetPoint(position.Point);
     this.SetAngle(position.Angle);
     this.SetLenght(position.Lenght);
 }
Ejemplo n.º 2
0
        public void Test_length_relationships(double metersX, double metersY, double metersLength)
        {
            var position = VectorPosition.FromMeters(metersX, metersY);

            position.MetersLength.IsSameOrEqualTo(metersLength);
            position.CentimetersLength.IsSameOrEqualTo(metersLength * 100);
            position.MillimetersLength.IsSameOrEqualTo(metersLength * 1000);
        }
Ejemplo n.º 3
0
 private static async Task StartDemoAsync(IDrawingService drawingService)
 {
     var lines = new IDrawingPrimitive[]
     {
         new LinePrimitive(VectorPosition.FromCentimeters(1, 1), VectorPosition.FromCentimeters(2, 2))
     };
     await drawingService.DrawAsync(new RandomPrimitive(-1));
 }
Ejemplo n.º 4
0
 public bool TryInstruction(string _input, VectorPosition _cvp, IMap m, out VectorPosition _vp)
 {
     _vp = _cvp;
     if (_input == "F")
     {
         _vp._coordinate = _vp._coordinate.Add(MovementHelper._moveindirection[_vp._direction]);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        void Update()
        {
            if (this.isPositionChanging)
            {
                var point = this.currentPosition.Point;
                if (this.isMoving)
                {
                    point = new Point(
                        this.Approximate(point.X, this.targetPosition.Point.X, this.movementSpeed),
                        this.Approximate(point.Y, this.targetPosition.Point.Y, this.movementSpeed),
                        this.Approximate(point.Z, this.targetPosition.Point.Z, this.movementSpeed));

                    this.SetPoint(point);

                    this.SetIsMoving();
                }

                var angle = this.currentPosition.Angle;
                if (this.isTurning)
                {
                    angle = new EulerAngle(
                        this.Approximate(angle.XAngle, this.targetPosition.Angle.XAngle, this.rotationSpeed),
                        this.Approximate(angle.YAngle, this.targetPosition.Angle.YAngle, this.rotationSpeed),
                        this.Approximate(angle.ZAngle, this.targetPosition.Angle.ZAngle, this.rotationSpeed));

                    this.SetAngle(angle);

                    this.SetIsTurning();
                }

                var lenght = this.currentPosition.Lenght;
                if (this.isLenghtChanging)
                {
                    lenght = this.Approximate(lenght, this.targetPosition.Lenght, this.lenghtChangingSpeed);

                    this.SetLenght(lenght);

                    this.SetIsLenghtChanging();
                }

                this.currentPosition = new VectorPosition(
                    this.currentPosition.IsVisible,
                    point,
                    angle,
                    lenght);

                this.SetIsPositionChanging();
            }
        }
        public void DrawCircle(VectorPosition position)
        {
            var x       = Canvas.ActualWidth / Count;
            var y       = Canvas.ActualHeight / Count;
            var ellipse = new Ellipse
            {
                Fill   = PointsColor,
                Height = PointsRadius * 2,
                Width  = PointsRadius * 2,
                Margin = new Thickness(position.CentimetersX * x - PointsRadius, Canvas.ActualHeight - position.CentimetersY * y - PointsRadius, 0, 0)
            };

            Canvas.Children.Add(ellipse);
            Task.Delay(PathTtl).ContinueWith(_ =>
            {
                Canvas.Children.Remove(ellipse);
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Ejemplo n.º 7
0
        private void OnPositionChanged(object sender, EventArgs e)
        {
            this.targetPosition = this.vector.Position;

            if (this.currentPosition.IsVisible != this.targetPosition.IsVisible)
            {
                this.SetVisibility(this.targetPosition.IsVisible);

                this.currentPosition = new VectorPosition(
                    this.targetPosition.IsVisible,
                    this.currentPosition.Point,
                    this.currentPosition.Angle,
                    this.currentPosition.Lenght);
            }

            this.SetIsMoving();
            this.SetIsTurning();
            this.SetIsLenghtChanging();
            this.SetIsPositionChanging();
        }
Ejemplo n.º 8
0
    public static Vector3 SwapFromVector(Vector3 original, float newValue, VectorPosition position)
    {
        Vector3 newVector = new Vector3();

        switch (position)
        {
        case VectorPosition.x:

            newVector = new Vector3(newValue, original.y, original.z);
            break;

        case VectorPosition.y:

            newVector = new Vector3(original.x, newValue, original.z);
            break;

        case VectorPosition.z:

            newVector = new Vector3(original.x, original.y, newValue);
            break;
        }

        return(newVector);
    }
Ejemplo n.º 9
0
        public void Initialize(Vector vector)
        {
            this.vector = vector;

            this.vector.PositionChanged += this.OnPositionChanged;

            var vectorTransform = transform.Find("Vector");

            this.head  = vectorTransform.Find("Head");
            this.shaft = vectorTransform.Find("Shaft");

            transform.localScale = new Vector3(5, 5, 5);

            if (!this.vector.HasHead)
            {
                this.head.gameObject.SetActive(false);
            }

            GameObjectColorHelper.SetGameObjectColor(this.head.gameObject, this.vector.Color);
            GameObjectColorHelper.SetGameObjectColor(this.shaft.gameObject, this.vector.Color);

            this.currentPosition = this.vector.Position;
            this.SetPostion(this.vector.Position);
        }
Ejemplo n.º 10
0
 public async Task MoveToAsync(VectorPosition position)
 {
     // throw new System.NotImplementedException();
 }
Ejemplo n.º 11
0
 public Task MoveToAsync(VectorPosition position)
 {
     return(Task.WhenAll(drawingMechanisms.Select(m => m.MoveToAsync(position))));
 }
Ejemplo n.º 12
0
 public Task MoveToAsync(VectorPosition position)
 {
     Console.WriteLine($"Move to {position}");
     return(Task.CompletedTask);
 }
Ejemplo n.º 13
0
        public void Test_reachability(double metersX, double metersY, bool isReachable)
        {
            var position = VectorPosition.FromMeters(metersX, metersY);

            position.IsReachable.Should().Be(isReachable);
        }
Ejemplo n.º 14
0
 public void Test_length_in_millimeters_correctness(double x, double y, double length)
 {
     VectorPosition.FromMillimeters(x, y).MillimetersLength.IsSameOrEqualTo(length);
 }