PHP - 数学 - 旋转后的新坐标
我已经旋转了图像,需要将较小图像的新坐标放置在旋转图像上。
假设未旋转的大图像上的小图像的坐标是:
$x0 = 100;
$x1 = 120;
$y0 = 100;
$y2 = 200;
对大图像执行的顺时针旋转是:
$rotation = -3.5;
我现在如何获得更新的坐标,以将小图像放置到较大的(现在旋转的)图像上?
(免责声明:这个问题具体是如何在旋转图像后在 PHP 中计算新坐标,因此它不是其他“旋转后的坐标”问题的重复,这些问题不涉及如何在 PHP 中解决此问题代码,0,0 是左上角并使用 PHP 函数。)
I have rotated an image and need to get the new coordinates of a smaller image to be placed on the rotated image.
Assuming the small image's coordinates on the unrotated large image are:
$x0 = 100;
$x1 = 120;
$y0 = 100;
$y2 = 200;
And the clockwise rotation performed on the large image is:
$rotation = -3.5;
How can I now get the updated coordinates for placing the small image onto the larger (now rotated) image?
(Disclaimer: This question is specifically how to calculate the new coordinates in PHP after a rotate of an image, so it is not a duplicate of other "coordinates after rotate" questions, which don't deal with how to solve this problem in PHP code, with 0,0 being top left corner and using PHP functions.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要知道图像旋转的原点。然后,您可以通过执行以下步骤将旧坐标系(未旋转的大图像)中的任意点转换为新坐标系(旋转后的大图像):
然后小图像将被旋转并放置在之前的位置。
我以前在 HTML Canvas 中遇到过这个问题。请参阅此问题的第一个答案:围绕另一个点旋转一个点(2D)
那一个详细描述了一种如何做到这一点的方法。
You need to know the Origin point where the image is rotated about. Then you can take any point in the old coordinate system (your big unrotated image) and translate it to the new coordinate system (your big rotated image) by doing the following steps:
Then the small image will be rotated and placed where it was before.
I had that problem before in HTML Canvas. Please see the first answer on this question: Rotating a point about another point (2D)
That one describes a method how to do that in detail.