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

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

问题描述

这超出了我的理解,谁能更好地向我解释一下?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

但它有一个很好的几何解释

but it has a nice geometric interpretation

ab 之间的点积是长度ab 的投影如果两个向量指向,则为负号相反的方向,乘以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.

使用几何解释不那么明显的是点积是可交换的,即 = <b, a>(考虑到公式,这个事实很清楚).

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,那么点积 就是投影的长度a 超过 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).

鉴于这种解释,计算平面反射的公式很容易理解:

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

要计算反射矢量 r,给定矢量 a 和具有法线 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在这种情况下只是(注意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.

如果您考虑适当的点积符号,您应该会发现当入射向量 a 和平面法线 n 面向同一方向时,该公式也适用.

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

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

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