查找弧度反射角反射角、弧度

2023-09-08 14:20:01 作者:少年,换心么

我编写一个简单的Flash游戏,刚学的闪光灯和提高我的数学,但我发现很困惑与弧度,因为有新的我。

I'm coding a simple Flash game, just to learn flash and improve my maths, but I'm getting very confused with Radians as there are new to me.

我到目前为止已经用鼠标做的,你(点击&安培;释放),你在这个方向使用弧度射将球断下。现在我想发生的情况是,当球击中它在它的反射角反弹的墙上。例如。如果球击中右手侧壁在-0.65弧度一个行进应该反弹在约-2.5的弧度

What I've done so far is using your mouse you (click & release) you shoot a ball off in that direction using radians. Now what I'd like to happen is when the ball hits the wall it bounces off in it's reflection angle. Eg. if the ball hits the right-hand-side wall travelling at in a radians of -0.65 it should bounce back in the radians of about -2.5

可能有的请向我解释我是如何去这样做? 谢谢

Could some please explain to me how I go about doing this? Thanks

推荐答案

如果您使用弧度,你应该PSS他们(总是)EX $ P $淠,只需通过丕分裂。使它更容​​易与合作和理解。

If you work with radians, you should (always) express them in Pi, simply divide by Pi. Make it much easier to work with and understand.

-0.65 rad = -0.207*Pi rad
-2.5 rad = -0.796*Pi rad

一个完整的圆为2 * PI。在正常的水平面上为0.5 * PI(或-0.5 * PI)。

A full circle is 2*Pi. The normal for a horizontal surface is 0.5*Pi (or -0.5*Pi).

normal = 0.5*Pi
angle of incidence = i + Pi - 0.5*Pi //EDIT: +Pi, need to invert the direction
angle of reflection = 0.5*Pi - angle of incidence

请参阅思考维基百科上的图像和一些解释。这给了这个公式的水平墙面:

See Reflection on wikipedia for a image and some explanation. That gives this formula for a horizontal wall:

r = 0.5*Pi - (i + Pi - 0.5*Pi)
r = 2*Pi - i 
r = -i //subtract 2*Pi

例如

i = -0.207*Pi //gives
r = 0.207*Pi //for a horizontal wall

相似的垂直墙面:

r = 0 - (i + Pi - 0)
r = -Pi - i

修改我意识到这是不正确的。对式工作, I 具有在相反方向上精确地指向。固定它,希望它现​​在是正确的。如果我有时间后,我将包括图像解释错误和解决方案。

EDIT I realized this was not correct. For the formula to work, i has to point exactly in the opposite direction. Fixed it, hopefully it is correct now. If I got time later, I'll include an image explaining the mistake and solution.