<i id='16woz'><tr id='16woz'><dt id='16woz'><q id='16woz'><span id='16woz'><b id='16woz'><form id='16woz'><ins id='16woz'></ins><ul id='16woz'></ul><sub id='16woz'></sub></form><legend id='16woz'></legend><bdo id='16woz'><pre id='16woz'><center id='16woz'></center></pre></bdo></b><th id='16woz'></th></span></q></dt></tr></i><div id='16woz'><tfoot id='16woz'></tfoot><dl id='16woz'><fieldset id='16woz'></fieldset></dl></div>

      <legend id='16woz'><style id='16woz'><dir id='16woz'><q id='16woz'></q></dir></style></legend>

        <bdo id='16woz'></bdo><ul id='16woz'></ul>

    1. <tfoot id='16woz'></tfoot>

      1. <small id='16woz'></small><noframes id='16woz'>

      2. 旋转图像数学 (C#)

        时间:2023-10-06

        1. <small id='DuthN'></small><noframes id='DuthN'>

          • <bdo id='DuthN'></bdo><ul id='DuthN'></ul>

            1. <i id='DuthN'><tr id='DuthN'><dt id='DuthN'><q id='DuthN'><span id='DuthN'><b id='DuthN'><form id='DuthN'><ins id='DuthN'></ins><ul id='DuthN'></ul><sub id='DuthN'></sub></form><legend id='DuthN'></legend><bdo id='DuthN'><pre id='DuthN'><center id='DuthN'></center></pre></bdo></b><th id='DuthN'></th></span></q></dt></tr></i><div id='DuthN'><tfoot id='DuthN'></tfoot><dl id='DuthN'><fieldset id='DuthN'></fieldset></dl></div>

                <tfoot id='DuthN'></tfoot>
              • <legend id='DuthN'><style id='DuthN'><dir id='DuthN'><q id='DuthN'></q></dir></style></legend>
                    <tbody id='DuthN'></tbody>
                  本文介绍了旋转图像数学 (C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含两个点的图像,对齐如下:

                  I have an image with two points, aligned something like this:

                  |----------------|
                  |                |
                  |    .           |
                  |                |
                  |          .     |
                  |                |
                  |----------------|
                  

                  我有两个点的 X、Y 坐标,我需要将图像旋转 X 度,所以它看起来像这样:

                  I have both X, Y coordinates for both points and I need to rotate the image X degrees so it looks like this instead:

                  |----------------|
                  |                |
                  |                |
                  |    .     .     |
                  |                |
                  |                |
                  |----------------|
                  

                  基本上,它们彼此对齐,这是什么数学?(C# 中的代码示例会更好,但不是必需的)

                  Basically so they align next to eachother, what's the math for this? (A code example in C# would be even better but not required)

                  推荐答案

                  这取决于您想将哪个点用作旋转的中心".让我们将这个点称为左上点 A 和右下点 B.如果您想绕 A 点旋转,使 B 点与它对齐,则以弧度计算旋转角度如下:

                  It depends on which point you want to use as a "center" for your rotation. Let's call the point to the up and left pointA and the one to the right and below pointB. If you want to rotate around the point A so that point B aligns with it, calculating the rotation angle in radians would go like this:

                  double angle = Math.Atan2(pointB.Y - pointA.Y, pointB.X - pointA.X);
                  

                  我不知道您如何处理您的图像,因此以下内容仅适用于您使用 System.Drawing.Graphics:

                  I don't how you're handling your image, so the following applies only if you're using System.Drawing.Graphics:

                  myImage.TranslateTransform(-pointA.X, -pointA.Y);
                  myImage.RotateTransform((float) angle, MatrixOrder.Append);
                  myImage.TranslateTransform(pointA.X, pointA.Y, MatrixOrder.Append);
                  

                  希望对你有帮助.

                  这篇关于旋转图像数学 (C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:围绕另一个点旋转一个点 下一篇:如何旋转图片框中的图像

                  相关文章

                    <bdo id='phUc2'></bdo><ul id='phUc2'></ul>
                  <tfoot id='phUc2'></tfoot>
                • <small id='phUc2'></small><noframes id='phUc2'>

                  <legend id='phUc2'><style id='phUc2'><dir id='phUc2'><q id='phUc2'></q></dir></style></legend>

                    <i id='phUc2'><tr id='phUc2'><dt id='phUc2'><q id='phUc2'><span id='phUc2'><b id='phUc2'><form id='phUc2'><ins id='phUc2'></ins><ul id='phUc2'></ul><sub id='phUc2'></sub></form><legend id='phUc2'></legend><bdo id='phUc2'><pre id='phUc2'><center id='phUc2'></center></pre></bdo></b><th id='phUc2'></th></span></q></dt></tr></i><div id='phUc2'><tfoot id='phUc2'></tfoot><dl id='phUc2'><fieldset id='phUc2'></fieldset></dl></div>