Chapter 4. 2D Primitive Shapes

Now that we have covered the necessary linear algebra, it is time to delve into some geometry. We are going to start with 2D primitive shapes. In this chapter, we are going to cover:

  • 2D points
  • 2D line segments
  • Circle
  • Rectangle
  • Oriented rectangle
  • Point containment tests
  • Line intersection tests

Introduction

Collisions play a large role in physics, determining if two objects touch is half the work. To determine if collisions are happening, we need to cover some basic geometry. In this chapter, we define what the geometry being used for collision tests will be and even implement some basic containment tests.

In this chapter we will implement primitive two-dimensional shapes. In the following chapters which follow we will combine ...

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.