小编dar*_*y89的帖子

如何旋转Vector2?


我正在尝试旋转Vector2但没有任何效果.
我试过以下 - >没有用:

x' = cos(angle)*x - sin(angle)*y & y' = sin(angle)*x + cos(angle)*y
Run Code Online (Sandbox Code Playgroud)

我尝试过使用旋转矩阵 - >没用

我究竟做错了什么 ?:/

angle = MathHelper.Pi;
direction.X = (int)((direction.X) * Math.Cos(angle) - direction.Y * Math.Sin(angle));
direction.Y = (int)((direction.X) * Math.Sin(angle) + direction.Y * Math.Cos(angle));

float angle = MathHelper.PiOver2;
Vector2 dir = new Vector2(direction.X, direction.Y);
Vector2.Transform(dir, Matrix.CreateRotationX(angle));
direction = new Point((int)dir.X, (int)dir.Y);
Run Code Online (Sandbox Code Playgroud)

.net c# xna

2
推荐指数
1
解决办法
9599
查看次数

标签 统计

.net ×1

c# ×1

xna ×1