2D lines

A line is the shortest straight path that connects two points. A line can be defined by a point on the line and a slope; this is called the slope intercept form. An actual line has no ends; it extends infinitely in both directions. This is not what we intuitively think of as a line. Instead, we want to define a line using a Start Point and an End Point. This is called a Line Segment:

2D lines

Getting ready

Even though we are implementing a line segment, in code we are going to refer to it as a line. We rarely, if ever, use real lines to detect collisions, but we often use line segments. The Line2D structure we are about to create will consist of two ...

Get Game Physics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.