找回密码
 欢迎注册
查看: 9276|回复: 8

[提问] 如何求矩形在不同角度时4个角度坐标?

[复制链接]
发表于 2020-9-23 13:05:15 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
已知矩形长26宽11,R角半径为2,中心点O的 坐标为(0,0),怎样求矩形旋转任意角度后角A、B、C、D的坐标位置。
1600824531(1).jpg
1600824585(1).jpg
1600831042(1).jpg

评分

参与人数 1金币 +20 收起 理由
gxqcn + 20 首帖奖励,欢迎常来。

查看全部评分

毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2020-9-23 13:58:25 | 显示全部楼层
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2020-9-23 22:02:53 | 显示全部楼层
zeroieme 发表于 2020-9-23 13:58
https://zh.wikipedia.org/wiki/%E6%97%8B%E8%BD%AC

兄弟链接打不开啊
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2020-9-25 17:05:42 | 显示全部楼层
这是一个很简单的问题:
假设旋转角度为α(右手法则),旋转前点的坐标为(x,y),旋转后的坐标为(x',y'),则
x'=x*cos(α)-y*sin(α)
y'=x*sin(α)+y*cos(α)
比如,B点旋转前坐标为(13+√2,5.5+√2),则旋转后的坐标(x',y')为
x'=(13+√2)*cos(α)-(5.5+√2)*sin(α)
y'=(13+√2)*sin(α)+(5.5+√2)*cos(α)
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2020-9-25 20:01:38 | 显示全部楼层
\[\left(
\begin{array}{c}
A \\
B \\
C \\
D \\
\end{array}
\right)^T = \left(
\begin{array}{cc}
\cos (\theta ) & -\sin (\theta ) \\
\sin (\theta ) & \cos (\theta ) \\
\end{array}
\right)\cdot\left(
\begin{array}{cc}
-R \sin \left(\frac{\pi }{4}\right)-\frac{w}{2} & \frac{h}{2}+R \sin \left(\frac{\pi }{4}\right) \\
R \sin \left(\frac{\pi }{4}\right)+\frac{w}{2} & \frac{h}{2}+R \sin \left(\frac{\pi }{4}\right) \\
-R \sin \left(\frac{\pi }{4}\right)-\frac{w}{2} & -\frac{h}{2}-R \sin \left(\frac{\pi }{4}\right) \\
R \sin \left(\frac{\pi }{4}\right)+\frac{w}{2} & -\frac{h}{2}-R \sin \left(\frac{\pi }{4}\right) \\
\end{array}
\right)^T=\left(
\begin{array}{cc}
\cos (\theta ) \left(-\frac{R}{\sqrt{2}}-\frac{w}{2}\right)-\left(\frac{h}{2}+\frac{R}{\sqrt{2}}\right) \sin (\theta ) & \left(\frac{h}{2}+\frac{R}{\sqrt{2}}\right) \cos (\theta )+\sin (\theta ) \left(-\frac{R}{\sqrt{2}}-\frac{w}{2}\right) \\
\cos (\theta ) \left(\frac{R}{\sqrt{2}}+\frac{w}{2}\right)-\left(\frac{h}{2}+\frac{R}{\sqrt{2}}\right) \sin (\theta ) & \left(\frac{h}{2}+\frac{R}{\sqrt{2}}\right) \cos (\theta )+\sin (\theta ) \left(\frac{R}{\sqrt{2}}+\frac{w}{2}\right) \\
\cos (\theta ) \left(-\frac{R}{\sqrt{2}}-\frac{w}{2}\right)-\left(-\frac{h}{2}-\frac{R}{\sqrt{2}}\right) \sin (\theta ) & \left(-\frac{h}{2}-\frac{R}{\sqrt{2}}\right) \cos (\theta )+\sin (\theta ) \left(-\frac{R}{\sqrt{2}}-\frac{w}{2}\right) \\
\cos (\theta ) \left(\frac{R}{\sqrt{2}}+\frac{w}{2}\right)-\left(-\frac{h}{2}-\frac{R}{\sqrt{2}}\right) \sin (\theta ) & \left(-\frac{h}{2}-\frac{R}{\sqrt{2}}\right) \cos (\theta )+\sin (\theta ) \left(\frac{R}{\sqrt{2}}+\frac{w}{2}\right) \\
\end{array}
\right)^T\]
代入$w=26,h=11,R=2$得到\(\left(
\begin{array}{c}
A \\
B \\
C \\
D \\
\end{array}
\right)^T =\left(
\begin{array}{cc}
\left(-\sqrt{2}-13\right) \cos (\theta )-\left(\sqrt{2}+\frac{11}{2}\right) \sin (\theta ) & \left(-\sqrt{2}-13\right) \sin (\theta )+\left(\sqrt{2}+\frac{11}{2}\right) \cos (\theta ) \\
\left(\sqrt{2}+13\right) \cos (\theta )-\left(\sqrt{2}+\frac{11}{2}\right) \sin (\theta ) & \left(\sqrt{2}+13\right) \sin (\theta )+\left(\sqrt{2}+\frac{11}{2}\right) \cos (\theta ) \\
\left(-\sqrt{2}-13\right) \cos (\theta )-\left(-\sqrt{2}-\frac{11}{2}\right) \sin (\theta ) & \left(-\sqrt{2}-13\right) \sin (\theta )+\left(-\sqrt{2}-\frac{11}{2}\right) \cos (\theta ) \\
\left(\sqrt{2}+13\right) \cos (\theta )-\left(-\sqrt{2}-\frac{11}{2}\right) \sin (\theta ) & \left(\sqrt{2}+13\right) \sin (\theta )+\left(-\sqrt{2}-\frac{11}{2}\right) \cos (\theta ) \\
\end{array}
\right)^T\)

  1. Transpose[RotationMatrix[\[Theta]].Transpose[{{-R Sin[Pi/4]-w/2,R Sin[Pi/4]+h/2},{R Sin[Pi/4]+w/2,R Sin[Pi/4]+h/2},{-R Sin[Pi/4]-w/2,-R Sin[Pi/4]-h/2},{R Sin[Pi/4]+w/2,-R Sin[Pi/4]-h/2}}]]/.{w->26,h->11,R->2}
复制代码

点评

已经改正,差点蒙混过关了。当时忘了转置,所以不能批量变换,就偷懒,没想到这还能出错,嘿嘿。  发表于 2020-9-26 16:48
是我错了,哈哈哈,我应该左边乘以旋转矩阵,而不是右边乘  发表于 2020-9-26 16:26
θ是如何定义的?如果按通常定义(右手法则),则当θ=arctg[(13+√2)/(5.5+√2)]时(即将B点旋转到y轴上)(0<θ<π/2),B点旋转后的x坐标等于0,但按上面公式B点旋转后的x坐标大于0(当0<θ<π/2)。  发表于 2020-9-26 15:52
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2020-10-9 11:20:01 | 显示全部楼层
wayne 发表于 2020-9-25 20:01
\[\left(
\begin{array}{c}
A \\

好的谢谢两位,我先消化一下
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-5-4 13:47 , Processed in 0.057233 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表