A box product is a determinant-based product of vectors. In N-dimensional space, it takes N vectors with N components and returns the determinant of the matrix they form. In two dimensions, it describes the signed area of the parallelogram spanned by two vectors: a positive or negative sign records orientation, while zero indicates degeneracy. section 9.5.2
For two-dimensional vectors, compute the product directly:
- box((a1, b1), (a2, b2)) = a1b2 − a2b1. section 9.5.2 section 9.5.3
- Use the sign to distinguish the vectors’ orientation and the magnitude to obtain parallelogram area. section 9.5.2
- In higher dimensions, build the vectors into a square matrix and take its determinant; symbolic expressions quickly become unwieldy. section 9.5.2 section 9.5.3
Signed distance to a line
A 2D box product turns directly into a signed distance calculation. For a point (x, y) and line endpoints (x1, y1), (x2, y2), compute box2d(x−x1, y−y1, x2−x1, y2−y1) and divide by the endpoint distance. The result is the parallelogram’s signed area divided by its base length. This construction supports point-to-line and point-to-segment distances, including signed distance functions for rectangles. section 10.1.4
def dot2d(x1, y1, x2, y2): #1
return x1*x2 + y1*y2 #1
def box2d(x1, y1, x2, y2): #2
return x1*y2 - x2*y1 #2
A compact Python implementation defines the 2D dot product alongside box2d(x1, y1, x2, y2) = x1*y2 − x2*y1. section 10.1.4
