How do I calculate the height of the bottom edge when rotating a plane on the x-axis in 3d space?

喜夏-厌秋 提交于 2019-12-08 06:29:55

问题


In my iOS app, I have a view that I'm translating on the X axis in 3D space. The anchor point for the view is in the top center. If I rotate the view M_PI degrees, it will appear to go flat. I need X pixels between the bottom of the screen and the bottom edge of the rotated view (essentially, the bottom edge's height off the ground needs to be X px). How do I calculate this percentage of M_PI?

Here's an example. In this case the view is 100px high, and I need to rotate it some percentage of M_PI such that there's 40px from the bottom edge of the screen.


回答1:


This is fairly simple trigonometry. If you want 40 pixels between the bottom of your shape and the bottom of the screen, then you have 60 pixels between the top and bottom edges of your shape. You know that before rotation your shape was 100 pixels tall, so to find the angle, just take arccos(60/100) = 53.13º = .295167 * M_PI.



来源:https://stackoverflow.com/questions/11835111/how-do-i-calculate-the-height-of-the-bottom-edge-when-rotating-a-plane-on-the-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!