Processing math: 100%

Information

Deadline No deadline
Submission limit No limitation

Sign in

Geometry - Cross product

The cross product v×w of two vectors v and w can be seen as a measure of how perpendicular they are.

It is defined in 2D as:

v×w=vwsinθ

where v and w are the lengths of the vectors and θ is the amplitude of the oriented angle from v to w.

The cross product has a very simple expression in cartesian coordiantes. If v=(vx,vy) and w=(wx,wy) then

v×w=vxwyvywx
static double cross(Point v, Point w) {
    return v.x * w.y - v.y * w.x;
}

Geometric interpretation

The cross product v×w can be seen as a measure of how perpendicular the two vectors are.

The sign of the cross product indicates whether w is to the left or to the right of v.

  • v×w>0: w is to the left of v
  • v×w<0: w is to the right of v
  • v×w=0: w and v are aligned

geometry-cross/products2.png

In general, we take the angle between the vectors θ in ]π,π] so that the dot product is positive if 0<θ<π, negative if π<θ<0 and zero if θ=0 or θ=π:


geometry-cross/products3.png


Mark this section as read?