# Dot Product Question

**URL:** <https://discourse.processing.org/t/dot-product-question/28351>\
**Category:** Beginners\
**Created:** [March 8, 2021, 6:31pm UTC](https://discourse.processing.org/t/dot-product-question/28351 "2021-03-08T18:31:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BigBigRed](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@BigBigRed](https://discourse.processing.org/u/BigBigRed)\
**Post date:** [March 8, 2021, 6:31pm UTC](https://discourse.processing.org/t/dot-product-question/28351/1 "2021-03-08T18:31:07Z")

</div>

I am trying to understand Dot Product and how to use it.  
I am trying to follow/re engineer a shader that I have found.  
(Acid Jelly from either Shadertoy or Shaderific, I think).  
The line of shader code is ‘uv /= dot(uv, uv);’.  
So I comment that line out and I can see that line of code is really making this shader do what it does.

I did a little grey/ one color study sketch in 2D and I see we get black at 0, 0 and it gradients to white as we right and/or down. So you pass a vector as parameter1 and the same vector as parameter2 and you get a changing result. I have not done heavy math in decades and this changing result has me struggling to understand. I have researched Dot Product in Wikipedia and other sites but still not clear at all.

If anyone has some enlightenment then I would appreciate it.

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [March 8, 2021, 9:30pm UTC](https://discourse.processing.org/t/dot-product-question/28351/2 "2021-03-08T21:30:18Z")

</div>

Say you have two vectors **a** and **b** each with **x** and **y** values. Your dot product is **a.x \* b.x + a.y \* b.y.**. So a self dot product of vector uv is **uv.x \* uv.x + uv.y \* uv.y**. Assuming ordinary dot calculation (not dot product of vectors representing imaginary numbers, which you may also encounter in shadertoy). So basically you are expecting scalar result.

---

<div class="post-metadata">

**Author:** ![BigBigRed](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@BigBigRed](https://discourse.processing.org/u/BigBigRed)\
**Post date:** [March 9, 2021, 3:06pm UTC](https://discourse.processing.org/t/dot-product-question/28351/3 "2021-03-09T15:06:05Z")

</div>

Thanks for your insight
