如何旋转坐标系?
如果我绕原点旋转,我试图找到坐标的新值。
例如,假设我有点 (1,1)。 如果我绕原点旋转坐标轴 45 度,变换后的坐标将为 (0,1.414)
有没有办法在 cocos2d 或 Objective-c 中有效地做到这一点? 即使是解释数学原理的答案也会有所帮助。
I am trying to find the new value of a coordinate if I rotate around the origin.
For example, say I have the point (1,1).
If I rotate the coordinate axis 45 degrees around the origin, the transformed coordinate would be (0,1.414)
Is there a way to do this efficiently in cocos2d, or in objective-c ?
Even answers explaining the math to do this would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅此页面:
http://www.siggraph.org/education/materials/HyperGraph /modeling/mod_tran/2drota.htm
这是公式:
x' = x cos f - y sin f
y' = y cos f + x sin f
请记住,sin 和 cos 需要弧度,所以你必须这样做:
我没有测试这个,所以可能会有拼写错误...;)
See this page:
http://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/2drota.htm
This is the formula:
x' = x cos f - y sin f
y' = y cos f + x sin f
Remember that sin and cos takes radians, so you have to do like this:
I didn't test this, so there might be typos... ;)