如何获得以米为单位的场景高度(快速)? [英] How to get scene height in meters (swift)?

查看:74
本文介绍了如何获得以米为单位的场景高度(快速)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的身高为self.frame.height,该高度返回iPhone 6s预期的736.如何将此值转换为米,以与PhysicalWorld单位制保持一致?

解决方案

到一米大约135点.

在9.8m/s的重力作用下从静止中坠落的PhysicsBody在1.00806862953687s(1.01s)中移动了660点,速度为1342.8162841796875m/s(1342.82).

将数学计算到小数点后两位,我们可以使用行进距离和速度方程来通过2种不同的计算来计算每米的点数:

使用v = u + at(u = 0,a = 9.8,t = 1.01s),我们可以计算出1.01s之后,v为1.01 * 9.8 = 9.90m/s.物理体的速度为1342.85,因此9.90m/s = 1342.82点/s,所以1m = 135.6点.

或者,使用s = ut + 1/2at²来计算时间t之后的行进距离,我们得出s = 0.5x9.8x1.01 = 4.95m.因此,4.95m = 660点; 1m = 133.3点.

如果完全精确地进行数学运算,您将获得137点的数字.

使用大约2秒钟后的计时,加速度公式得出的数字为133.4点/m,距离公式得出的数字为133.7点/m

奇怪的是,SKPhysicsBody类引用将速度属性描述为以米/秒为单位,但绝对以每秒点数为单位.

So I have my height as self.frame.height which returns 736 as expected for an iPhone 6s. How do I convert this value into meters to be consistent with the physicsWorld unit system??

解决方案

It's about 135 points to a meter.

A physicsBody left to fall from stationary under gravity of 9.8m/s travelled 660 points in 1.00806862953687s (1.01s), with a velocity of 1342.8162841796875m/s (1342.82).

Doing the maths to 2 decimal places, we can use both the equations of distance travelled and speed to calculate the number of points per meter through 2 different calculations:

Using v=u+at (u=0, a=9.8, t=1.01s), we can calculate that after 1.01s, v is 1.01 * 9.8 = 9.90m/s. The physicsbody's velocity is 1342.85, Therefore 9.90m/s = 1342.82 points/s so 1m = 135.6 points.

Or, using s=ut+½at², to calculate the distance travelled after time t, we get s = 0.5x9.8x1.01 = 4.95m. Therefore 4.95m = 660point; 1m = 133.3 points.

If you do the maths with the full precision, you get a figure of 137 points.

Using the timings after approx 2 seconds gives a figure of 133.4 points/m from the acceleration formula and 133.7points/m from the distance formula

What is odd is that the SKPhysicsBody class reference described the velocity property as being in meters/second, but it definitely appears to be in points per second.

这篇关于如何获得以米为单位的场景高度(快速)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