CreateRotationZ() 공개 정적인 메소드

public static CreateRotationZ ( float radians ) : Matrix
radians float
리턴 Matrix
예제 #1
0
        public BasicEntity(ModelDefinition modelbb, MaterialEffect material, Vector3 position, double angleZ, double angleX, double angleY, Vector3 scale, MeshMaterialLibrary library = null, Entity physicsObject = null)
        {
            Id                  = IdGenerator.GetNewId();
            Name                = GetType().Name + " " + Id;
            WorldTransform      = new TransformMatrix(Matrix.Identity, Id);
            ModelDefinition     = modelbb;
            Model               = modelbb.Model;
            BoundingBox         = modelbb.BoundingBox;
            BoundingBoxOffset   = modelbb.BoundingBoxOffset;
            SignedDistanceField = modelbb.SDF;

            Material = material;
            Position = position;
            Scale    = scale;

            RotationMatrix = Matrix.CreateRotationX((float)angleX) * Matrix.CreateRotationY((float)angleY) *
                             Matrix.CreateRotationZ((float)angleZ);

            if (library != null)
            {
                RegisterInLibrary(library);
            }

            if (physicsObject != null)
            {
                RegisterPhysics(physicsObject);
            }

            WorldTransform.World        = Matrix.CreateScale(Scale) * RotationMatrix * Matrix.CreateTranslation(Position);
            WorldTransform.Scale        = Scale;
            WorldTransform.InverseWorld = Matrix.Invert(Matrix.CreateTranslation(BoundingBoxOffset * Scale) * RotationMatrix * Matrix.CreateTranslation(Position));
        }
예제 #2
0
        private void _motion_CurrentValueChanged(object sender, SensorReadingEventArgs <MotionReading> e)
        {
            double motionDelta = 0.01;

            if (!_motion.IsDataValid)
            {
                return;
            }

            if (Math.Abs(e.SensorReading.Attitude.Yaw - _yaw) > motionDelta)
            {
                _yaw = e.SensorReading.Attitude.Yaw;
            }

            if (Math.Abs(e.SensorReading.Attitude.Roll - _roll) > motionDelta)
            {
                _roll = e.SensorReading.Attitude.Roll;
            }

            if (Math.Abs(e.SensorReading.Attitude.Pitch - _pitch) > motionDelta)
            {
                _pitch = e.SensorReading.Attitude.Pitch;
            }

            Dispatcher.BeginInvoke(delegate()
            {
                if (myVM.ClickedNearbyLocation != null)
                {
                    myVM.ClickedNearbyLocation.CalculateHeadingAngle(MathHelper.ToDegrees(_yaw));
                }
            });

            if (_onDragEndAnimation)
            {
                return;
            }

            if (_gestureState == GestureStateEnum.OnFreeDrag)
            {
                _cameraMatrixBehindDrag  = Matrix.CreateLookAt(new Vector3(0, 0, 0), new Vector3(0, 0, -1), Vector3.Up);
                _cameraMatrixBehindDrag *= Matrix.CreateRotationY(-_yaw);
                _cameraMatrixBehindDrag *= Matrix.CreateRotationZ(_roll);
                _cameraMatrixBehindDrag *= Matrix.CreateRotationX(-_pitch + MathHelper.PiOver2);
            }
            else
            {
                _cameraMatrix  = Matrix.CreateLookAt(new Vector3(0, 0, 0), new Vector3(0, 0, -1), Vector3.Up);
                _cameraMatrix *= Matrix.CreateRotationY(-_yaw);
                _cameraMatrix *= Matrix.CreateRotationZ(_roll);
                _cameraMatrix *= Matrix.CreateRotationX(-_pitch + MathHelper.PiOver2);

                //rotate radar
                Dispatcher.BeginInvoke(delegate()
                {
                    (radarCanvas.RenderTransform as System.Windows.Media.RotateTransform).Angle = MathHelper.ToDegrees((_yaw));
                });
            }
        }
        private AiControllerInputBuilder LookInDirection(float angleFromAhead)
        {
            var directionToLook = Vector2.Transform(car.DirectionVector, Matrix.CreateRotationZ(MathHelper.ToRadians(angleFromAhead)));
            var currentPosition = car.Position + directionToLook;
            var distance        = 1;

            while (trackManager.IsOnTrack(currentPosition))
            {
                currentPosition += directionToLook;
                distance++;
            }

            inputs.Add(distance);

            return(this);
        }
예제 #4
0
        protected override void WhenUpdatedByUi()
        {
            _transform =
                Matrix.CreateTranslation(new Vector3(-_properties.Origin.X, -_properties.Origin.Y, 0.0f)) *
                Matrix.CreateScale(Scale.X, Scale.Y, 1) *
                Matrix.CreateRotationZ(Rotation) *
                Matrix.CreateTranslation(new Vector3(_properties.Position, 0.0f));

            Vector2 leftTop = Vector2.Zero;

            var leftBottom  = new Vector2(0, _texture.Height);
            var rightTop    = new Vector2(_texture.Width, 0);
            var rightBottom = new Vector2(_texture.Width, _texture.Height);

            // Transform all four corners into work space
            Vector2.Transform(ref leftTop, ref _transform, out leftTop);
            Vector2.Transform(ref rightTop, ref _transform, out rightTop);
            Vector2.Transform(ref leftBottom, ref _transform, out leftBottom);
            Vector2.Transform(ref rightBottom, ref _transform, out rightBottom);

            _polygon[0] = leftTop;
            _polygon[1] = rightTop;
            _polygon[3] = leftBottom;
            _polygon[2] = rightBottom;

            // Find the minimum and maximum extents of the rectangle in world space
            Vector2 min = Vector2.Min(
                Vector2.Min(leftTop, rightTop),
                Vector2.Min(leftBottom, rightBottom));

            Vector2 max = Vector2.Max(
                Vector2.Max(leftTop, rightTop),
                Vector2.Max(leftBottom, rightBottom));

            // Return as a rectangle
            _boundingRectangle = new Rectangle(
                (int)min.X,
                (int)min.Y,
                (int)(max.X - min.X),
                (int)(max.Y - min.Y));
        }
예제 #5
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            float amount = 0.5f + (float)Math.Sin((double)gameTime.TotalGameTime.TotalSeconds / 4.0) / 2f;

            effect.World = Matrix.CreateRotationX(MathHelper.Lerp(-(float)Math.PI, (float)Math.PI, amount)) *
                           Matrix.CreateRotationY(MathHelper.Lerp(-(float)Math.PI, (float)Math.PI, amount)) *
                           Matrix.CreateRotationZ(MathHelper.Lerp(-(float)Math.PI, (float)Math.PI, amount));

            effect.View       = camera.view;
            effect.Projection = camera.projection;

            // Begin effect and draw for each pass
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                for (int i = 0; i < quad.Length; i++)
                {
                    GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList, quad[i].Vertices, 0, 4, quad[i].Indexes, 0, 2);
                }
            }
            base.Draw(gameTime);
        }
예제 #6
0
        public static V2  sovev_vector(F zavit)
        {
            MX cli_sivoov = MX.CreateRotationZ(zavit);

            return(V2.Transform(-V2.UnitY, cli_sivoov));
        }