反射?我该怎么办呢? [英] Reflection? How do I do it?

查看:213
本文介绍了反射?我该怎么办呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在我的头上,有人可以解释给我好? http://mathworld.wolfram.com/Reflection.html

This is over my head, can someone explain it to me better? http://mathworld.wolfram.com/Reflection.html

我在做一个突破2D格斗游戏,所以我需要的球能反映当它击中墙壁,桨,或敌人(或敌人击中的话)。

I'm making a 2d breakout fighting game, so I need the ball to be able to reflect when it hits a wall, paddle, or enemy (or a enemy hits it).

所有的公式的是这样的:X_1 ^' - X_0 = V-2(V·N ^^)N ^^

all their formula's are like: x_1^'-x_0=v-2(v·n^^)n^^.

和我不能休耕的。 (什么是'意思或X_0?或^^?)

And I can't fallow that. (What does ' mean or x_0? or ^^?)

推荐答案

该公式反映是比较容易,如果你觉得点产品的运作的几何意义,了解。

The formula for reflection is easier to understand if you think to the geometric meaning of the operation of "dot product".

两个3D向量的内积在数学上定义为

The dot product between two 3d vectors is mathematically defined as

<a, b> = ax*bx + ay*by + az*bz

但它有一个很好的几何除pretation

but it has a nice geometric interpretation

之间的点积 B 的长度   的投影 B 与拍摄   一个负号,如果两个向量都指向在   相反的方向,乘以长度的 B

The dot product between a and b is the length of the projection of a over b taken with a negative sign if the two vectors are pointing in opposite directions, multiplied by the length of b.

东西是显而易见使用这个定义,这不是很明显,如果你只是看公式为例子,两个向量的点积如果坐标系旋转并没有改变,这两个点积垂直矢量为0(突出部的长度显然是零在这种情况下),或一个矢量本身的点积是其长度的平方

Something that is immediately obvious using this definition and that it's not evident if you only look at the formula is for example that the dot product of two vectors doesn't change if the coordinate system is rotated, that the dot product of two perpendicular vectors is 0 (the length of the projection is clearly zero in this case) or that the dot product of a vector by itself is the square of its length.

东西是不是不太明显采用几何间pretation是点积是可交换的,即是&LT; A,B&GT; =&LT; B,A&GT; (事实​​是清楚的考虑公式)

Something that is instead less obvious using the geometric interpretation is that the dot product is commutative, i.e. that <a, b> = <b, a> (fact that is clear considering the formula).

这是很重要的一点要考虑的是也,如果对 B 的长度为1,那么点积&LT; A,B&GT; 简直就是的投影长度 B (用正确的符号取)。

An important point to consider is also that if the length of b is 1 then the dot product <a, b> is simply the length of the projection of a over b (taken with the proper sign).

鉴于这种跨pretation是很容易的公式计算反射了飞机就明白了:

Given this interpretation the formula for computing the reflection over a plane is quite easy to understand:

要计算的反射向量的研究,给定一个向量与正常的 N 您只需要使用公式 和面

To compute the reflected vector r, given a vector a and a plane with normal n you just need to use the formula:

r = a - 2<a, n> n

高度 ^ h 的数字是在这种情况下,仅仅&LT; A,N&GT; (注意, N 假定为单位长度),并因此它应该清楚的是需要这样的高度移动两次在正常的方向。

the height h in the figure is in this case just <a, n> (note that n is assumed to be of unit length) and so it should be clear that you need to move twice that height in the direction of the normal.

如果您认为合适的点积的迹象,你应该看到,同样的配方也适用于当事件的vector 正常的 N 正面临着相同的一个和飞机方向发展。

If you consider the proper dot product signs you should see that the very same formula applies also when the incident vector a and the plane normal n are facing in the same direction.

这篇关于反射?我该怎么办呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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