Microsoft.Xna.Framework.Vector2.Transform C# (CSharp) Method

Transform() public static method

Transforms the vector (x, y, 0, 1) by the specified matrix. Transforms a Vector2 by the given Matrix. Transforms a 2D vector normal by a matrix. Transforms a vector normal by a matrix. Transforms a single Vector2, or the vector normal (x, y, 0, 0), by a specified Quaternion rotation. Transforms a Vector2, or the vector normal (x, y, 0, 0), by a specified Quaternion rotation. Transforms an array of Vector2s by a specified Matrix. Transforms a specified range in an array of Vector2s by a specified Matrix and places the results in a specified range in a destination array. Transforms an array of Vector2 vector normals by a specified Matrix. Transforms a specified range in an array of Vector2 vector normals by a specified Matrix and places the results in a specified range in a destination array. Transforms an array of Vector2s by a specified Quaternion. Transforms a specified range in an array of Vector2s by a specified Quaternion and places the results in a specified range in a destination array.
public static Transform ( Vector2 position, Matrix matrix ) : Vector2
position Vector2 The source vector.
matrix Matrix The transformation matrix.
return Vector2
        public static Vector2 Transform(Vector2 position, Matrix matrix)
        {
            //float x = position.X * matrix.M11 + position.Y * matrix.M21 + matrix.M41;
            //float y = position.X * matrix.M12 + position.Y * matrix.M22 + matrix.M42;
            //Vector2 result;
            //result.X = x;
            //result.Y = y;
            //return result;
            return position;
        }

Usage Example

コード例 #1
0
ファイル: InputManager.cs プロジェクト: toffen/EvoNet
        public void Zoom(float zoomFactor, Vector2 mousePos)
        {
            // Track where we are before scale
            Vector2 mousePositionBeforeScale = Vector2.Transform(mousePos, Matrix.Invert(camera.Matrix));

            camera.Scale += (gameConfiguration.ScaleFactor * zoomFactor) / (camera.Scale < 1 ? 1 / camera.Scale : camera.Scale);

            // Track where we are after scale
            Vector2 mousePositionAfterScale = Vector2.Transform(mousePos, Matrix.Invert(camera.Matrix));

            // Adjust screen position with respect to scale to achieve zoom to Mouse cursor functionality
            camera.Move(mousePositionAfterScale - mousePositionBeforeScale);
        }
All Usage Examples Of Microsoft.Xna.Framework.Vector2::Transform