在我正在制作的应用程序中,我需要一些物理计算(功率、力、扭矩等)。我想使用 JScience,因为它在跟踪单位时似乎非常有用。例如,要分配速度,我会这样做:
Amount<Velocity> vel = Amount.valueOf(100, SI.METERS_PER_SECOND);
我的问题是我想在课堂上分配一些角速度,但我无法理解我应该如何做到这一点。假设我想指定 100 rad/s 的角速度。
Amount<AngularVelocity> angVel = Amount.valueOf(100, {SOME UNIT});
我在 JScience 中找不到任何用于角速度的单位。文档说“这个数量的系统单位是”rad/s“(弧度每秒)。”但没有像“SI.RAD_PER_SECOND”这样的东西或任何像我认为的枚举值......
所以问题是:我在后面的代码示例中写成{SOME UNIT}什么?
Birger 的欢呼
---编辑--
有人建议使用“SI.RADIAN.divide(SI.SECOND)”作为单位,但是我必须将变量分配为不同的类型。
// This will not compile, due to type mismatch
Amount<AngularVelocity> angVel = Amount.valueOf(100, SI.RADIAN.divide(SI.SECOND));
// This will compile, but I want to assign the amount as a AngularVelocity ...
Amount<?> angVel = Amount.valueOf(100, SI.RADIAN.divide(SI.SECOND));
// Another, working alternative. But, surely, there is a way to assign an angular velocity using rad/s ... ?
Amount<Frequency> angVel = Amount.valueOf(100 * Math.PI, SI.HERTZ);