理解什么是点乘Understanding the DOT product!

理解什么是点乘Understanding the DOT product!

Understanding how the dot product works and how it can help you mask out areas of your mesh.
Add me on Instagram: pclaesvfx

Dot product wikipedia: http://bit.ly/WikiDot
Dot product on Khan Academy: http://bit.ly/KhanDot

FIRST: Geometric definition of the dot product.
Finding information on wikipedia and Khan Academy.
Geometric definition of the dot product:
a · b = |a| × |b| × cos(theta)

SECOND: Range of the dot product.
Range of the dot product is -1 to 1. The dot project is the result of one vector projected onto another vector. Why do you need the dot product? There are some really useful applications for the dot product: Find out if two vectors align, are perpendicular to each other, are opposite to each other. We can cover objects with snow or find out which way is facing the sun. We can also use it for Field of View as part of crowds or a flocking system.

THIRD: Example in Houdini.
Working with normalized vectors simplifies the mathematics.
When the angle between the vectors is 0, then the dot product will be a value of 1. When the angle is 90, the dot product will be 0. When the angle is 180 degrees, then the dot product will be a value of -1.

FOURTH: Computing the angle in between – theory.
The dot product is represented with a big dot.
General equation: a · b = |a| × |b| × cos(theta)
After normalizing a and b: a · b = 1 × 1 × cos(theta)
Simplifies to: a · b = cos(theta)
To get the angle theta we can apply the arccos: arccos(a · b) = arccos(cos(theta))
This simplifies to: arccos(a · b) = theta

FIFTH: Creating the demo example.
Creating various line segments to represent the two vectors. The target vector traces a circle defined by the sin($FF*5) in the y-axis and cos($FF*5) in the z-axis. Showing how to normalize the line segment that represents the ‘target’ vector.
Next we build the ‘normal’ segment that lies on the z-axis.

SIXTH: computing the dot product.
Next we compute the dot product inside an attribute vop. We can use a ‘get attribute’ to grab the positions of the end points (that represent the normals) of both the ‘target’ segment and the ‘normal’ segment. We compute the dot product with a ‘dot product’ vop and output it into a ‘dot_result’.

SEVENTH: Computing the angle in between – implementation.
Divide the dot product by the multiplication of the length of the vectors will correctly scale the dot product before computing the angle. If one or both vectors have a value of zero, than the dot product will not be calculated correctly. The result of the division feeds into the arccos calculation which results in the angle in radians.

EIGHT: Understanding radians to degrees.
Mapping one ‘radius length’ along the circumference of the circle represents 1 radian. 180 degrees represents pie radians. 360 degrees represents 2*pie*r radians, which is also the definition of the circumference of the circle. Convert the angle theta from radians to degrees.

NINTH: Rounding the dot and angle values.
Round the dot and angle to 3 values behind the period. Reference the dot_result_rounded_string in the Font sop so we can see it in the viewport. Remaining edge segments are polywired and merged with the font sops. We also compute the projected point onto the z-axis, resample the projected line segment, delete every other line segment with a modulo operation.

TENTH: Cover rubber toy with snow.
We want to identify the surface normals that are a certain amount in alignment with the y-axis. Inside of an attribute vop we compute the dot product between the normalized surface normal N and the normalized user specified direction vector. We normalize the resulting dot product by fitting(x,-1,1,0,1). This gives us a useful gradient.

ELEVENTH: Isolate the top area of the mesh.
Inside of an attribute vop we can do a comparison between a hard threshold specified by the user and the result of the dot product calculation. This will allow us to isolate the top polygons on the mesh. Next we scatter some points on the white polygons.

TWELFTH: Converting scattered points to snow volume.
Using vdb from particles we turn the points into a sdf volume. If the pscale is too small we need to lower the voxel size to capture the small scale details. To smooth the sdf we use a ‘vdb smooth sdf’ sop. We use an attribute wrangle to specify the pscale for all points.

THIRTEENTH: Dot product restrictions and workarounds.
The dot product only does normal projection, it can not take (self-)occlusion into account. Instead we can use the ray-sop to project points on the mesh.

FOURTEENTH: Group by normal & dot against sun.
The group by normal makes use of the dot product algorithm underneath. A primitive sphere represents the position of the sun. Compute the difference vector between the surface point and the sun target point. Next compute the dot product between the surface normal and the difference vector.

For business or one-on-one visual effects consulting inquiries, you can reach me at peterclaesbusiness@gmail.com
谷歌翻译:
了解点积如何工作以及它如何帮助您屏蔽网格区域。
加我在Instagram:pclaesvfx

Dot product wikipedia: http://bit.ly/WikiDot
Dot product on Khan Academy: http://bit.ly/KhanDot

第一:点积的几何定义。
查找有关维基百科和可汗学院的信息。
点积的几何定义:
a·b = | a | ×| b | ×cos(theta)

第二:点积的范围。
点积的范围是-1到1.点项目是一个矢量投影到另一个矢量的结果。你为什么需要点积?点积有一些非常有用的应用:找出两个矢量是否对齐,彼此垂直,是否彼此相反。我们可以用雪覆盖物体或找出朝向太阳的方向。我们也可以将它用作视野,作为人群或植绒系统的一部分。

第三:Houdini的例子。
使用标准化向量简化了数学运算。
当矢量之间的角度为0时,则点积为1。当角度为90时,点积为0.当角度为180度时,点积为 – 的值为 – 1。

第四个:计算两者之间的角度 – 理论。
点积用大点表示。
一般方程:a·b = | a | ×| b | ×cos(theta)
归一化a和b后:a·b = 1×1×cos(theta)
简化为:a·b = cos(theta)
为了获得角度theta,我们可以应用arccos:arccos(a·b)= arccos(cos(theta))
这简化为:arccos(a·b)= theta

第五部分:创建演示示例。
创建各种线段以表示两个向量。目标矢量跟踪由y轴中的sin($ FF * 5)和z轴中的cos($ FF * 5)定义的圆。显示如何规范化表示“目标”向量的线段。
接下来,我们构建位于z轴上的“正常”段。

第六:计算点积。
接下来,我们计算属性vop中的点积。我们可以使用’get属性’来获取“目标”段和“正常”段的终点(代表法线)的位置。我们使用’dot product’vop计算点积并将其输出为’dot_result’。

SEVENTH:计算两者之间的角度 – 实施。
将点积乘以矢量长度的乘积将在计算角度之前正确地缩放点积。如果一个或两个向量的值为零,则不会正确计算点积。除法的结果输入到arccos计算中,这导致以弧度表示的角度。

八:将弧度理解为度数。
沿着圆的圆周映射一个“半径长度”表示1弧度。 180度表示饼弧度。 360度表示2 *饼* r弧度,这也是圆周长的定义。将角度theta从弧度转换为度数。

NINTH:舍入点和角度值。
将点和角度舍入为期间后面的3个值。引用Font sop中的dot_result_rounded_string,以便我们可以在视口中看到它。剩余的边缘段是多线连接并与字体sops合并。我们还计算z轴上的投影点,重新采样投影线段,使用模运算删除每隔一个线段。

TENTH:用雪覆盖橡胶玩具。
我们想要识别与y轴对齐的一定量的表面法线。在属性vop内部,我们计算归一化表面法线N和规范化用户指定方向向量之间的点积。我们通过拟合(x,-1,1,0,1)对得到的点积进行归一化。这给了我们一个有用的梯度。

ELEVENTH:隔离网格的顶部区域。
在属性vop内部,我们可以比较用户指定的硬阈值和点积计算的结果。这将允许我们隔离网格上的顶部多边形。接下来,我们在白色多边形上散布一些点。

TWELFTH:将散乱点转换为雪量。
使用粒子中的vdb,我们将点转换为sdf卷。如果pscale太小,我们需要降低体素大小以捕获小规模细节。为了平滑sdf,我们使用’vdb smooth sdf’sop。我们使用属性争论来指定所有点的pscale。

第十三:Dot产品限制和解决方法。
点积只做正常投影,不考虑(自)遮挡。相反,我们可以使用ray-sop来投影网格上的点。

第十四:按正常分组并点击太阳。
正常组使用下面的点积算法。原始球体代表太阳的位置。计算表面点和太阳目标点之间的差异向量。接下来计算表面法线和差矢量之间的点积。

For business or one-on-one visual effects consulting inquiries, you can reach me at peterclaesbusiness@gmail.com