Tuesday, September 30, 2014

The Cross Product

The Cross Product
We saw in the previous section on dot products that the dot product takes two vectors and produces a scalar, making it an example of a scalar product. In this section, we will introduce a vector product, a multiplication rule that takes two vectors and produces a new vector. We will find that this new operation, the cross product, is only valid for our 3-dimensional vectors, and cannot be defined in the 2- dimensional case. 

One important feature of the dot product is its invariance under rotations.In other words, if we take a pair of vectors in the plane and rotate them both by the same angle, their dot product will remain the same. Consider the length of a single vector (which is given by the dot product): if the vector gets rotated about the origin by some angle, its length will not change--even though its direction can change quite dramatically! Similarly, from the geometric formula for the dot product, we see that the result depends only on the lengths of the two vectors and the angle between them. None of these quantities changes when we rotate the two vectors together, so neither can their dot product. This is what we mean when we say that the dot product is invariant under rotations.

Making the requirement of rotational invariance more stringent for the cross product, we need the cross product of two vectors to yield another vector. Consider, for instance, two 3-dimensional vectors u and v in a plane (two non-parallel vectors always define a plane, in the same way that two lines do. If we rotate this plane, the vectors will change direction, but we don't want the cross product w = u×v to change at all. However, if w has any non-zero components in the plane of u and v , those components will necessarily change under rotation (they get rotated just like everything else). The only vectors that won't change at all under a rotation of the u - v plane are those vectors that are perpendicular to the plane. Hence, the cross product of two vectors u and v must give a new vector which is perpendicular to both u and v .

we can see immediately that it is not possible to define a cross product for two- dimensional vectors, since there is no direction perpendicular to the plane of two-dimensional the vectors! (We'd need a third dimension for that).


Let's begin by defining the cross product for the unit vectors i , j , and k . Since all vectors can be decomposed in terms of unit vectors (see Unit vectors), once we've defined the cross products for this special case it will be easy to extend the definition to include all vectors. As we noted above, the cross product between iand j (since they both lie in the x - y plane) must point purely in the z -direction. Hence:


i×j = c k

for some constant c . Because later on we will want the magnitude of the resultant vector to have geometric significance, we need c k to have unit length. In other words, c can be either +1 or -1. Now we make a completely arbitrary choice in order to accord with convention: we choose c = + 1 . The fact that we have chosen c to be positive is known as The Right-Hand Rule.

It turns out that in order to be consistent with the Right-Hand Rule, all of the cross products between unit vectors are uniquely determined:

i×j=k = - j×i 
j×k=i = - k×j 
k×i=j = - i×k 

In particular, notice that the order of the vectors within the cross products holds significance. In general, u×v = - v×u . From here we can see that the cross product of a vector with itself is always zero, since by the above rule u×u = - u×u , which means that both sides must vanish for equality to hold. We can now complete our list of cross products between unit vectors by observing that:
i×i = j×j = k×k = 0

Geometric Formula for Cross Product
Consider the cross product of two (not necessarily unit-length) vectors that lie purely along the x and y axes (as i and j do). We can thus write the vectors as u = a i and v = b j , for some constants a and b . The cross product u×v is thus equal to
u×v = ab(i×j) = ab k   

Notice that the magnitude of the resultant vector is the same as the area of the rectangle with sides u and v ! As promised above, the magnitude of the cross product between two vectors, u×v| , has a geometric interpretation. In general it is equal to the area of the parallelogram having the two given vectors as its sides (see ).
From basic geometry, we know that this area is given by area = | u|| v| sinθ , whereu| and v| are the lengths of the sides of the parallelogram, and θ is the angle between the two vectors. Notice that when the two vectors are perpendicular to each other, θ = 90 degrees, so sinθ = 1 and we recover the familiar formula for the area of a square. On the other hand, when the two vectors are parallel, θ = 0 degrees, and sinθ =0, meaning the area vanishes (as we expect). In general, then, we find that the magnitude of the cross product between two vectors u and v that are separated by an angle θ (going clockwise from u to v , as specified by the Right-Hand Rule) is given by:
u×v| = | u|| v| sinθ   

In particular, this means that for two parallel vectors the cross product equals 0.

Cross Product Summary

In summary, the cross product of two vectors is given by:
u×v = (u 1 v 2 - u 2 v 1)k + (u 3 v 1 - u 1 v 3)j + (u 2 v 3 - u 3 v 2)i   

where the resultant vector is perpendicular to each of the original two and its magnitude is given by u×v| = | u|| v| sinθ .

Unit Vector

vector has magnitude (how long it is) and direction:

Unit Vector

Unit Vector has a magnitude of 1:

The symbol is usually a lowercase
letter with a "hat", such as:
(Pronounced "a-hat")

Scaling

A vector can be "scaled" off the unit vector. Here vector a is shown to be 2.5 times a unit vector. Notice they still point in the same direction:

In 2 Dimensions

You can use unit vectors to help you work with vectors in 2 dimensions:
Here we show that the vector a is made up of 2 "x" unit vectors and 1.3 "y" unit vectors.

In 3 Dimensions

Likewise we can use unit vectors in three (or more!) dimensions:
Read full article from Unit Vector

Monday, September 29, 2014

Straight-Line Equations: Slope-Intercept Form

http://www.purplemath.com/modules/strtlneq.htm
  • Find the equation of the line that passes through the points (–2, 4) and (1, 2).
    Well, if I have two points on a straight line, I can always find the slope; that's what the slope formula is for.
      slope m = -2/3
The other format for straight-line equations is called the "point-slope" form. For this one, they give you a point (x1y1) and a slope m, and have you plug it into this formula:
     y1 = m( x1)
  • Find the equation of the line that passes through the points (–2, 4) and (1, 2).
    I've already answered this one, but let's look at the process. I should get the same result (namely,  y = ( – 2/x + 8/). Given two points, I can always find the slope:
      slope m = -2/3
    Then I can use either point as my (x1y1), along with this slope Ive just calculated, and plug in to the point-slope form. Using (–2, 4) as the (x1y1), I get:
     y1 = m( x1) y – (4) = ( – 2/)(x – (–2)) y – 4 = ( – 2/)(x + 2) y – 4 = ( – 2/x – 4/3y = ( – 2/x – 4/3 + 4 y = ( – 2/x – 4/3 + 12/3 y = ( – 2/x + 8/3

y=(y2-y1/x2-x1)*X+(x2y1-x1y2/x2-x1)

Tuesday, September 23, 2014

Lucene/Solr Revolution 2013 - Dublin - YouTube


Read full article from Lucene/Solr Revolution 2013 - Dublin - YouTube

Thursday, September 11, 2014

Modular multiplicative inverse - Wikipedia, the free encyclopedia

In modular arithmetic, the modular multiplicative inverse of an integer a modulo m is an integer x such that

a\,x \equiv 1 \pmod{m}.

That is, it is the multiplicative inverse in the ring of integers modulo m, denoted \mathbb{Z}_m.

Once defined, x may be noted a^{-1}, where the fact that the inversion is m-modular is implicit.

The multiplicative inverse of a modulo m exists if and only if a and m are coprime (i.e., if gcd(a, m) = 1). If the modular multiplicative inverse of a modulo m exists, the operation of division by a modulo m can be defined as multiplying by the inverse, which is in essence the same concept as division in the field of reals.


Read full article from Modular multiplicative inverse - Wikipedia, the free encyclopedia

Pascal's Triangle

One of the most interesting Number Patterns is Pascal's Triangle (named after Blaise Pascal, a famous French Mathematician and Philosopher).

To build the triangle, start with "1" at the top, then continue placing numbers below it in a triangular pattern.

Each number is the two numbers above it added together (except for the edges, which are all "1").

(Here I have highlighted that 1+3 = 4)

Patterns Within the Triangle

 

Diagonals

The first diagonal is, of course, just "1"s, and the next diagonal has the Counting Numbers (1,2,3, etc).

The third diagonal has the triangular numbers

(The fourth diagonal, not highlighted, has the tetrahedral numbers.)


Read full article from Pascal's Triangle

Tuesday, September 9, 2014

domenic's question at Yahoo! Answers regarding computing the work to empty a tank

A tank containing oil is in the shape of a downward-pointing cone with its vertical axis perpendicular to ground level. In this exercise we will assume that the height of the tank is h=16 feet , the circular top of the tank has radius r=8 feet, and that the oil inside the tank weighs 55 pounds per cubic foot.
How much work (W) does it take to pump oil from the tank to an outlet that is 3 feet above the top of the tank if, prior to pumping, there is only a half-tank of oil? Note: "half-tank" means half the volume in the tank.
Note: For this problem a pound is to be taken as a unit of weight (not of mass), so it is not necessary to multiply by the gravitational acceleration constant in order to find the work.

Read full article from domenic's question at Yahoo! Answers regarding computing the work to empty a tank

Monday, September 8, 2014

自动扫雷游戏中的概率分析之程序实现和数学实现

http://www.cr173.com/html/18295_1.html
第一种、第二种模型
分析右上角的的2,其周围的未知块a,b两块,等于其周围雷数,故可判断出a,b都是雷;接下来,分析下面的2,其周围共有3个未显示的块a,b,c,其中a,b已判断出为雷,即周围已判断的雷数等于其雷数时,则可判断剩下的块都不是雷,即c块不是雷。
这两种模型,一种是判断出雷、一种是判断出没有雷,这是地球人都知道的扫雷方法。而接下来的模型或许只有扫雷高手或者数学高手才知道~~
第三种模型
我先做一个大胆的判断,c块没有雷!!且听我慢慢道来~
根据两个显示为1的块,可得如下的式子:
a+b=1                 (1)  
d+e=1                 (2)
表示a,b中有且只有一个雷,d,e有且只有一个雷,
根据显示为2的块,可得:
a+b+c+d+e=2         (3)
表示abcde中有且只有两个雷
根据(1)(3),可得
c+d+e=1      (4)
根据(2)(4)可得, c=0  ,所以c块肯定无雷,可放心地揭开。
这种模型可以说在扫雷中应用得最精妙,看似无法判断的情况,通过这样的计算就可确定出哪里是雷或者哪里不是雷。
第四种模型 - 数学概率
上面三种模型都属于可确定判断的范畴,而在扫雷中经常会遇到无法确定判断的死局。这时就得用到数学工具——概率,来进行最优判断。
如图所示显示为3周围有雷的概率很容易计算出:3/8(这是比较简单的情况)。再看下面的图
当点开两个"8邻接"距离小于等于2的块时,它们周围有雷的概率就不那么容易判断了(上面a,b,c有雷的概率分别是多少)
先看游戏界面,如下:   
在游戏开始时,如何出现这样的情况,我们可以认为游戏中未显示块按概率相等可分为四个区域,其中a,b,c是其中的三个区域(a区域指上面的5个块,b区域指中间的3个块,c区域指下面的5个块),再加上不与已揭开块相邻的所有块构成一个区域d(d区域含有465块)。那么这四个区域中哪个区域有雷的概率最小呢?
这里直接说明所使用的数学方法叫做——条件概率和全概率公式。
条件概率可以说是计算机领域的一个功臣,由其发展而来的“统计语言模型”实现了机器翻译、语音识别、汉字识别等一系列的用传统方法很难解决的问题。而以其为基础的“贝叶斯公式”在图像处理、决策支持系统和博弈论中有着广泛的应用。
维基百科中给的定义是:条件概率就是事件A在另外一个事件B已经发生条件下的发生概率。条件概率表示为P(A|B),读作“在B条件下A的概率”。
而全概率为:
假设{ Bn : n = 1, 2, 3, ... } 是一个概率空间的有限或者可数无限的分割,且每个集合Bn是一个可测集合,则对任意事件A有全概率公式
又因为
此处Pr(A | B)是B发生后A的条件概率,所以全概率公式又可写作:
用自己的话说,条件概率是在某件事发生的情况下,另一件事的概率;全概率是将所有情况的概率加起来。
而在扫雷游戏中有什么“所有情况”呢?
看上面的游戏场景,a,b,c所占的13个块,如果仅仅根据上面所显示的"1","2",可以说这13个块中,雷的总数可以有2个,也可以有3个!!并且有2个或者3个的概率分别是1/2。
 那么其情况如下:
上表说明当雷数为2时,abc有雷的概率分别为0,1/3,1/5;当雷数为3时,abc有雷的概率分别为1/5,0,2/5。
可算出
a区域有雷的概率为0*1/2+(1/5)*(1/2)=1/10
b区域有雷的概率为(1/2)*(1/3)+0*1/2=1/6
c区域有雷的概率为(1/2)*(1/5)+(1/2)*(2/5)=3/10
而d区域的概率同理也算出为(1/2)*(97/465)+(1/2)*(96/465)=193/930
可知,a区域有雷的概率最小,故可以在此5块中随机选一块点击了,然后一切就交给上苍了~~(在不用类似查看内存的方法的情况下,人做的就只有这么多了)
到此,数学原理已介绍完毕,用一句话总结,即,先找出按区域划分的未显示块,然后分类讨论这些区域中雷的总个数。接下来的一篇博文(也是本系列最后一篇),将介绍如何将上面的数学运算用程序代码实现。

Sunday, September 7, 2014

Barycentric Coordinates -- from Wolfram MathWorld

Barycentric Coordinates

Barycentric coordinates are triples of numbers (t_1,t_2,t_3) corresponding to masses placed at the vertices of a reference triangle DeltaA_1A_2A_3. These masses then determine a point P, which is the geometric centroid of the three masses and is identified with coordinates (t_1,t_2,t_3). The vertices of the triangle are given by (1,0,0), (0,1,0), and (0,0,1). Barycentric coordinates were discovered by Möbius in 1827 (Coxeter 1969, p. 217; Fauvel et al. 1993).

Barycentric

To find the barycentric coordinates for an arbitrary point P, find t_2 and t_3 from the point Q at the intersection of the line A_1P with the side A_2A_3, and then determine t_1 as the mass at A_1 that will balance a mass t_2+t_3 at Q, thus making P the centroid (left figure). Furthermore, the areas of the triangles DeltaA_1A_2P, DeltaA_1A_3P, and DeltaA_2A_3P are proportional to the barycentric coordinates t_3, t_2, and t_1 of P (right figure; Coxeter 1969, p. 217).

Barycentric coordinates are homogeneous, so

 (t_1,t_2,t_3)=(mut_1,mut_2,mut_3)
(1)

for mu!=0.

Barycentric coordinates normalized so that they become the actual areas of the subtriangles are called homogeneous barycentric coordinates. Barycentric coordinates normalized so that

 t_1+t_2+t_3=1,
(2)

so that the coordinates give the areas of the subtriangles normalized by the area of the original triangle are called areal coordinates (Coxeter 1969, p. 218). Barycentric and areal coordinates can provide particularly elegant proofs of geometric theorems such as Routh's theorem, Ceva's theorem, and Menelaus' theorem (Coxeter 1969, pp. 219-221).


Read full article from Barycentric Coordinates -- from Wolfram MathWorld

Labels

Popular Posts