The Dot Product - A Visual Explanation

  Рет қаралды 91,603

Freya Holmér

Freya Holmér

4 жыл бұрын

🔽 Click
Clipped from the super long shaders for beginners stream of two days ago!
Note that this is for two normalized vectors, it's a bit different if only one or none of them are normalized. Regardless - the case of two normalized vectors is very common in shaders!
For example, Lambert shading is the dot product of the light direction and the surface normal
Full video will be up soon!
📺 Twitch ❱ / acegikmo
🐦 Twitter ❱ / freyaholmer
💬 Discord ❱ / discord
🌸 Instagram ❱ / freya_holmer

Пікірлер: 129
@xniyana9956
@xniyana9956 2 ай бұрын
This video is literally that meme where "the random youtuber with a small channel has the exact answer to your problem"....Even the bigger channels didn't explain the concept behind dot products so simply. Love this!
@AshKetchum2011
@AshKetchum2011 Ай бұрын
wtf who hasnt explained dot products is the question... and its not even a good explaination... The forgot to mention many but its ok for people who dont need to understand what the dot product really is.. In fact its the worst explaination but ok for casuals..
@overnights2572
@overnights2572 12 күн бұрын
@@AshKetchum2011 Take it easy man, many videos explain the "math" behind dot product, but she explains the highest level of understanding of what the dot product represents, this is the way how AI verifies if ideas are similar or not (yes, ideas are transformed in vectors/arrays inside Artificial Intelligence). Thanks a lot Freya @acegikmo ! Awesome and straight to the point explanation!
@mittensandsnowdrop
@mittensandsnowdrop 3 жыл бұрын
You wouldn't believe how helpful your videos have been for me. Studying games programming and I have a maths module. Your videos have totally saved my life! Thank you so much.
@remon563
@remon563 2 жыл бұрын
this is so cool and useful Freya! I have been working with shaders for a long time but the bigger my mental library gets the more I need to study in order to keep my knowledge. Videos like these are super helpful for this.
@luisdfernandez2601
@luisdfernandez2601 4 жыл бұрын
In just over a minute you explained to where it finally made sense. Nice!!
@arcadiaplanatia8009
@arcadiaplanatia8009 2 жыл бұрын
This is actually such a good video. I've been struggling so long to understand this thank you so much!!
@loot6
@loot6 3 жыл бұрын
Far and away the best explanation I've come across. People normally try to make it sound complex but it's not.
@Zamaroht
@Zamaroht 10 ай бұрын
Wow this explanation is crazy intuitive, thank you so much
@hypersapien
@hypersapien 2 ай бұрын
Great video! I appreciate how concise this was!
@yurkkon6010
@yurkkon6010 11 ай бұрын
made my day. happy to find your channel
@MartynDerg
@MartynDerg 8 ай бұрын
brilliant explanation, thank you so much for the simple illustration
@whiteravenshow4342
@whiteravenshow4342 3 жыл бұрын
Visual explanations are very cool and useful, thank you)
@bigevilcorporation7050
@bigevilcorporation7050 4 жыл бұрын
"Ugh this is doing my head in, I hope there's some Freya-like explanation on YouTu--" AND THERE IT IS
@rustemagayev8256
@rustemagayev8256 2 жыл бұрын
As someone with chronic migraine, which makes thinking about and understanding complicated concept really hard, your explanations are a blessing.
@SugarTouch
@SugarTouch 2 жыл бұрын
Clear and sharp ! Thank you !
@lemetamax
@lemetamax 5 ай бұрын
This actually makes perfect sense! Now i perfectly understand how dot products work in my code
@chinedusamuel7950
@chinedusamuel7950 4 жыл бұрын
Awesome explanations, made so simple. Thank u
@levioptionallastname6749
@levioptionallastname6749 2 ай бұрын
just solved my problems in about 45 seconds thank you!
@garethgriffiths7084
@garethgriffiths7084 4 жыл бұрын
Thank you for sharing your explanation the of the Dot Product. Helped a lot =D
@dartneer
@dartneer 3 ай бұрын
Damn, i have seen hours long videos on dot product! When you know, you know! Thanks Freya..
@kimm9086
@kimm9086 Жыл бұрын
ur vibe is so cool
@aleksandarv.1459
@aleksandarv.1459 Ай бұрын
Keep up the good work!
@MaximumAxiom
@MaximumAxiom 11 ай бұрын
Such a good explanation
@Mogo-jan
@Mogo-jan 4 жыл бұрын
Ty so much for the visualization, i was having a hard time understanding from everyone's explainations
@_brin189
@_brin189 2 жыл бұрын
literal math mommy. thank you
@jasoniswrongabouteverythin8230
@jasoniswrongabouteverythin8230 6 ай бұрын
man, whenever im trying to understand some game dev math stuff i really should come to this channel first
@tempestandacomputer6951
@tempestandacomputer6951 Жыл бұрын
Am a senior engineering student and never quite thought about it this way. Props!
@official_noself
@official_noself 3 жыл бұрын
is it basically cosine of the angle in between two vectors
@charlieliu3857
@charlieliu3857 3 ай бұрын
Thank you for your video!!
@sinonimos1790
@sinonimos1790 2 жыл бұрын
Muchas gracias. Gran Explicacion
@randomaccount6146
@randomaccount6146 2 жыл бұрын
Finally someone explaining what the dot product even is instead of just jumping into how it is calculated.
@izvarzone
@izvarzone 3 жыл бұрын
most important, not forget normalize both vectors before sending them to dot product, just in case. I had bad results when not normalized, scratched my head before realize why that happened.
@Mj-multimediaNet
@Mj-multimediaNet Жыл бұрын
only one must be normalized
@sterling709
@sterling709 Жыл бұрын
what i understand is that, when we want to compare the angle diferences we normalise both the vector, and if we wanted to compare the magnitude or the length or distance, then dont need to normalise it, mean one is the compare angle the other is to compare distance or range
@forbidden-cyrillic-handle
@forbidden-cyrillic-handle 11 ай бұрын
​@@Mj-multimediaNet Depends what you want to do. Sometimes you want then not normalized. Sometimes you want only one of them normalized. And sometimes yoy want them both normalized. In this specific case you want to find cosine of an angle. So both of them should be normalized.
@MathCuriousity
@MathCuriousity 7 ай бұрын
What does “normalize” mean? Was she showing “normalized”?
@MathCuriousity
@MathCuriousity 7 ай бұрын
What does normalize mean
@hk_labs
@hk_labs 25 күн бұрын
Thank you so much!
@dmitriyborisov_hitsen
@dmitriyborisov_hitsen Ай бұрын
Amazing!
@ninthjake
@ninthjake 4 жыл бұрын
Really good explanation. Even a simpleton like myself understood it :)
@juxtapos1034
@juxtapos1034 8 ай бұрын
some who says simpleton is not simple
@RobertBerrier
@RobertBerrier 7 ай бұрын
you are a live saver!
@Ofenkatze
@Ofenkatze 10 ай бұрын
I wish I could tick a "love" emoji instead of just like. Most concise explanation I've found so far.
@poki95
@poki95 Жыл бұрын
Very helpful video!
@jackleu8996
@jackleu8996 2 жыл бұрын
The explanation has to be qualified as it is correct iff the first vector is a unit vector. Or, the dot product would be the projected distance x the length of first vector. Actually, it would be nice to start with a unit vector, then generalize into non-unit vectors. Overall, this is a concise explanation.
@MathCuriousity
@MathCuriousity 7 ай бұрын
can you explain why its only right for a "unit vector" ? Just starting to understand vectors myself.
@redact7395
@redact7395 7 ай бұрын
​@@MathCuriousity its because the dot product of two vectors is the length of the projected vector multiplied by the length of the vector it was projected onto, the video "Dot products and duality" by 3blue1brown explains this in a lot more detail
@MathCuriousity
@MathCuriousity 7 ай бұрын
@@redact7395 hmm ok and why did another person say it was only ok for normed?
@redact7395
@redact7395 7 ай бұрын
​@@MathCuriousity this video applies as long as the vector you are projecting onto has a length of 1 and unit vector and a normalized vector just mean that the vector has length 1
@GokdenizCetin
@GokdenizCetin Жыл бұрын
Thank you!
@thegreendude2086
@thegreendude2086 Жыл бұрын
Very helpful, thanks a lot
@aussieraver7182
@aussieraver7182 2 ай бұрын
NICE! Im going to use this to confirm if my bots are facing their target's before they can attack within a FoV!
@brouxelian2744
@brouxelian2744 3 жыл бұрын
short and usefull thank you !
@b-bug923
@b-bug923 9 ай бұрын
Thanks a lot🎉
@harrynnebank8321
@harrynnebank8321 4 жыл бұрын
if I've more teachers like you in college
@supertenchoo4271
@supertenchoo4271 2 жыл бұрын
Best Teach for Game math
@adeyemiadeyanju2247
@adeyemiadeyanju2247 Жыл бұрын
I'm sorry if this come off as a dumb question, i'm not really good with math, For this to work rightly the 2 vectors must stem from the same origin right ?
@acegikmo
@acegikmo Жыл бұрын
yes! but also, vectors technically don't "have an origin", they're always only the tip, in terms of the data stored
@MathCuriousity
@MathCuriousity 7 ай бұрын
@Freya what does "normalized" vector mean that she talks about in her description!?
@edcify8241
@edcify8241 4 ай бұрын
A normalized vector has a unit "length", i. e. it's a vector divided by its norm equal to itself.
@MathCuriousity
@MathCuriousity 4 ай бұрын
@@edcify8241what would that be as an equation?
@edcify8241
@edcify8241 4 ай бұрын
@@MathCuriousity The normalization of a vector α is α'=α/||α|| (scalar multiplication by the reciprocal of its norm), and a vector is normalized iff α'=α.
@novictim
@novictim 2 жыл бұрын
Woah! Very useful
@skelhain
@skelhain Жыл бұрын
In a 3D scene, when i.e. calculating if an enemy is in front of the player, can we use the dot product to also check the vertical angle? Or is the dot product rather a flat circle instead of a sphere?
@acegikmo
@acegikmo Жыл бұрын
it's always the dimension of the space it's in, so in 3D it would be like a hemisphere, so you wouldn't be able to distinguish vertical from horizontal (without more math), but you would still be able to do the, "facing away" check
@skelhain
@skelhain Жыл бұрын
@@acegikmo Thank you for the clarification, Freya!
@VictorAlmeidaTroo
@VictorAlmeidaTroo 3 жыл бұрын
Thanks a lot !!
@form767
@form767 3 ай бұрын
damn, that a pro explanation 1m and I understood perfectly lol
@hyphendash5815
@hyphendash5815 4 жыл бұрын
Very simple.huge useful.
@denver1329
@denver1329 4 ай бұрын
wow this explained it really fast
@mekabare
@mekabare Жыл бұрын
now I understand how the hessian normal form works (you only normalize the normal vector in that one), thank you miss Freya!
@fosos_
@fosos_ 3 жыл бұрын
thiss was peerfect
@kepcukhusamettin9400
@kepcukhusamettin9400 Жыл бұрын
thanks
@rede_neural
@rede_neural Жыл бұрын
Only if the module of both vectors are 1... Cuz dot product is a product of 'the parallel part of b in respect to a' and a
@benzeltser9851
@benzeltser9851 Жыл бұрын
short n sweet good 4 students
@marisbaier6686
@marisbaier6686 3 жыл бұрын
great video! What about non-normalized vectors?
@mekabare
@mekabare Жыл бұрын
for anyone whos wondering: if you normalize one of them, you can calculate the length of the non normalized vector, because its basically checking "how often does it fit into the normalized vector (length 1) if you projected it?"
@richardbruno201
@richardbruno201 Жыл бұрын
This is the best explanation for it lol
@austecon6818
@austecon6818 9 ай бұрын
Nice
@magnusm4
@magnusm4 3 жыл бұрын
A dot product is taking two normalized vectors and taking the length from one's tip down to the other vector in a perpendicular direction to it. So basically it's a projected vector clamped to one?
@deyomash
@deyomash 2 жыл бұрын
the dot product is not a vector. It is a scalar. Its just the value of "how much of one vector is contained in the other"
@MathCuriousity
@MathCuriousity 7 ай бұрын
@@deyomash can I also say its "how much one vector opposes another" ?
@deyomash
@deyomash 7 ай бұрын
@@MathCuriousity The dot product between two vectors gives a value that resembles the 'overlap' between the two. If its zero they don't "overlap" at all, which means they are perpendicular. If the dot product is simply the length of one of the two this means they are parallel. Everything else lies in between :)
@colinmuller3067
@colinmuller3067 Жыл бұрын
i said to myself, "i know she'll explain this to me" and you did
@frankdearr2772
@frankdearr2772 3 жыл бұрын
a way that I love to use: to get projection: (vec1 * (1/sqrt(vec2 * vec2) * vec2) ) = scalar * (1/sqrt(vec2 * vec2) * vec2) ___ that works for 180 degree and you get it without use cos or sin, or 360 with some tricks the cos and sin are to move the blackdot and are not connected how we calculate the tangent line. www.geogebra.org/m/w3gnjwae (move B around the cercle ) a fast way to get tangent to a curve at any power : like for circle a projection of vP on unit vertical vector and we negate it . works for any value of x (power) www.geogebra.org/m/cpsbdbyv (move tx) the same in 3 D (partial derivative ....) www.geogebra.org/m/jsfkkbpu (move ty and tx) always with projection only a gradient color pick with small maths and code www.geogebra.org/m/fe4tyh2m bye and thanks for those videos :)) Lo
@ralusek
@ralusek Жыл бұрын
Isn't that similar to cosine then, if this is on a unit circle?
@acegikmo
@acegikmo Жыл бұрын
yeah! the dot product is often defined using the cosine
@ralusek
@ralusek Жыл бұрын
@@acegikmo much thanks
@gamersuji7745
@gamersuji7745 4 жыл бұрын
Really good explanation! Could you please tell me where this can be used at its best ? I've been asked at a lot of interviews about dot products but I've never really understood them enough to answer about it. Now that I do, thanks to you! It'd be really awesome to know where this dot product can be used.
@AaditDoshi
@AaditDoshi 4 жыл бұрын
In shaders, it can be used to tell if a normal is facing a light source or not. U can use the dot product to calculate how dark a pixel should be colored. In regular game world, a dot product can be used to tell if a player is looking at an object or not.
@izvarzone
@izvarzone 3 жыл бұрын
fresnel effect, moss on top of a stone (though it could be rotated differently if you add another vector), PBR shaders reflection of fringes (almost same thing as fresnel, really), or to generate trees and grass only on non-sloped surfaces.
@izvarzone
@izvarzone 3 жыл бұрын
also hit detection of railguns, rocket launchers, etc.
@MrWeebable
@MrWeebable 2 жыл бұрын
In procedural 3D modeling, I can use the dot product to determine whether part of a curve is pointing in the right direction. Or to check which parts of a polyline are near horizontal or vertical. It's more useful than calculating the angle because the dot product gives only 1 value instead of both an inner and outer angle.
@zorsat1
@zorsat1 3 жыл бұрын
enjoyablllle
@user-wb3wz3sx8z
@user-wb3wz3sx8z 3 жыл бұрын
thanks mama
@FaizanKhan-um6bn
@FaizanKhan-um6bn 2 жыл бұрын
Given a Vector A and Angle, between Vector B. How can we find the value of Vector B? Vector A = (0,0,1). Angle can be any.
@acegikmo
@acegikmo 2 жыл бұрын
it's an underdetermined problem, because we can't know the length of B or what direction B is deviating in from A (two solutions in 2D, infinite solutions in 3D) but, if you assume B has the same magnitude as A, and that the angle is signed rather than the shortest angle, it's a matter of rotating the vector A by the angle
@FaizanKhan-um6bn
@FaizanKhan-um6bn 2 жыл бұрын
@@acegikmo In my case, I have a Vector A which is basically Vector3.forward, (0,0,1). I have another Vector B which is used as Direction of Wind. So, for example, I want to change the direction of wind to a certain angle. I determine the angle by Vector3.Angle(VectorA,VectorB). It returns me the angle based on Value of B whatever I change. I want to turn Vector B in such a value that I get a desired Angle between the two. I suck at trignometry, so I am just not being able to visualize things, and hence cannot put it in code. I somehow managed to find some code within Unity something like this: vector2 = Quaternion.AngleAxis(targetAngle, new Vector3(0,1,0)) * Vector3.forward; I just saw this snippet and it worked. But I still am not able to comprehend it or how it works etc.
@spliter88
@spliter88 2 жыл бұрын
@@FaizanKhan-um6bn In 3D you need an axis to rotate around and if you want the result to be perpendicular to the original then that axis needs to be perpendicular to the original as well, so you're back to square one What you have here doesn't work in all cases, only in cases where the Y coordinate of the vector A is 0 (because in the equation the axis of rotation has Y coordinate 1). In fact it's impossibly to chose a vector that will work in all cases. One common trick that games use is to grab an arbitrary direction (eg: world up), then make a cross-product with the Vector A, then use the resulting vector (normalized ofc) as the axis of rotation ie: WorldUp = new Vector3(0,1,0); RotAxis = Vector3.Normalize(WorldUp x VecA); VecB = Quaternion.AngleAxis(targetAngle,RotAxis) * VecA; (we rotate VectorA around RotAxis by targetAngle radians) But be aware that this creates two singularities where RotAxis is undefined, when VecA and WorldUp are the same, or exact opposite. At those times the cross product will create a vector of 0 length.
@MathCuriousity
@MathCuriousity 7 ай бұрын
@@spliter88 Hey can you explain why people are saying her video is bad because she didn't normalize? what does normalize mean? Also can you explain like I'm five your video game analogy!
@spliter88
@spliter88 7 ай бұрын
@@MathCuriousity I havent seen the video in a long time so you'd have to be more specific what's their exact problem, but my guess is at some point in the video she's saying the dot product between two vectors is the cosine of the angle between them. Normalizing a vector just means turning it into a unit vector. So you just calculate its length and then divide that vector by the length. In the case of cosine, the dot product beyween two vectors is only the cosine of the angle between them if both vectors are unit vectors (ie: normalized) otherwise it'll be cosine times the length of vector A times the length of vector B
@walterh2113
@walterh2113 3 жыл бұрын
if I've more teachers like you in college
@giancarloprado8206
@giancarloprado8206 2 жыл бұрын
Thats trigonometry
@peoplearecool8766
@peoplearecool8766 2 жыл бұрын
Good explanation but just to mention, everything sad here is true under the assumption that those vectors are normalized which means their length is 1.
@Ryanisthere
@Ryanisthere 2 жыл бұрын
that feel when you invented cos(x)
@0xF81
@0xF81 10 ай бұрын
What about Z axis?
@edcify8241
@edcify8241 4 ай бұрын
The dot product works in any number of dimensions. Just like the Pythagorean theorem.
@0xF81
@0xF81 4 ай бұрын
@@edcify8241 aight, the video was about just 2D so I wasn't sure
@fraddi
@fraddi Жыл бұрын
may i ask, when did you transition from MtF ?
@RegenerationOfficial
@RegenerationOfficial Жыл бұрын
my fix was to normalize them...
@TheRealLifeSonicTheHedgehog
@TheRealLifeSonicTheHedgehog 4 ай бұрын
i think you meant to say parallel hehehehheheeeeeee
@kaiandkoarivera7025
@kaiandkoarivera7025 4 ай бұрын
Hi IRL sonic :D
@TheRealLifeSonicTheHedgehog
@TheRealLifeSonicTheHedgehog 4 ай бұрын
lmaooo@@kaiandkoarivera7025
@enyihou4553
@enyihou4553 Жыл бұрын
This is not quite accurate. In reality, u⋅v = magnitude of the projection of u unto v times the magnitude of v. she said that it is simply the magnitude of the projection of u unto v.
@enyihou4553
@enyihou4553 Жыл бұрын
by the way, since u⋅v = v⋅u, it also works if you think : magnitude of the projection of v unto u times the magnitude of u.
@zeez7777
@zeez7777 Жыл бұрын
yeah i was about to comment the same thing
@MathCuriousity
@MathCuriousity 7 ай бұрын
is this because her vectors were not "normalized" whatever that means!?
@enyihou4553
@enyihou4553 7 ай бұрын
@@MathCuriousity if she were to use normalized vectors, then she was right. because magnitude of v would be 1.
@yaoyunxu1642
@yaoyunxu1642 2 жыл бұрын
you are so beautiful , love you
@aleyummusic
@aleyummusic 3 жыл бұрын
You have sort of an Irish accent
@cannahacker9637
@cannahacker9637 3 жыл бұрын
search dot product game, get 1 minute 49 sec video....no regrets, thanks
@lx4302
@lx4302 2 жыл бұрын
im confused, but not at the topic
@lkledu2
@lkledu2 4 жыл бұрын
if I've more teachers like you in college
@ajarivas72
@ajarivas72 2 жыл бұрын
She is a great teacher
Dot Product Intuition | BetterExplained
8:01
Better Explained
Рет қаралды 118 М.
когда одна дома // EVA mash
00:51
EVA mash
Рет қаралды 13 МЛН
Trágico final :(
01:00
Juan De Dios Pantoja
Рет қаралды 29 МЛН
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 17 МЛН
Jurassic Park tour car - Tour Program
3:23
JP-06
Рет қаралды 36
Cross Product and Dot Product: Visual explanation
4:08
Physics Videos by Eugene Khutoryansky
Рет қаралды 943 М.
How to... Use Dot Product
5:30
Ryan Laley
Рет қаралды 16 М.
The real world applications of the dot product
12:49
Zach Star
Рет қаралды 211 М.
6.5: Vectors: Dot Product and Scalar Projection - The Nature of Code
15:23
The Beauty of Bézier Curves
24:26
Freya Holmér
Рет қаралды 1,9 МЛН
Work as the Dot Product
15:11
Flipping Physics
Рет қаралды 9 М.
The Vector Dot Product
6:59
Professor Dave Explains
Рет қаралды 776 М.
Trigonometry • Math for Game Devs [Part 3]
3:06:02
Freya Holmér
Рет қаралды 105 М.
Samsung or iPhone
0:19
rishton vines😇
Рет қаралды 7 МЛН
Я Создал Новый Айфон!
0:59
FLV
Рет қаралды 3,7 МЛН
🤖Вернулись в ПРОШЛОЕ🤪
0:28
Demin's Lounge
Рет қаралды 101 М.
3D printed Nintendo Switch Game Carousel
0:14
Bambu Lab
Рет қаралды 3,9 МЛН
IPad Pro fix screen
1:01
Tamar DB (mt)
Рет қаралды 3,3 МЛН