点积、夹角与投影Dot Products, Angles & Projections
一个向量在另一个方向上究竟贡献了多少?How much of one vector points along another direction?
前置知识:Prerequisites: B03:向量、坐标与距离。B03: vectors, coordinates and distance.
复习前置:Review prerequisites: B03 · 向量、坐标与距离Vectors, Coordinates & Distance
学完后你能:After this lesson you can: 计算点积,判断方向关系,并在非零方向上求投影。Calculate dot products, identify direction relationships, and project onto a nonzero direction.
动手观察Explore
拖动箭头或调节分量,观察投影和点积。把 b 变成零向量,查看不可定义状态。Drag an arrow or adjust its components. Watch the projection and dot product. Set b to zero to see the undefined state.
从观察到解释From observation to explanation
从分量计算Calculate from components
a = (2, 1)、b = (1, 0) 时,a·b = 2×1 + 1×0 = 2。点积同时受到方向和长度影响,所以不能只凭点积比较方向相似度。For a = (2, 1) and b = (1, 0), a·b = 2×1 + 1×0 = 2. The dot product depends on both direction and length, so it alone does not measure directional similarity.
看方向与影子Observe direction and shadow
非零向量点积为正、零、负,分别对应锐角、直角、钝角。投影是沿 b 的直线落下的垂足:例子中 a 投影为 (2, 0),剩余误差 (0, 1) 与 b 垂直。For nonzero vectors, positive, zero and negative dot products correspond to acute, right and obtuse angles. The projection is the perpendicular foot on the line along b: in the example it is (2, 0), leaving error (0, 1) perpendicular to b.
长度和相似度Length and similarity
把两个非零向量都除以各自长度后,点积就是余弦相似度。两个同向箭头即使长度不同,余弦相似度也是 1。After dividing each nonzero vector by its length, their dot product is cosine similarity. Two arrows in the same direction have cosine similarity 1 even if their lengths differ.
公式与符号Formula and symbols
a、b 是向量;· 表示点积;proj_b a 是 a 在非零方向 b 所在直线上的投影。θ 是两非零向量的夹角,cos θ = (a·b)/(|a||b|)。a and b are vectors; · denotes the dot product; proj_b a is the projection of a onto the line through nonzero b. θ is the angle between two nonzero vectors and cos θ = (a·b)/(|a||b|).
留意这个区别Watch for this
零向量没有方向或夹角,不能作为投影方向;当点积为负,投影可能落在 b 箭头的反方向。The zero vector has no direction or angle and cannot be a projection direction. A negative dot product can put the projection opposite to b’s arrow.
继续探索Explore further
课后练习
检验你的理解