The Dot Product - A Visual Explanation

Поділитися
Вставка
  • Опубліковано 4 сер 2019
  • 🔽 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
  • Наука та технологія

КОМЕНТАРІ • 128

  • @xniyana9956
    @xniyana9956 2 місяці тому +20

    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 20 днів тому

      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..

  • @mittensandsnowdrop
    @mittensandsnowdrop 3 роки тому +39

    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 роки тому +4

    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 роки тому +10

    In just over a minute you explained to where it finally made sense. Nice!!

  • @arcadiaplanatia8009
    @arcadiaplanatia8009 Рік тому +1

    This is actually such a good video. I've been struggling so long to understand this thank you so much!!

  • @MartynDerg
    @MartynDerg 7 місяців тому

    brilliant explanation, thank you so much for the simple illustration

  • @loot6
    @loot6 3 роки тому +14

    Far and away the best explanation I've come across. People normally try to make it sound complex but it's not.

  • @yurkkon6010
    @yurkkon6010 10 місяців тому +1

    made my day. happy to find your channel

  • @hypersapien
    @hypersapien 2 місяці тому

    Great video! I appreciate how concise this was!

  • @Zamaroht
    @Zamaroht 10 місяців тому

    Wow this explanation is crazy intuitive, thank you so much

  • @bigevilcorporation7050
    @bigevilcorporation7050 4 роки тому +10

    "Ugh this is doing my head in, I hope there's some Freya-like explanation on YouTu--" AND THERE IT IS

  • @whiteravenshow4342
    @whiteravenshow4342 3 роки тому +1

    Visual explanations are very cool and useful, thank you)

  • @SugarTouch
    @SugarTouch 2 роки тому +1

    Clear and sharp ! Thank you !

  • @chinedusamuel7950
    @chinedusamuel7950 4 роки тому +1

    Awesome explanations, made so simple. Thank u

  • @garethgriffiths7084
    @garethgriffiths7084 4 роки тому +1

    Thank you for sharing your explanation the of the Dot Product. Helped a lot =D

  • @b-bug923
    @b-bug923 9 місяців тому

    Thanks a lot🎉

  • @MaximumAxiom
    @MaximumAxiom 11 місяців тому

    Such a good explanation

  • @lemetamax
    @lemetamax 4 місяці тому

    This actually makes perfect sense! Now i perfectly understand how dot products work in my code

  • @rustemagayev8256
    @rustemagayev8256 2 роки тому +8

    As someone with chronic migraine, which makes thinking about and understanding complicated concept really hard, your explanations are a blessing.

  • @_brin189
    @_brin189 2 роки тому +3

    literal math mommy.
    thank you

  • @aleksandarv.1459
    @aleksandarv.1459 24 дні тому

    Keep up the good work!

  • @Mogo-jan
    @Mogo-jan 4 роки тому

    Ty so much for the visualization, i was having a hard time understanding from everyone's explainations

  • @levioptionallastname6749
    @levioptionallastname6749 Місяць тому

    just solved my problems in about 45 seconds thank you!

  • @RobertBerrier
    @RobertBerrier 6 місяців тому

    you are a live saver!

  • @jackleu8996
    @jackleu8996 2 роки тому +7

    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 6 місяців тому

      ​@@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 6 місяців тому

      @@redact7395 hmm ok and why did another person say it was only ok for normed?

    • @redact7395
      @redact7395 6 місяців тому

      ​@@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

  • @izvarzone
    @izvarzone 3 роки тому +32

    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 Рік тому +1

      only one must be normalized

    • @sterling709
      @sterling709 Рік тому +1

      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 6 місяців тому

      What does normalize mean

  • @jasoniswrongabouteverythin8230
    @jasoniswrongabouteverythin8230 5 місяців тому

    man, whenever im trying to understand some game dev math stuff i really should come to this channel first

  • @dmitriyborisov_hitsen
    @dmitriyborisov_hitsen Місяць тому

    Amazing!

  • @sinonimos1790
    @sinonimos1790 2 роки тому +1

    Muchas gracias. Gran Explicacion

  • @tempestandacomputer6951
    @tempestandacomputer6951 Рік тому

    Am a senior engineering student and never quite thought about it this way. Props!

  • @kimm9086
    @kimm9086 Рік тому

    ur vibe is so cool

  • @hk_labs
    @hk_labs 12 днів тому

    Thank you so much!

  • @randomaccount6146
    @randomaccount6146 Рік тому

    Finally someone explaining what the dot product even is instead of just jumping into how it is calculated.

  • @charlieliu3857
    @charlieliu3857 3 місяці тому

    Thank you for your video!!

  • @dartneer
    @dartneer 2 місяці тому

    Damn, i have seen hours long videos on dot product! When you know, you know! Thanks Freya..

  • @GokdenizCetin
    @GokdenizCetin Рік тому

    Thank you!

  • @thegreendude2086
    @thegreendude2086 Рік тому

    Very helpful, thanks a lot

  • @poki95
    @poki95 Рік тому

    Very helpful video!

  • @ninthjake
    @ninthjake 4 роки тому +42

    Really good explanation. Even a simpleton like myself understood it :)

    • @juxtapos1034
      @juxtapos1034 8 місяців тому

      some who says simpleton is not simple

  • @supertenchoo4271
    @supertenchoo4271 2 роки тому

    Best Teach for Game math

  • @brouxelian2744
    @brouxelian2744 3 роки тому

    short and usefull thank you !

  • @official_noself
    @official_noself 3 роки тому +3

    is it basically cosine of the angle in between two vectors

  • @novictim
    @novictim 2 роки тому

    Woah! Very useful

  • @Ofenkatze
    @Ofenkatze 9 місяців тому

    I wish I could tick a "love" emoji instead of just like. Most concise explanation I've found so far.

  • @harrynnebank8321
    @harrynnebank8321 4 роки тому +1

    if I've more teachers like you in college

  • @fosos_
    @fosos_ 3 роки тому

    thiss was peerfect

  • @VictorAlmeidaTroo
    @VictorAlmeidaTroo 3 роки тому

    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!

  • @hyphendash5815
    @hyphendash5815 4 роки тому

    Very simple.huge useful.

  • @richardbruno201
    @richardbruno201 Рік тому

    This is the best explanation for it lol

  • @form767
    @form767 3 місяці тому

    damn, that a pro explanation 1m and I understood perfectly lol

  • @benzeltser9851
    @benzeltser9851 Рік тому

    short n sweet good 4 students

  • @austecon6818
    @austecon6818 8 місяців тому

    Nice

  • @kepcukhusamettin9400
    @kepcukhusamettin9400 Рік тому

    thanks

  • @denver1329
    @denver1329 3 місяці тому

    wow this explained it really fast

  • @adeyemiadeyanju2247
    @adeyemiadeyanju2247 Рік тому +1

    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  Рік тому +1

      yes! but also, vectors technically don't "have an origin", they're always only the tip, in terms of the data stored

  • @marisbaier6686
    @marisbaier6686 3 роки тому +2

    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?"

  • @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

  • @zorsat1
    @zorsat1 3 роки тому

    enjoyablllle

  • @MathCuriousity
    @MathCuriousity 7 місяців тому +1

    @Freya what does "normalized" vector mean that she talks about in her description!?

    • @edcify8241
      @edcify8241 3 місяці тому

      A normalized vector has a unit "length", i. e. it's a vector divided by its norm equal to itself.

    • @MathCuriousity
      @MathCuriousity 3 місяці тому

      @@edcify8241what would that be as an equation?

    • @edcify8241
      @edcify8241 3 місяці тому

      @@MathCuriousity The normalization of a vector α is α'=α/||α|| (scalar multiplication by the reciprocal of its norm), and a vector is normalized iff α'=α.

  • @colinmuller3067
    @colinmuller3067 Рік тому

    i said to myself, "i know she'll explain this to me" and you did

  • @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!

  • @mekabare
    @mekabare Рік тому

    now I understand how the hessian normal form works (you only normalize the normal vector in that one), thank you miss Freya!

  • @frankdearr2772
    @frankdearr2772 3 роки тому +1

    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

  • @user-wb3wz3sx8z
    @user-wb3wz3sx8z 3 роки тому

    thanks mama

  • @magnusm4
    @magnusm4 3 роки тому +1

    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 :)

  • @ralusek
    @ralusek Рік тому

    Isn't that similar to cosine then, if this is on a unit circle?

    • @acegikmo
      @acegikmo  Рік тому +1

      yeah! the dot product is often defined using the cosine

    • @ralusek
      @ralusek Рік тому

      @@acegikmo much thanks

  • @walterh2113
    @walterh2113 3 роки тому +1

    if I've more teachers like you in college

  • @giancarloprado8206
    @giancarloprado8206 2 роки тому

    Thats trigonometry

  • @gamersuji7745
    @gamersuji7745 4 роки тому +1

    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 роки тому +3

      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 роки тому +2

      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 роки тому +4

      also hit detection of railguns, rocket launchers, etc.

    • @MrWeebable
      @MrWeebable 2 роки тому +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.

  • @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 роки тому +1

      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 роки тому +1

      @@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

  • @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.

  • @0xF81
    @0xF81 10 місяців тому

    What about Z axis?

    • @edcify8241
      @edcify8241 3 місяці тому

      The dot product works in any number of dimensions. Just like the Pythagorean theorem.

    • @0xF81
      @0xF81 3 місяці тому

      @@edcify8241 aight, the video was about just 2D so I wasn't sure

  • @Ryanisthere
    @Ryanisthere 2 роки тому

    that feel when you invented cos(x)

  • @RegenerationOfficial
    @RegenerationOfficial Рік тому

    my fix was to normalize them...

  • @TheRealLifeSonicTheHedgehog
    @TheRealLifeSonicTheHedgehog 3 місяці тому +1

    i think you meant to say parallel hehehehheheeeeeee

  • @enyihou4553
    @enyihou4553 Рік тому +1

    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 Рік тому +1

      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.

  • @fraddi
    @fraddi Рік тому

    may i ask, when did you transition from MtF ?

  • @lx4302
    @lx4302 2 роки тому +1

    im confused, but not at the topic

  • @yaoyunxu1642
    @yaoyunxu1642 2 роки тому

    you are so beautiful , love you

  • @cannahacker9637
    @cannahacker9637 3 роки тому

    search dot product game, get 1 minute 49 sec video....no regrets, thanks

  • @aleyummusic
    @aleyummusic 3 роки тому

    You have sort of an Irish accent

  • @lkledu2
    @lkledu2 4 роки тому +1

    if I've more teachers like you in college

    • @ajarivas72
      @ajarivas72 2 роки тому

      She is a great teacher