These are vectors:

They can be multiplied using the "Dot Product" (also see Cross Product).

Calculating

You can calculate the Dot Product of two vectors this way:

a · b = |a| × |b| × cos(θ)

Where:
|a| is the magnitude (length) of vector a
|b| is the magnitude (length) of vector b
θ is the angle between a and b

So we multiply the length of a times the length of b, then multiply by the cosine of the angle between a and b

OR you can calculate it this way:

a · b = ax × bx + ay × by

So we multiply the x's, multiply the y's, then add.

Both methods work!

Example: Calculate the dot product of vectors a and b:

a · b = |a| × |b| × cos(θ)

a · b = 10 × 13 × cos(59.5°)

a · b = 10 × 13 × 0.5075...

a · b = 65.98... = 66 (rounded)

a · b = ax × bx + ay × by

a · b = -6 × 5 + 8 × 12

a · b = -30 + 96

a · b = 66

Both methods came up with the same result (after rounding)

Also note that we used minus 6 for ax (it is heading in the negative x-direction)

Note: you can use the Vector Calculator to help you.

Why cos(θ) ?

OK, to multiply two vectors it makes sense to multiply their lengths together but only when they point in the same direction.

So we make one "point in the same direction" as the other by multiplying by cos(θ):

We take the component of a
that lies alongside b

Like shining a light to see
where the shadow lies

THEN we multiply !

It works exactly the same if we "projected" b alongside a then multiplied:

Because it doesn't matter which order we do the multiplication:

|a| × |b| × cos(θ) = |a| × cos(θ) × |b|

Right Angles

When two vectors are at right angles to each other the dot product is zero.

Example: calculate the Dot Product for:

a · b = |a| × |b| × cos(θ)

a · b = | a| × | b| × cos(90°)

a · b = | a| × | b| × 0

a · b = 0

a · b = ax × bx + ay × by

a · b = -12 × 12 + 16 × 9

a · b = -144 + 144

a · b = 0

This can be a handy way to find out if two vectors are at right angles.

Three or More Dimensions

This all works fine in 3 (or more) dimensions, too.

And can actually be very useful!

Example: Sam has measured the end-points of two poles, and wants to know the angle between them:

We have 3 dimensions, so don't forget the z-components:

a · b = ax × bx + ay × by + az × bz

a · b = 9 × 4 + 2 × 8 + 7 × 10

a · b = 36 + 16 + 70

a · b = 122

Now for the other formula:

a · b = |a| × |b| × cos(θ)

But what is |a| ? It is the magnitude, or length, of the vector a. We can use Pythagoras:

  • |a| = √(42 + 82 + 102)
  • |a| = √(16 + 64 + 100)
  • |a| = √180

Likewise for |b|:

  • |b| = √(92 + 22 + 72)
  • |b| = √(81 + 4 + 49)
  • |b| = √134

And we know from the calculation above that a · b = 122, so:

a · b = |a| × |b| × cos(θ)

122 = √180 × √134 × cos(θ)

cos(θ) = 122 / (√180 × √134)

cos(θ) = 0.7855...

θ = cos -1(0.7855...) = 38.2...°

Done!

I tried a calculation like that once, but worked all in angles and distances ... it was very hard, involved lots of trigonometry, and my brain hurt. The method above is much easier.

Cross Product

The Dot Product gives a scalar (ordinary number) answer, and is sometimes called the scalar product.

But there is also the Cross Product which gives a vector as an answer, and is sometimes called the vector product.

