Dot Product, I need some help

Please do not explain me how to calculate the Dot product. I was pretty good at school with it but when it comes to using it in programming I am a bit confused.

I have watched this video and the guy explain me the dot product:

The question I want ask you, and I have never asked my teacher is: If I can use the Dot product in 3D too without adding the z component or do I have to add a z component? sorry my intuition tells me I am asking a stupid question because the dot product gets the angle between two Vectors, so I should I have to use the third component or?

this means (again sorry I am so confused)

local function Dotproduct(vA, vB, vC)
	return vA.X*vB.X*vC.X + vA.Y*vB.Y*vC.Y + vA.Z *vB.Z*vC.Z
end

There’s a built-in way to do this, not sure if you were aware but Vector3 has a Dot (member function) which gets the dot product of two Vector3s.

Okey but instead of using the member function is it right how I did?

a = (a1, a2, a3)
b = (b1, b2, b3)

a1 * b1 + a2 * b2 + a3 * b3

The dot product can be used in any dimensions. Two dimensions, three dimensions, four dimensions, etc. I don’t think it makes sense to compute the dot product of three vectors, though.

1 Like

check the api reference
https://developer.roblox.com/en-us/api-reference/datatype/Vector3
image

I didn’t even know cross and dot product were a built in thing in roblox, that’s great

1 Like