计算绕原点旋转某角度后的点的坐标

2024-06-24 14:18

本文主要是介绍计算绕原点旋转某角度后的点的坐标,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

问题:

A点(x, y)按顺时针旋转 theta 角度后点的坐标为A1点(x1,y1)  ,求x1 y1坐标用(x,y)和 theta 来表示

方法一:

设 OA 向量和x轴的角度为 alpha ,

那么顺时针转过 theta后 ,OA1 向量和x轴的角度为 (alpha - theta) 。

使用圆的参数方程来表示点坐标。A的坐标可以表示为:

\[\left\{ {\begin{array}{*{20}{c}}
  {x = r \cdot \cos \alpha } \\ 
  {y = r \cdot \sin \alpha } 
\end{array}} \right.\]

A1的坐标可以表示为(带入A点坐标进行化简)

\[\left\{ {\begin{array}{*{20}{c}}
  {{x_1} = r \cdot \cos (\alpha  - \theta ) = r \cdot (\cos \alpha \cos \theta  + \sin \alpha \sin \theta ) = x \cdot \cos \theta  + y \cdot \sin \theta } \\ 
  {{y_1} = r \cdot \sin (\alpha  - \theta ) = r \cdot (\sin \alpha \cos \theta  - \cos \alpha \sin \theta ) =  - x \cdot \sin \theta  + y \cdot \cos \theta } 
\end{array}} \right.\]

写成矩阵形式:

\[\left( {\begin{array}{*{20}{c}}
  {\cos \theta }&{\sin \theta } \\ 
  { - \sin \theta }&{\cos \theta } 
\end{array}} \right)\left( {\begin{array}{*{20}{c}}
  x \\ 
  y 
\end{array}} \right) = \left( {\begin{array}{*{20}{c}}
  {{x_1}} \\ 
  {{y_1}} 
\end{array}} \right)\]


方法二:

点顺时针转,相当于 点不变,让坐标轴逆指针转。


坐标为(x,y),可以看成: 

x值是点表示的向量,与x正轴单位向量的点积。

y值是点表示的向量,与y正轴单位向量的点积。

即在x轴和y轴上,带方向的投影长度。


所以问题等价的转化为: 坐标轴逆时针转了theta,求点在新的坐标系下的坐标。


新的坐标系的x正轴单位向量为(用原来的坐标系来表示)

\[(\cos \theta ,\sin \theta )\]

新的坐标系的y正轴单位向量为

\[( - \sin \theta ,\cos \theta )\]


所以

A点新的坐标系下的x值 x1= 点积(A点坐标,新坐标系x正轴单位向量)

A点新的坐标系下的y值 y1= 点积(A点坐标,新坐标系y正轴单位向量)

\[\left\{ {\begin{array}{*{20}{c}}
  {{x_1} = x \cdot \cos \theta  + y \cdot \sin \theta } \\ 
  {{y_1} =  - x \cdot \sin \theta  + y \cdot \cos \theta } 
\end{array}} \right.\]

\[\left( {\begin{array}{*{20}{c}}
  {\cos \theta }&{\sin \theta } \\ 
  { - \sin \theta }&{\cos \theta } 
\end{array}} \right)\left( {\begin{array}{*{20}{c}}
  x \\ 
  y 
\end{array}} \right) = \left( {\begin{array}{*{20}{c}}
  {{x_1}} \\ 
  {{y_1}} 
\end{array}} \right)\]


总结:

顺时针旋转矩阵为:

\[\left( {\begin{array}{*{20}{c}}
  {\cos \theta }&{\sin \theta } \\ 
  { - \sin \theta }&{\cos \theta } 
\end{array}} \right)\]


逆时针旋转矩阵为:(theta 变成 -theta带入即可)

\[\left( {\begin{array}{*{20}{c}}
  {\cos \theta }&{ - \sin \theta } \\ 
  {\sin \theta }&{\cos \theta } 
\end{array}} \right)\]


这篇关于计算绕原点旋转某角度后的点的坐标的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1090380

相关文章

Python如何计算两个不同类型列表的相似度

《Python如何计算两个不同类型列表的相似度》在编程中,经常需要比较两个列表的相似度,尤其是当这两个列表包含不同类型的元素时,下面小编就来讲讲如何使用Python计算两个不同类型列表的相似度吧... 目录摘要引言数字类型相似度欧几里得距离曼哈顿距离字符串类型相似度Levenshtein距离Jaccard相

css实现图片旋转功能

《css实现图片旋转功能》:本文主要介绍了四种CSS变换效果:图片旋转90度、水平翻转、垂直翻转,并附带了相应的代码示例,详细内容请阅读本文,希望能对你有所帮助... 一 css实现图片旋转90度.icon{ -moz-transform:rotate(-90deg); -webkit-transfo

使用C#代码计算数学表达式实例

《使用C#代码计算数学表达式实例》这段文字主要讲述了如何使用C#语言来计算数学表达式,该程序通过使用Dictionary保存变量,定义了运算符优先级,并实现了EvaluateExpression方法来... 目录C#代码计算数学表达式该方法很长,因此我将分段描述下面的代码片段显示了下一步以下代码显示该方法如

如何用Java结合经纬度位置计算目标点的日出日落时间详解

《如何用Java结合经纬度位置计算目标点的日出日落时间详解》这篇文章主详细讲解了如何基于目标点的经纬度计算日出日落时间,提供了在线API和Java库两种计算方法,并通过实际案例展示了其应用,需要的朋友... 目录前言一、应用示例1、天安门升旗时间2、湖南省日出日落信息二、Java日出日落计算1、在线API2

Qt QWidget实现图片旋转动画

《QtQWidget实现图片旋转动画》这篇文章主要为大家详细介绍了如何使用了Qt和QWidget实现图片旋转动画效果,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 一、效果展示二、源码分享本例程通过QGraphicsView实现svg格式图片旋转。.hpjavascript

poj 1113 凸包+简单几何计算

题意: 给N个平面上的点,现在要在离点外L米处建城墙,使得城墙把所有点都包含进去且城墙的长度最短。 解析: 韬哥出的某次训练赛上A出的第一道计算几何,算是大水题吧。 用convexhull算法把凸包求出来,然后加加减减就A了。 计算见下图: 好久没玩画图了啊好开心。 代码: #include <iostream>#include <cstdio>#inclu

uva 1342 欧拉定理(计算几何模板)

题意: 给几个点,把这几个点用直线连起来,求这些直线把平面分成了几个。 解析: 欧拉定理: 顶点数 + 面数 - 边数= 2。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cmath>#inc

uva 11178 计算集合模板题

题意: 求三角形行三个角三等分点射线交出的内三角形坐标。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cmath>#include <stack>#include <vector>#include <

XTU 1237 计算几何

题面: Magic Triangle Problem Description: Huangriq is a respectful acmer in ACM team of XTU because he brought the best place in regional contest in history of XTU. Huangriq works in a big compa

poj 2187 凸包or旋转qia壳法

题意: 给n(50000)个点,求这些点与点之间距离最大的距离。 解析: 先求凸包然后暴力。 或者旋转卡壳大法。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cmath>#include <s