The Dot product can also be calculated by (the asterisk should be a dot):
.
Or for a nth dimensional vector space:
.
Hope this helps, and what language is the code by the way. I've only programed in ADA
I'm having trouble understanding how this code calculates the dot product which I understand as |A||B|cos Ɵ
Multiplying the cordinates together seems too easy
/**
* Calculates the dot product of this vector and another given vector.
* @param v2 Another Vector2D instance.
* @return Number The dot product of this vector and the one passed in as a parameter.
*/
public function dotProd(v2:Vector2D):Number
{
return _x * v2.x + _y * v2.y;
}
That doesn't seem the same as
Calculating the Dot Product In 2D
Define your two vectors. Vector1 (x1, y1) and Vector2 (x2, y2).
DotProduct = (x1*x2 + y1*y2)
from
Dot Product