简体   繁体   English

jScience中的单位; 角速度的单位是多少?

[英]Units in jScience; Whats the unit of an angular velocity?

In an application I'm making, I need some physics calculations (power, forces, torques etc.). 在我正在做的应用程序中,我需要一些物理计算(功率,力,转矩等)。 I want to use JScience, because it seems really useful when it comes to keeping track of units. 我想使用JScience,因为它在跟踪单位方面似乎非常有用。 For instance, to assign a velocity I would do this: 例如,要分配速度,我可以这样做:

Amount<Velocity> vel = Amount.valueOf(100, SI.METERS_PER_SECOND);

My problem is that I want to assign some angular velocity in a class, but I can't wrap my head around how I am supposed to do this. 我的问题是我想在一个班级中分配一些角速度 ,但是我不能为应该如何做而费神。 Say I want to specify an angular velocity of 100 rad/s. 假设我要指定100 rad / s的角速度。

Amount<AngularVelocity> angVel = Amount.valueOf(100, {SOME UNIT});

I can't find any unit in JScience to use for angular velocity. 我在JScience中找不到用于角速度的任何单位。 The documentation says "The system unit for this quantity is "rad/s" (radian per second).", but there is no such thing as a an "SI.RAD_PER_SECOND" or any enum value like that I think... 文档说“此数量的系统单位为“ rad / s”(每秒弧度)。”但是没有“ SI.RAD_PER_SECOND”之类的值或我认为的任何枚举值...

So the question is: What do I write as {SOME UNIT} in the latter code sample? 所以问题是:在后一个代码示例中,我如何写为{SOME UNIT}

Cheers from Birger 来自伯杰的欢呼

--- EDIT -- - 编辑 -

Got suggestions to use "SI.RADIAN.divide(SI.SECOND)" as unit, but then I have to assing the variable to a different type. 有建议使用“ 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);

I'm no expert with this particular library, but some quick tests in eclipse led me to this : 我不是这个特定库的专家,但是在eclipse中的一些快速测试使我想到了这一点:

Amount<AngularVelocity> angVel = Amount.valueOf(100, AngularVelocity.UNIT);

The problem with that is that if AngularVelocity.UNIT changes, your quntity will change too. 这样做的问题是,如果AngularVelocity.UNIT更改,则您的数量也会更改。 But that's unlikely I'd say. 但这不太可能。

Otherwise, giving a less beautiful line of code : 否则,给出不太美观的代码行:

Amount<AngularVelocity> angVel = Amount.valueOf(100, SI.RADIAN.divide(SI.SECOND).asType(AngularVelocity.class));

This leads me to a good hint when programming in Java: Use control-space. 这使我在使用Java进行编程时有一个很好的提示:使用控制空间。 A lot. 很多。 I never used this library and I was still able to find this with just a quick check in the doc for the AngularVelocity.UNIT version. 我从来没有使用过这个库,但仍然可以通过快速查看AngularVelocity.UNIT版本的文档来找到它。 The other is just control-space after your own solution. 另一个只是您自己的解决方案之后的控制空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM