Understanding the DOT product!

  Рет қаралды 9,645

Peter Claes

4 жыл бұрын

Understanding how the dot product works and how it can help you mask out areas of your mesh.
Add me on Instagram: pclaesvfx
Hipfile: bit.ly/dot_product_hipfile
Dot product wikipedia: bit.ly/WikiDot
Dot product on Khan Academy: bit.ly/KhanDot
FIRST: Geometric definition of the dot product.
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

Пікірлер: 37
@evening8990
@evening8990 3 жыл бұрын
Peter, that is brilliantly done, I'm sure you are busy but hope to see some more tutorials from you again some day, many thanks!
@WaseemFitness
@WaseemFitness 4 жыл бұрын
Thank you Peter ..very clear , super straight
@peterclaes5918
@peterclaes5918 4 жыл бұрын
Thanks Wasseem!
@MDA_01
@MDA_01 4 жыл бұрын
Thanks Peter - an excellent tutorial and very helpful! (I'm also following your 'Houdini Bridge' example from way back - still valuable in 2020!)
@laofang
@laofang 4 жыл бұрын
Master!!!
@p2s212
@p2s212 3 жыл бұрын
You have a special ability to explain. I totally understand even I am Korean. Thank you bro!!!
@Dome794
@Dome794 2 жыл бұрын
well explained, fantastic quality. Thank you
@thehatchery4253
@thehatchery4253 4 жыл бұрын
Fantastic explication, really helped me understand how to use this as part of my vex setups
@carlosrivadulla8903
@carlosrivadulla8903 4 жыл бұрын
A really good place to be subscribed. Nice voice and rhythm, friendly explanations, quality content with several examples from scratch and all from a kind, talented and didactic person.
@peterclaes5918
@peterclaes5918 4 жыл бұрын
Glad you are enjoying the content and thank you for the kind words.
@lveronese
@lveronese 4 жыл бұрын
some of the best tutorials out there.. keep them coming..
@peterclaes5918
@peterclaes5918 4 жыл бұрын
Thanks Luca! The next one will probably cover the cross product as that one I tend to use even more.
@lveronese
@lveronese 4 жыл бұрын
@@peterclaes5918 great.. thank you for taking the time..
@dzedrit
@dzedrit 4 жыл бұрын
Awesome Tutorial!
@simonbrun1832
@simonbrun1832 4 жыл бұрын
High quality tutorials, full support ! Thanks
@peterclaes5918
@peterclaes5918 4 жыл бұрын
Thanks Simon!
@samkaz5810
@samkaz5810 4 жыл бұрын
awesome tutorial bro...
@LostArkLover
@LostArkLover 4 жыл бұрын
Wow amazing explanation, Completely forgot Trig but your tutes just triggered me to do trigs now. Thank you!
@peterclaes5918
@peterclaes5918 4 жыл бұрын
A little bit of sin and cos can go a long way!
@jimmyliu7738
@jimmyliu7738 4 жыл бұрын
good job, Peter! thanks for sharing!
@peterclaes5918
@peterclaes5918 4 жыл бұрын
Glad you liked it Ziming!
@ojisan4220
@ojisan4220 2 жыл бұрын
Thank you for the work you did! Hope you will return one day. It might be with some practical applications, let's say these linear algebra concepts to Hou particles or whatever you prefer
@TheChannel1978
@TheChannel1978 Жыл бұрын
I'm a rigger and haven't had to use dot except in very specific cases like building vector-based drivers. For most rigging tasks I found one doesn't need to go so low-level. Maybe it's more for shader writers?
@vrbalex
@vrbalex 4 жыл бұрын
Very useful and easy to understand! Waiting for the next video :) Thanks!
@peterclaes5918
@peterclaes5918 4 жыл бұрын
Aiming to do one on the cross product next!
@vrbalex
@vrbalex 4 жыл бұрын
@@peterclaes5918 Awesome! We share links to your videos in our small telegram community, people like it! If you want, you can join t.me/sidefx_edu We collect all interesting staff about houdini in this channel.
@artfive
@artfive 4 жыл бұрын
That's great Peter, very useful !
@peterclaes5918
@peterclaes5918 4 жыл бұрын
Thanks Raimondo, I plan to create these fundamental tool videos first so I can refer to them in later more advanced tutorials. Cross product will be next :).
@rale1895
@rale1895 4 жыл бұрын
*would like to take a look at your workspace and workstation.
@carolinamondragon9831
@carolinamondragon9831 3 жыл бұрын
Thank you so much for the tutorial Peter! I was wondering if there is a way to influence pscale with the dot product so it doesnt just influence a few points but also their size? Thank you :)
@peterclaes5918
@peterclaes5918 3 жыл бұрын
Hmm, not sure I fully understand the question. Do you want to use the dot product value to influence the size of the points? That could be achieved by remapping the dot product value between a certain min and max amount and then into pscale. Then after that you can use a point relax node that makes use of the pscale to nudge the points away from each other (use the second input of the point relax to stick them to a surface). If you have a pointcloud with points of varying pscale and you want that pscale to influence how the dot product is computed, there is no direct way to compute that as far as I know. The way I would probably try that is by creating a unique name attribute for each point, the copying some poly spheres onto the points (making sure the name attribute gets copied along). Then calculate the dot product on the resulting copied spheres that have the varying sizes. Then you need to attributepromote the dot product value to the ‘piece’ level. This is where that name attribute comes in. Basically each point from the original pointcloud is represented by a sphere and each sphere now has a bunch of points with a dot product value. So now we have to get that dot product value back onto the pointcloud. First we attributepromote the dot product from the points onto the ‘piece’ level (on the attributepromote turn on the ‘piece attribute’ as name. You could use average, max or sum. Then use an attribute copy to copy the resulting ‘sum’ onto the original pointcloud. The key here is to turn on ‘match by attribute’ on the attributecopy. That way the point knows which sphere it should use to lookup the dot product sum attribute. So yeah, that is a bit harder, but also doable. Hope it makes sense. When I am allowed to make videos again I can perhaps make this in video form.
@evening8990
@evening8990 3 жыл бұрын
@@peterclaes5918 would love to see an example of this
@BlueZiFX
@BlueZiFX 2 жыл бұрын
Really helpful video :D But I dont understand the part at 28:32, why you have to normalize the vector 2 which already has the value between 0 - 1, can you explain for me? Many thanks!
@MatheooPL
@MatheooPL Жыл бұрын
When you normalize vector its lenght is always 1
@Bleepurchin
@Bleepurchin 4 жыл бұрын
New Houdini user here. As much as it is clear you understand what you're talk about, you're mathmatical approach to showcasing Houdini in this way is the reason many 3D designers/animatrs are put off using the Software... I wonder if there is a way of understanding the dot product without turning it into a maths lesson... maybe focussing on the things it can do maybe?? #Cinema4Dforever
@peterclaes5918
@peterclaes5918 4 жыл бұрын
I hear you, it can be a bit intense when you first start. This was a long video and in future videos I am trying to split up the theory from the examples a bit more. At the same time I am currently building a library of foundational knowledge so that I can refer back to in the future when I am building bigger setups.
@UmarFarooqChaudhrY
@UmarFarooqChaudhrY 4 жыл бұрын
4:10