liveBook · Manning

Inner product

As explained in Advanced Algorithms and Data Structures

The dot product is a scalar operation on vectors equal to the sum of the products of corresponding coordinates and related to their angle.

The inner product, or dot product, combines corresponding vector coordinates into a scalar. In planar geometry, it identifies perpendicular directions because a vector and its quarter-turn have dot product zero. section 15.4.1

For segment intersection, the inner product supports a vector-based calculation:

  • Construct u = (-v.y, v.x), a perpendicular vector to v. section 15.4.1
  • Use B + h·v = D + g·w to represent the same intersection point along both segments. section 15.4.1
  • Take dot products with u to eliminate h and solve for g; repeat symmetrically to obtain h. section 15.4.1
  • Accept an intersection when both scaling factors lie between zero and one, while handling shared-endpoint cases separately. section 15.4.1

Computing segment intersection

Given endpoints A, B, C, and D, calculate v = B − A, w = D − C, and u = (−v.y, v.x). The expression ((B − D)·u)/(w·u) yields one scaling factor; swapping the segments yields the other. section 15.4.1

Figure 15.19 A vector approach to check whether the point of intersection of the two lines falls within both segments

Use the vector diagram to connect the parameterized segment equation with the geometric location of the intersection point. section 15.4.1

How Advanced Algorithms and Data Structures covers it

How deep it goes
Develops perpendicular-vector construction, algebraic elimination, implementation, and endpoint handling without general inner-product theory.
Examples
Uses vectors between segment endpoints, a quarter-turned vector, scaling factors, and shared-endpoint cases.
What it assumes
Assumes coordinates, points, vectors, scalar multiplication, and cross products; constructs perpendicular vectors explicitly.
What you can do after
Apply vector arithmetic to compute segment parameters and diagnose whether two segments intersect.
How it connects
Connects vectors, perpendicularity, cross products, line intersection, and segment intersection.

Also explained in

Compare how 12 books explain inner product →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.