为什么我不应该在Box2D中使用像素作为单位? [英] Why shouldn't I use pixels as unit with Box2D?

查看:116
本文介绍了为什么我不应该在Box2D中使用像素作为单位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在手册中说我应该使用小型单位(0.1-10米).不建议使用像素作为度量单位.但是为什么Box2D会比我使用小型单元更好地工作并且具有更好的模拟效果?

In the manual it says that I should use small units (0.1-10 meters). It's discouraged to use pixels as the unit of measure. But why would Box2D be working better, and have better simulation than when I'd use small units?

推荐答案

Box2D是一个模拟框架,内部使用 MKS单位制.如果需要可靠且可预测的仿真,则应在此单位制内以合理的值表示创建的仿真系统.您想要一个盒子像一个盒子,一个岩石像一个岩石,一个球像一个球.

Box2D is a simulation framework which internally uses the MKS system of units. If you want a reliable and predictable simulation, you should express the simulation systems you create in reasonable values within this system of units. You want a box to behave like a box, a rock to behave like a rock and a ball to behave like a ball.

如果以像素为单位,并且有一个20 x 20像素的盒子,其标量质量值为10,则实际上创建的盒子的边长为20米,质量只有10公斤.从本质上讲,您的仿真将变得难以设置且难以逼真地表现出来.

If you take pixels as a unit and you have a box of 20 by 20 pixels with a scalar mass value of 10, you really create a box with sides of 20 meters long, which has a mass of a mere 10 kilograms. In essence, your simulation becomes difficult to set up and be made to behave realistically.

没有什么可以阻止您使用像素作为单位.但是,为了使其行为可靠,自然和可预测,最好以期望的单位并在合理的范围内表达馈入仿真框架的值,这种做法越来越容易.

There is nothing stopping you from using pixels as units. But for it to behave reliably, naturally and predictably, it is better and easier to express the values fed to the simulation framework in the units it expects and within reasonable boundaries.

这篇关于为什么我不应该在Box2D中使用像素作为单位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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