Reader small image

You're reading from  Game Physics Cookbook

Product typeBook
Published inMar 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781787123663
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Gabor Szauer
Gabor Szauer
author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer

Right arrow

Circle to oriented rectangle


Testing if a point intersects an oriented rectangle involves moving the point into the local space of the oriented rectangle. Once in the oriented rectangle's local space, we treated the oriented rectangle as a non-oriented rectangle. Testing for intersection between a circle and an oriented rectangle works the same way. We move both the circle and oriented rectangle into the rectangle's local space, then perform a circle rectangle intersection test:

Getting ready

We are going to implement a test to see if a circle and oriented rectangle are intersecting. For the sake of convenience, we are also creating a #define macro as an alias for the function. The code to move the circle into the local space of the oriented rectangle should look familiar by now.

How to do it…

Follow these steps to implement a function which tests for intersection between a circle and an oriented rectangle:

  1. Declare the circle oriented rectangle test in Geometry2D.h, also create an alias for this...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Game Physics Cookbook
Published in: Mar 2017Publisher: PacktISBN-13: 9781787123663

Author (1)

author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer