简体   繁体   English

AffineTransform setToRotation - 参数代表什么?

[英]AffineTransform setToRotation - what do the parameters stand for?

I am currently trying to make som polygons rotate for my Asteroids game!我目前正在尝试为我的小行星游戏旋转一些多边形! :) :)

In order to do that, I'm using the AffineTransform setToRotation() method, however I am very confused about the meaning of the parameters.为了做到这一点,我使用了 AffineTransform setToRotation() 方法,但是我对参数的含义感到非常困惑。 For setToRotation(a, b, c) I understand that b and c are the x and y coordinates of the point, the shape revolves around.对于setToRotation(a, b, c)我理解 b 和 c 是点的 x 和 y 坐标,形状围绕。 a somehow makes the shape rotate, but it doesn't appear to be in degrees. a 以某种方式使形状旋转,但它似乎不是度数。 So what else is it?那么还有什么呢? And what to the other two setToRotation methods ( setToRotation(a, b) and setToRotation(a) ) do?其他两个 setToRotation 方法( setToRotation(a, b)setToRotation(a) )怎么办? I dont understand them AT ALL.我完全不理解他们。

Thanks for every answer!感谢您的每一个回答!

As in the documentation :文档中所示

theta - the angle of rotation measured in radians theta - 以弧度为单位的旋转角度

All of the trigonometric functions in java.lang.Math either accept or return radians. java.lang.Math所有三角函数都接受或返回弧度。

You can convert from degrees to radians using Math.toRadians .您可以使用Math.toRadians将度数转换为弧度。

The other method overloads are also described in the documentation.文档中还描述了其他方法重载。 Unless you can describe what about them you don't understand, there is no point in trying to explain them again, as that explanation could be in the same terms that you don't understand.除非您可以描述您不理解的内容,否则尝试再次解释它们是没有意义的,因为该解释可能使用您不理解的相同术语。

So what else is it?那么还有什么呢?

It is in radians.它以弧度为单位。 You can see its documentation here .您可以在此处查看其文档。 To convert from degrees to radians, just divide by 180 then times by π, so π radians is 180 degrees for examples.要将度数转换为弧度,只需除以 180 然后乘以 π,例如 π 弧度就是 180 度。 Or you can use Math.toRadians .或者您可以使用Math.toRadians

And what to the other two setToRotation methods (setToRotation(a, b) and setToRotation(a)) do?其他两个 setToRotation 方法(setToRotation(a, b) 和 setToRotation(a))怎么办?

Those are also very well documented.这些也有很好的记录。 See this and this .看到这个这个

Basically, the one that takes one parameter is equivalent to calling setToRotation(a, b, c) but with b and c all equal to 0, and the one that takes 2 parameters is equivalent to calling setToRotation(a) with the inverse tangent of the quotient of the two parameters ( setToRotation(Math.atan2(a, b)) ).基本上,带一个参数的等效于调用setToRotation(a, b, c)bc都等于 0,带 2 个参数的等效于调用setToRotation(a)的反正切为两个参数的商( setToRotation(Math.atan2(a, b)) )。

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

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