Math in Unity : Dot Product (Part I)

The Dot Product is the sum of the multiplication of the components of a Vector.

The small square between the v and the w is the mathematical symbol of the Dot

d = vx * wx + vy * wy
d = 3 * 2 + 9 * 7
d = 62

An important thing to know is that even if we are doing calculations between Vectors, the result, that is the Dot Product, IS NOT A VECTOR BUT A REAL NUMBER.

that number represents THE ANGLE between the two Vectors.

This is the rule :
If the Dot Product is > 0, the angle is < 90°
If the Dot Product = 0, the angle is perfectly at 90°
if the Dot Product < 0, the angle is > 90°

The second formula, which is the one we will implement directly to calculate the angle, translated into slightly more understandable words is:

The angle = inverse cosine of the Dot Product divided by the length of the two Vectors.

--

--

--

Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Virtual networking labs — NAT and host-only networking with VirtualBox

2.5D Game Development In Unity: Physics Based Character Controller Part 2: Jumping

Successful Interoperability Test between IPLOOK 5GC and AsiaInfo International CHF

IPLOOK and AsiaInfo partner to deliver an end-to-end 5G solution for the Telecom Industry.

Compact Siri…Top 10 iOS 14 features Every iPhone and iPad users must know….(Part 2)

READ/DOWNLOAD%# The Filmmaker’s Eye: Learning (and Breaking) the Rules of Cinematic Composition…

A recurring pair-programming meeting

What’s the UAPx invasion?

Quick Start Elasticsearch with Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matteo Lo Piccolo

Matteo Lo Piccolo

Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!

More from Medium

Unity : use Raycast for move the Player

Scripting our greybox prototype

2.5D Platformer — #13 Rolling

Spawn Manager — Part 2