当前位置:网站首页>3D math - vector
3D math - vector
2022-07-23 15:43:00 【Just be interesting】
vector
Vector In physics, it is called vector , In mathematics, it is called vector .
Definition of vector : Is an existing size And then there is Direction The amount of .
There are two ways to express , Just choose one , as follows
Row vector : [ a 1 a 2 a 3 ] Column vector : [ a 1 a 2 a 3 ] (1) Row vector :\left[ \begin{matrix} a_1 & a_2 & a_3 \end{matrix} \right]\tag{1}\\ Column vector :\left[ \begin{matrix} a_1\\ a_2\\ a_3 \end{matrix} \right] Row vector :[a1a2a3] Column vector :⎣⎡a1a2a3⎦⎤(1)
stay Unity The middle vector is Position( Location ), It can be either a point , Used to indicate position , It can also be a vector pointing to a certain position from the origin .
Tips : Mathematically, point and vector are equivalent
Zero vector
0 ⃗ = [ 0 0 ⋯ 0 ] \vec{0} =\left[ \begin{matrix} 0 &0 & \cdots & 0 \end{matrix} \right] 0=[00⋯0]
The zero vector is the only vector that has no direction , And the size is 0.
Negative vector
− v ⃗ = − [ a 1 a 2 ⋯ a n ] = [ − a 1 − a 2 ⋯ − a n ] -\vec{v} = -\left[ \begin{matrix} a_1 & a_2 & \cdots & a_n \end{matrix} \right] = \left[ \begin{matrix} -a_1 & -a_2 & \cdots & -a_n \end{matrix} \right] −v=−[a1a2⋯an]=[−a1−a2⋯−an]
Negative vectors are generated by equal but In the opposite direction Vector of
Scalar And vector Of Relationship
Scalar is a number , They cannot be added directly to vectors , But it can be multiplied by a vector .(k For the scalar )
k v ⃗ = k [ a 1 a 2 ⋯ a n ] = [ k a 1 k a 2 ⋯ k a n ] k\vec{v}= k \left[ \begin{matrix} a_1 & a_2 & \cdots & a_n \end{matrix} \right] = \left[ \begin{matrix} ka_1 & ka_2 & \cdots & ka_n \end{matrix} \right] kv=k[a1a2⋯an]=[ka1ka2⋯kan]
The result of multiplication is still a vector
- k > 0 when , Direction unchanged , The size changes to the original |k| times
- k = 0 when , Become a zero vector
- k < 0 when , In the opposite direction , The size changes to the original |k| times
Conclusion :k > 0 Direction unchanged ,k < 0 In the opposite direction . The size is the original |k| times .
In actual development , We often Use scalar and unit vector multiplication , To obtain the vector of the corresponding size in a certain direction
Scalar division is similar to multiplication , I won't repeat
Vector size
The size of the vector is also called the length of the vector , That is, calculate the distance from the origin of the vector to the target position .
∥ v ⃗ ∥ = ∑ i = 1 n a i 2 = a 1 2 + a 2 2 + ⋯ + a n 2 \begin{Vmatrix}\vec{v}\end{Vmatrix} = \sqrt{\sum_{i = 1}^na_i^2} = \sqrt{a_1^2 + a_2^2 + \cdots + a_n^2} ∥∥v∥∥=i=1∑nai2=a12+a22+⋯+an2
Unit vector
The unit vector is of size 1 Vector of ,** They do not represent the size of the vector , It only represents the direction of the vector .** Also known as normalized vector .
v ^ = v ⃗ ∥ v ⃗ ∥ \widehat{v} = \frac{\vec{v}}{ \begin{Vmatrix} \vec{v} \end{Vmatrix} } v=∥∥v∥∥v
Vector addition and Subtraction
Vectors can be added and subtracted .
Add :
a ⃗ + b ⃗ = [ a 1 + b 1 a 2 + b 2 ⋯ a n + b n ] \vec{a} + \vec{b} =\left[ \begin{matrix} a_1 + b_1 \\ a_2 + b_2 \\ \cdots \\ a_n + b_n \end{matrix} \right] a+b=⎣⎡a1+b1a2+b2⋯an+bn⎦⎤
The addition of vectors satisfies the commutative law . And the geometric meaning of vector addition is very important . They are not just the addition of values . what's more , Get a vector a With vector b The direction of extends the vector b Vector of magnitude . And the vector addition satisfies the triangle rule .
Addition is very common , They are often used to move vectors ( Such as how much distance to go in a certain direction )
Subtraction :
a ⃗ − b ⃗ = [ a 1 − b 1 a 2 − b 2 ⋯ a n − b n ] \vec{a} - \vec{b} = \left[ \begin{matrix} a_1 - b_1\\ a_2 - b_2\\ \cdots \\ a_n - b_n \end{matrix} \right] a−b=⎣⎡a1−b1a2−b2⋯an−bn⎦⎤
Vector subtraction does not satisfy commutative law , in other words a - b and b - a The geometric meaning is different .
a - b The geometric meaning of is to get a b Point to a Vector of , And the vector size is a And b Distance of , The vector direction is b Point to a The direction of
contrary ,b - a The geometric meaning of is to get a a Point to b Vector of , And the vector size is a And b Distance of , The vector direction is a Point to b The direction of .
Subtraction is often used to find the distance between two positions , Or get the relative direction of two positions .
Vector Dot product and Cross product
There are two kinds of multiplication between vectors , One is Dot product , One is Cross product . The most important difference between them is , The value of dot product is scalar , The value of the cross product is a vector .
Dot product :
a ⃗ ⋅ b ⃗ = ∑ i = 1 n a i b i = a 1 b 1 + a 2 b 2 + ⋯ + a n b n = ∥ a ⃗ ∥ ∥ b ⃗ ∥ cos θ θ For the angle between them \vec{a} \cdot \vec{b} = \sum_{i=1}^{n}a_ib_i = a_1b_1 + a_2b_2+\cdots+a_nb_n = \begin{Vmatrix} \vec{a} \end{Vmatrix} \begin{Vmatrix} \vec{b} \end{Vmatrix} \cos{\theta}\\ \theta For the angle between them a⋅b=i=1∑naibi=a1b1+a2b2+⋯+anbn=∥∥a∥∥∥∥b∥∥cosθθ For the angle between them
The geometric meaning of dot product is very important , We will focus on
First of all Projection , As the most important characteristic of dot product , Through dot product, the projection size of one vector relative to another vector can be easily calculated . a ⃗ ⋅ b ^ \vec{a} \cdot \widehat{b} a⋅b be relative to a ⃗ \vec{a} a stay b ⃗ \vec{b} b The size of the projection on .
a ⃗ ⋅ b ^ = ∥ a ⃗ ∥ cos θ \vec{a} \cdot \widehat{b} = \begin{Vmatrix} \vec{a} \end{Vmatrix} \cos{\theta} a⋅b=∥∥a∥∥cosθ
The projection gets scalar , That is, the size of the projection , If you want to get the vector of projection , You can multiply by the unit vector . as follows
k = a ⃗ ⋅ b ^ = ∥ a ⃗ ∥ cos θ v ⃗ = k b ^ k = \vec{a} \cdot \widehat{b} = \begin{Vmatrix} \vec{a} \end{Vmatrix} \cos{\theta}\\ \vec{v}=k\widehat{b} k=a⋅b=∥∥a∥∥cosθv=kb
What we get above is the vector a be relative to vector b Upper Horizontal vector . We can also find vectors a Relative to vector b Of Vertical vector
a ⃗ = a ∥ + a ⊥ (1) \vec{a} = a_\parallel + a_\perp\tag{1} \\ a=a∥+a⊥(1)
a ∥ = ( a ⃗ ⋅ b ^ ) b ^ (2) a_\parallel = (\vec{a} \cdot \widehat{b})\widehat{b}\tag{2} a∥=(a⋅b)b(2)
a ⊥ = a ⃗ − a ∥ = a ⃗ − ( a ⃗ ⋅ b ^ ) b ^ (3) \begin{aligned} a_\perp &= \vec{a} - a_\parallel\\ &=\vec{a} - (\vec{a} \cdot \widehat{b})\widehat{b} \end{aligned}\tag{3} a⊥=a−a∥=a−(a⋅b)b(3)
This formula for horizontal and vertical projection is very useful .
Secondly, the dot product can also roughly judge the angle
- a ⃗ ⋅ b ⃗ \vec{a} \cdot \vec{b} a⋅b > 0 It's an acute angle
- a ⃗ ⋅ b ⃗ \vec{a} \cdot \vec{b} a⋅b = 0 Is a right angle
- a ⃗ ⋅ b ⃗ \vec{a} \cdot \vec{b} a⋅b < 0 It's an obtuse angle
Another very important feature is that you can find the angle between two vectors
θ = arccos a ⃗ ⋅ b ⃗ ∥ a ⃗ ∥ ∥ b ⃗ ∥ \theta = \arccos{\frac{\vec{a} \cdot \vec{b}}{\begin{Vmatrix} \vec{a} \end{Vmatrix}\begin{Vmatrix} \vec{b} \end{Vmatrix}}} θ=arccos∥∥a∥∥∥∥b∥∥a⋅b
It can be simplified into
θ = arccos ( a ^ ⋅ b ^ ) \theta = \arccos{(\widehat{a} \cdot \widehat{b})} θ=arccos(a⋅b)
Cross product ( The three dimensional ):
a ⃗ × b ⃗ = [ i x 1 x 2 j y 1 y 2 k z 1 z 2 ] = [ ( y 1 z 2 − y 2 z 1 ) i ( z 1 x 2 − z 2 x 1 ) j ( x 1 y 2 − x 2 y 1 ) k ] = [ y 1 z 2 − y 2 z 1 z 1 x 2 − z 2 x 1 x 1 y 2 − x 2 y 1 ] \vec{a} \times \vec{b} = \left[ \begin{matrix} i & x_1 & x_2\\ j & y_1 & y_2\\ k & z_1 & z_2 \end{matrix} \right] = \left[ \begin{matrix} (y_1z_2-y_2z_1)i\\ (z_1x_2 -z_2x_1)j\\ (x_1y_2-x_2y_1)k \end{matrix} \right] = \left[ \begin{matrix} y_1z_2-y_2z_1\\ z_1x_2 -z_2x_1\\ x_1y_2-x_2y_1 \end{matrix} \right] a×b=⎣⎡ijkx1y1z1x2y2z2⎦⎤=⎣⎡(y1z2−y2z1)i(z1x2−z2x1)j(x1y2−x2y1)k⎦⎤=⎣⎡y1z2−y2z1z1x2−z2x1x1y2−x2y1⎦⎤
i = [ 1 0 0 ] j = [ 0 1 0 ] k = [ 0 0 1 ] i = \left[ \begin{matrix} 1 & 0 & 0 \end{matrix} \right]\; j = \left[ \begin{matrix} 0 & 1 & 0 \end{matrix} \right]\; k = \left[ \begin{matrix} 0 & 0 & 1 \end{matrix} \right] i=[100]j=[010]k=[001]
The result of cross product is vector , The obtained vector is ** The normal vector of the plane composed of two vectors .** This is also the most important use of cross product , Get the normal vector of the plane composed of two vectors .
Other formulas of cross product
∥ a ⃗ × b ⃗ ∥ = ∥ a ⃗ ∥ ∥ b ⃗ ∥ sin θ \begin{Vmatrix} \vec{a} \times \vec{b} \end{Vmatrix} = \begin{Vmatrix} \vec{a} \end{Vmatrix} \begin{Vmatrix} \vec{b} \end{Vmatrix} \sin{\theta} ∥∥a×b∥∥=∥∥a∥∥∥∥b∥∥sinθ
This formula calculates the area of a quadrilateral composed of two vectors . But it's less used .
The cross product can use the right-hand rule to determine the direction of the normal vector .
Empathy , You can judge whether the two vectors are clockwise by the normal vector , Or counter clockwise
边栏推荐
- 奔驰新能源产品线:豪华新能源市场或将改变格局
- 老照片上色——DeOldify快速上手
- STL map操作
- [pyGame practice] playing poker? Win or lose? This card game makes me forget to eat and sleep.
- Camera flashlight modification
- SCA在得物DevSecOps平台上应用
- Dynamic planning - force buckle
- C语言经典例题-逆序打印输入的两位数
- Solve the problem that kotlin writes the Android project compilation report execution failed for task ': app:kaptdebugkotlin'. Exception
- Les raccourcis clavier liés à l'onglet ne peuvent pas être utilisés après la mise à jour du vscode
猜你喜欢
随机推荐
Can multithreading optimize program performance?
airserver在哪里下载?使用方法教程
[CTFHub]JWT 的头部和有效载荷这两部分的数据是以明文形式传输的,如果其中包含了敏感信息的话,就会发生敏感信息泄露。试着找出FLAG。格式为 flag{}
Safe and reasonable use of electricity to harvest a cool "summer"
xxl-job 实现email发送警告的代码解析(一行一行代码解读)
记一次SQL优化
【Pygame实战】打扑克牌嘛?赢了输了?这款打牌游戏,竟让我废寝忘食。
复现各种对抗攻击方法
Part II how to design an RBAC authority system
可穿戴设备的自电容触摸控制器IT7259Q-13,IT7259EX-24
VSCode 更新後與tab相關快捷鍵無法使用
Dynamic planning - force buckle
Safe operation 7.22
C语言经典例题-求最少数量钞票
Opnsense - multifunctional, highly reliable and easy-to-use firewall (II)
Idea five free plug-ins to improve efficiency
[hiflow] regularly send Tencent cloud SMS sending group
IDEA 提高效率的5大免费插件
bgp选路原则
The exclamation point of vscode +tab shortcut key cannot be used, and the solution to the problem of a-soul-live2d plug-in









