Tag: 旋转

将角度转换为矢量

我正在做一些游戏编程。 FWIW我正在使用XNA,但我怀疑这是否相关。 我想将度数转换为幅度为1的方向向量(即X和Y)。 我的起源(0,0)位于左上角。 所以我想要0度转换为[0,-1] 我认为最好的方法是采用我的North / Up定义并使用矩阵旋转它,但这似乎不起作用。 这是守则…… public class Conversion { public static Vector2 GetDirectionVectorFromDegrees(float Degrees) { Vector2 North= new Vector2(0, -1); float Radians = MathHelper.ToRadians(Degrees); var RotationMatrix = Matrix.CreateRotationZ(Radians); return Vector2.Transform(North, RotationMatrix); } } ……这是我的unit testing…… [TestFixture] public class Turning_Tests { [Test] public void Degrees0_Tests() { Vector2 result = Conversion.GetDirectionVectorFromDegrees(0); Assert.AreEqual(0, result.X); […]

如何仅使用c#代码在图像对象上创建旋转动画(在WPF窗口内)

我有几个与同类事情有关的未解决的问题, 我是WPF的新手,但对C#和Winforms有经验。 我已经在互联网上浏览了一个有效的例子,但还没找到一个有效的。 我想要实现的是在C#函数中创建以下内容 创建图像(图像1) 创建图像(图像2) 将图像并排放在窗口上 创建一个故事板 将image1的rotate属性设置为0到360(animation1) 将图像2的不透明度属性从完全设置为不可见(animation2) 故事板应运行十秒钟,动画1从0秒开始,动画2从5秒开始 明确的代码请求道歉,但是,我已经看了,并尝试过,我之前的问题有完整的代码执行但没有动画显示(链接如下) 如何使用c#代码创建故事板并在wpf中旋转图像 提前致谢 担。

来回旋转GameObject

我想在Y轴上在90,-90之间来回旋转对象。 问题是我可以在-90中设置编辑器中的对象,但是当我运行项目时-90突然变为270.无论如何这里是我正在使用的代码: void Update() { if (transform.eulerAngles.y >= 270) { transform.Rotate(Vector3.up * speed * Time.deltaTime); } else if (transform.eulerAngles.y <= 90) { transform.Rotate(Vector3.up * -speed * Time.deltaTime); } } 它总是在360度左右卡在中间。 救命?

在C#中旋转图像时如何防止剪裁?

我刚刚经历了一些试图找出如何使图像均匀旋转的东西。 这有效,但现在它正在削减,我不确定如何让它停止…我正在使用这个rotateImage方法: public static Image RotateImage(Image img, float rotationAngle) { //create an empty Bitmap image Bitmap bmp = new Bitmap(img.Width, img.Height); //turn the Bitmap into a Graphics object Graphics gfx = Graphics.FromImage(bmp); //now we set the rotation point to the center of our image gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2); //now rotate the image gfx.RotateTransform(rotationAngle); […]

旋转M * N矩阵(90度)

我怎样才能旋转矩阵 |3 4 5 6 8| |5 4 3 2 6| |3 3 7 8 9| 至 |8 6 9| |6 2 8| |5 3 7| |4 4 3| |3 5 3| 因为我见过的所有算法都是N * N矩阵。

根据旋转的TextBox旋转光标

我有一个TextBox ,我允许我的用户旋转。 但我喜欢我的用户是让他们的Cursor旋转到与TextBox旋转相同的角度。 例如,如果他们将TextBox旋转到28°,那么当Cursor进入TextBox , Cursor也应该自己旋转到28°。 任何帮助都将不胜感激。 谢谢 :)

将游戏对象旋转到特定点

在我的项目中我有一座桥,此刻我与它旋转的桥并且不停止旋转,我想要的是通过特定点旋转该桥并停止旋转,该桥是在我的游戏对象内pivotPoint一般我旋转pivotPoint而不是桥,所以我这样做: using UnityEngine; using System.Collections; public class fallBridge : MonoBehaviour { private Rigidbody ball; public GameObject bridgePivot; private bool colided; private bool rotating = true; // Update is called once per frame void Start(){ colided = false; } void Update () { if (colided) { if (rotating) { Vector3 to = new Vector3 (0, 0, […]

如何在图片框中旋转图像

我正在制作一个winforms应用程序。 我希望实现的function之一是在家庭forms上的旋转装置。 装载主页时,应将鼠标hover在齿轮的图片上,并应将其旋转到位。 但到目前为止,我所拥有的只是RotateFlip而且只是翻转图片。 当鼠标hover在它上面时,有没有办法让齿轮转动到位? 我到目前为止的代码是: Bitmap bitmap1; public frmHome() { InitializeComponent(); try { bitmap1 = (Bitmap)Bitmap.FromFile(@”gear.jpg”); gear1.SizeMode = PictureBoxSizeMode.AutoSize; gear1.Image = bitmap1; } catch (System.IO.FileNotFoundException) { MessageBox.Show(“There was an error.” + “Check the path to the bitmap.”); } } private void frmHome_Load(object sender, EventArgs e) { System.Threading.Thread.Sleep(5000); } private void frmHome_FormClosed(object sender, FormClosedEventArgs e) […]

Silverlight旋转和缩放位图图像以适合矩形而不进行裁剪

我需要旋转一个WriteableBitmap并在它被裁剪之前向下或向上缩放。 我的当前代码将旋转,但如果高度大于宽度,则会裁剪边缘。 我想我需要扩展? public WriteableBitmap Rotate(WriteableBitmap Source, double Angle) { RotateTransform rt = new RotateTransform(); rt.Angle = Angle; TransformGroup transform = new TransformGroup(); transform.Children.Add(rt); Image tempImage2 = new Image(); WriteableBitmap wb; rt.CenterX = Source.PixelWidth / 2; rt.CenterY = Source.PixelHeight / 2; tempImage2.Width = Source.PixelWidth; tempImage2.Height = Source.PixelHeight; wb = new WriteableBitmap((int)(Source.PixelWidth), Source.PixelHeight); tempImage2.Source = Source; […]

旋转图像数学(C#)

我有一个有两个点的图像,对齐如下: |—————-| | | | . | | | | . | | | |—————-| 我有两个点的X,Y坐标,我需要将图像旋转X度,所以它看起来像这样: |—————-| | | | | | . . | | | | | |—————-| 基本上所以他们在彼此旁边对齐,这是什么数学? (C#中的代码示例会更好但不是必需的)