From wikipedia:
the cross product is a binary operation on two vectors in a three-dimensional Euclidean space that results in another vector which is perpendicular to the plane containing the two input vectors.
Given that the definition requires at least three dimensions, how does one calculate the cross product of two 2d vectors?
I have seen two implementations. One returns a new vector (but only accepts a single vector), the other returns a scalar (but is a calculation between two vectors).
Implementation 1 (returns a scalar):
float CrossProduct(const Vector2D & v1, const Vector2D & v2) const
{
return (v1.X*v2.Y) - (v1.Y*v2.X);
}
Implementation 2 (returns a vector):
Vector2D CrossProduct(const Vector2D & v) const
{
return Vector2D(v.Y, -v.X);
}
Why the varying implementations? What would I use the scalar implementation for? What would I use the vector implementation for?
The reason I ask is because I'm writing a Vector2D class myself and don't know which method to use.