Dot Product的更多相关文章

  1. [UCSD白板题] Minimum Dot Product

    Problem Introduction The dot product of two sequences \(a_1,a_2,\cdots,a_n\) and \(b_1,b_2,\cdots,b_ ...

  2. FB面经Prepare: Dot Product

    Conduct Dot Product of two large Vectors 1. two pointers 2. hashmap 3. 如果没有额外空间,如果一个很大,一个很小,适合scan小的 ...

  3. CUDA Samples: dot product(使用零拷贝内存)

    以下CUDA sample是分别用C++和CUDA实现的点积运算code,CUDA包括普通实现和采用零拷贝内存实现两种,并对其中使用到的CUDA函数进行了解说,code参考了<GPU高性能编程C ...

  4. 向量点积(Dot Product),向量叉积(Cross Product)

    参考的是<游戏和图形学的3D数学入门教程>,非常不错的书,推荐阅读,老外很喜欢把一个东西解释的很详细. 1.向量点积(Dot Product) 向量点积的结果有什么意义?事实上,向量的点积 ...

  5. CUDA Samples: Dot Product

    以下CUDA sample是分别用C++和CUDA实现的两个非常大的向量实现点积操作,并对其中使用到的CUDA函数进行了解说,各个文件内容如下: common.hpp: #ifndef FBC_CUD ...

  6. vector - vector product

    the inner product Givens two vectors \(x,y\in \mathbb{R}^n\), the quantity \(x^\top y\), sometimes c ...

  7. CF 405C Unusual Product(想法题)

    题目链接: 传送门 Domino Effect time limit per test:1 second     memory limit per test:256 megabytes Descrip ...

  8. Cross Product

    Cross Product These are two vectors: They can be multiplied using the "Cross Product" (als ...

  9. 对NumPy中dot()函数的理解

    今天学习到numpy基本的运算方法,遇到了一个让我比较难理解的问题.就是dot函数是如何对矩阵进行运算的. 一.dot()的使用 参考文档:https://docs.scipy.org/doc/num ...

随机推荐

  1. cookie会话技术

    会话技术 B/S请求是无状态无记忆的,脚本与脚本之间是没有联系的,导致不能进行连续的业务逻辑 Cookie技术:将会话数据保存在浏览器端 原理:服务器向浏览器发送指令,用来管理存储在浏览器端的cook ...

  2. EmbossMaskFilter BlurMaskFilter 学习

    MaskFilter类可以为Paint分配边缘效果.对MaskFilter的扩展可以对一个Paint边缘的alpha通道应用转换.Android包含了下面几种MaskFilter: BlurMaskF ...

  3. ASP.NET网站怎么发布 Web项目程序怎么发布部署(暂时收藏)

    Web程序如何发布部署呢.网站项目做好了,需要发布出来,提交给客户,装上服务器.那怎么在ASP.NET开发环境中将网站程序发布出来呢 ^_^   工具/原料 Visual Studio 2010  ( ...

  4. AnimatorController反向运动学IK

    通过使用反向运动学IK,我们可以根据需要控制角色身体某个特定部位进行旋转或移动,达到想要的一些效果,比如:在移动时,让一只脚带伤拖行:让手抬起去拿桌上的苹果:让脑袋一直面向我们的色像机,就像一直注视着 ...

  5. CSS display:inline-block的元素特点:

    将对象呈递为内联对象,但是对象的内容作为块对象呈递.旁边的内联对象会被呈递在同一行内,允许空格. 在CSS中,块级对象元素会单独占一行显示,多个block元素会各自新起一行,并且可以设置width,h ...

  6. QDataStream对QVector的序列化

    最近发现QDataStream这个好东东,序列化发送数据很方便,与大家分享一下. 客户端: line.h #ifndef LINE_H #define LINE_H #include <QStr ...

  7. php添加扩展插件

    给PHP安装扩展的方式有好多 一.重新编译 进入PHP源码目录./configure --prefix=/usr/local/php ...[其他编译参数] 二.通过phpize添加扩展 进入PHP源 ...

  8. OVERLAPPED相关的socket函数介绍

    OVERLAPPED相关的socket函数介绍 上一篇文章介绍了<Windows核心编程>OVERLAPPED结构与内核对象IOCompletionPort相关概念,见http://www ...

  9. js获取json的value

    getJson('age'); function getJson(key){ var jsonObj={"name":"cxr","age" ...

  10. oracle 字段类型详解

    CHAR 固定长度字符串 最大长度2000 bytes VARCHAR2 可变长度的字符串 最大长度4000 bytes 可做索引的最大长度749 NCHAR 根据字符集而定的固定长度字符串 最大长度 ...