Unity 3D Mathematics \ Graphics Basics - Game Development (Vector)

Geometric meaning of vector operations

Scalar and Vector Calculations

● Geometric explanation: the effect of multiplying a vector by a scalar is to scale the length of the vector by the size of the scalar, and the negative value is opposite.
insert image description here

the modulus length of the vector

The length of the vector. The result is a scalar.
insert image description here

insert image description here

Normalize vector normalize

Normalizes an ordinary vector.
A normalized vector only represents the direction of the vector, excluding the magnitude of the vector. (such as normals)

calculate:
insert image description here

normalized vector = vector / modulus length

And there is: a // b (parallel), then a / ||a|| = b / ||b||, a, b !=0

0 vector

Each component is a vector of 0,
which means a vector with no direction and a size of 0.

Addition and subtraction of vectors and vectors

(a, b) + (c, d) = (a + c, b + d)
insert image description here

Distance formula between two points (distance between vectors)

insert image description here

If: b - a = c
||b - a|| = || c ||
that is: the distance from b to a is equal to the modulus length of c.

dot product, dot product, inner product (dot)

The result of the dot product is a scalar.
(a1, a2) * (b1, b2) = (a1 * b1 + a2 * b2)
is satisfied: commutative law a * b = b * a
does not satisfy: a * b * c != a * c * b,
similar : U * V * U != U * U * V = U^2 * V
It can be found that the result of two-vector dot is a scalar, and the result of three-vector dot is a vector...

Vector Angle and Dot Product

The result of the dot product describes the similarity (direction proximity) of the two vectors. The smaller the angle between the dot product, the closer the two vectors are.
a * b = ||a|| * ||b|| * cosX, X is the vector angle
insert image description here

The angle between the available vectors is: cosX = (a * b) / (||a|| * ||b||),
that is: cosX = norma(a) * norma(b), and norma(a) represents a normalized vector

Application:
Lambert lighting model, calculate the surface brightness of the object through the angle between the reverse direction of the light and the normal direction of the model. The resulting value represents the angle at which the model meets the light

Projection and dot product

The projection vector V// of vector V on any vector n:
as long as it is not a 0 vector, it can be projected. The projection does not care about the size of n (whether it is a unit vector or not, only the direction).
It can be understood as the projection of V in the direction of the vector n.

insert image description here

The derivation process:
insert image description here

Cross product (outer product) of vectors

A vector cross product is where the components are crossed and then multiplied. Only for vectors in 3D space.
Operation:
insert image description here

Geometric meaning:

  1. The vector obtained by the cross product is perpendicular to the original two vectors. The vertical direction satisfies the right-hand rule.
  2. The outer product can represent the area of ​​a parallelogram whose sides are a and b.

a × b = ||a||*||b|| * The sinX
direction is based on the right-hand rule:
if the coordinate system satisfies the right-hand rule, when the four fingers of the right hand turn from a to b at an angle not exceeding 180 degrees , the thumbs up pointing in the direction of c.

Operation rules:
● Satisfy the distributive law of addition
ax (b + c) = axb + axc
● Not satisfy the commutative law, the anti-commutative law
axb = - (bxa)
● Satisfy the Jacobian identity
ax (bxc) + bx (cxa) + cx (axb) = 0

reference:
insert image description here

Double Vector Cross Product Simplification Formula

The cross product of 3 vectors is simplified as follows:
(axb) xc = b * (a * c) - a * (b * c)
ax (bxc) = b * (a * c) - c * (a * b)

Proof reference:
insert image description here

two vector angle bisect vector

insert image description here

Guess you like

Origin blog.csdn.net/qq_41709801/article/details/127327111