What is the purpose of getting the dot product between 2 Vector3s? For example:
Vector3.new(1, 3, 5):Dot(Vector3.new(-1, 1, 3)
Not that I know that it multiplies the components of the two vectors but I don’t understand what the purpose of it is…
What is the purpose of getting the dot product between 2 Vector3s? For example:
Vector3.new(1, 3, 5):Dot(Vector3.new(-1, 1, 3)
Not that I know that it multiplies the components of the two vectors but I don’t understand what the purpose of it is…
The main reason you will ever use in on Roblox is (most likely) to calculate the angle between two vectors.
The dot product is essentially one of the core ways for us to interpret multiplication in space.
Spaces are inhabited by vectors that get to do interesting things thanks to interactions with scalars - because scalars are ordinary numbers, their multiplication is uninteresting. Multiplying two vectors however gives us two possibilities - do we want the result to be a vector or a scalar? The latter is answered by the dot product.
The dot product is basically a measure for two vectors ‘mutuality’ or how much they complement one another. When two vectors point along each other, the result is maximized - when they point at right angles apart, the product is 0 (because perpendicular entities have no sense of mutuality). We can use the dot product to determine neat things like projections, work done, or even deduce the angle between two vectors.
x and y are vectors, the dot inbetween means dot product of them.
The dot between the x and y does not mean multiply x and y. It means the dot product of x and y.
You can rearrange that equation you gave to find a formula for the dot product. E.g. the formula below calculates the dot product of two vectors a
and b
.
I’m pretty certain this formula is less commonly used in computers though due to the magnitude operator not being very performant. An alternative formula is to just multiply the two vectors, and then add them.
This is a fantastic video by EgoMoose that explains the dot product really well, I would highly recommend watching it.
What do the lines going vertical on either side of a number or variable mean?
The lines surrounding them indicate that you want the magnitude of the vector - |a| is the size or length of a.
If a = <x, y, z>, then |a| = √(x²+y²+z²) under the Pythagorean Theorem.