• ### Popular Now

• 12
• 27
• 9
• 9
• 20

#### Archived

This topic is now archived and is closed to further replies.

# 2d vectors

This topic is 5921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok, for some reason I hit a total block in vectors. Is the correct way to find the dot product of 2 vectors: v1.x*v2.x + v1.y*v2.y and cross product v1.x*v2.x - v1.y*v2.y I just can''t remember...

##### Share on other sites

Note that the cross product produces a vector, but you've written your result as a scalar value. For vectors in the xy plane, the cross product produces a vector in the Z direction. For a purely 2D problem, you might not care to document that fact, but it can get you in the habit for doing 3D cross products at some point.

You can always derive the equation for a cross product, if you know how to calculate the determinant of a 3x3 matrix (which you may or may not). The equation for a cross product is determined by placing the two vectors as the 2nd and 3rd rows of a matrix. The first row is the row of directional unit vectors. "i" represents a unit vector in the x direction, "j" in the y direction, and "k" in the z direction. The cross product is the determinant of the matrix, shown below as:

  [ i j k ]V1 cross V2 = det | V1.x V1.y 0 | [ V2.x V2.y 0 ]

And the result is:

V1 cross V2 = k*(V1.x*V2.y - V1.y*V2.x)

  Or (V1.x*V2.y - V1.y*V2.x) in the Z direction.

If V1 and V2 are arbitrary 3D vectors, the cross product would be:

  [ i j k ]V1 cross V2 = det | V1.x V1.y V1.z | [ V2.x V2.y V2.z ]

I just added in the nonzero .z components in the last column. The result it:

  V1 cross V2 =+i*(V1.y*V2.z - V1.z*V2.y) +j*(V1.z*V2.x - V1.x*V2.z) +k*(V1.x*V2.y - V1.y*V2.x)

where the () after the "i" is the x component of the cross product vector, the () after the "j" is the y component of the vector, and the () after the "k" is the z component of the vector.

I always forget the exact equation for the cross product, and I use this handy method to derive the equation when I forget.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Edited by - grhodes_at_work on December 29, 2001 9:45:58 PM

##### Share on other sites
So would the cross product of a 2D vector be y*i-x*j And as long as I'm at it would a cross product in 4D take three vectors?

Edited by - LilBudyWizer on December 29, 2001 12:18:52 AM

##### Share on other sites
quote:
Original post by LilBudyWizer
So would the cross product of a 2D vector be y*i-x*j

Hey, hey! What an interesting observation! Yes, indeed, you are right! In a purely 2D space you can take the cross product of a single vector, given that the defining quality of the cross product is that it is orthogonal to all of the original vectors.

For those who didn''t see what you did, here is the equation LilBudyWizer used to find that cross product of a single vector in 2D space:

  2D cross product = det[i j] [x y]

Folks may be familiar with the fact that the negative reciprocal of the slope is the slope of a line normal to the original 2D line. That''s exactly what this 2D cross product produces, in convenient vector form.

But you cannot find the cross product of a single vector in 3D space, since there are an infinite number of vectors perpendicular to a single 3D vector.

quote:
Original post by LilBudyWizer
And as long as I''m at it would a cross product in 4D take three vectors?

Yes.

There are some excellent musings on this and other topics at:

www.insanemath.com

(Try the PDF version of "Cross Product in Finite Dimensional Euclidean Space.")

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.