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

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

问题描述

所以我的身高是 self.frame.height,它返回 736,正如 iPhone 6s 所期望的那样.如何将此值转换为米以与physicsWorld单位系统保持一致?

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??

推荐答案

大约135点一米.

一个物理体在 9.8m/s 的重力下从静止状态下落,在 1.00806862953687s (1.01s) 内移动了 660 个点,速度为 1342.8162841796875m/s (1342.82).

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).

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

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:

利用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 点.

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.

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

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.

如果您完全精确地进行数学运算,您将得到 137 分.

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

使用大约 2 秒后的时间,加速度公式为 133.4 点/米,距离公式为 133.7 点/米

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

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

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.

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

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