cross.js 402 B

1234567
  1. // Returns the 2D cross product of AB and AC vectors, i.e., the z-component of
  2. // the 3D cross product in a quadrant I Cartesian coordinate system (+x is
  3. // right, +y is up). Returns a positive value if ABC is counter-clockwise,
  4. // negative if clockwise, and zero if the points are collinear.
  5. export default function(a, b, c) {
  6. return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
  7. }