Book Image

Mathematics for Game Programming and Computer Graphics

By : Penny de Byl
5 (1)
Book Image

Mathematics for Game Programming and Computer Graphics

5 (1)
By: Penny de Byl

Overview of this book

Mathematics is an essential skill when it comes to graphics and game development, particularly if you want to understand the generation of real-time computer graphics and the manipulation of objects and environments in a detailed way. Python, together with Pygame and PyOpenGL, provides you with the opportunity to explore these features under the hood, revealing how computers generate and manipulate 3D environments. Mathematics for Game Programming and Computer Graphics is an exhaustive guide to getting “back to the basics” of mathematics, using a series of problem-based, practical exercises to explore ideas around drawing graphic lines and shapes, applying vectors and vertices, constructing and rendering meshes, and working with vertex shaders. By leveraging Python, Pygame, and PyOpenGL, you’ll be able to create your own mathematics-based engine and API that will be used throughout to build applications. By the end of this graphics focussed book, you’ll have gained a thorough understanding of how essential mathematics is for creating, rendering, and manipulating 3D virtual environments and know the secrets behind today’s top graphics and game engines.
Table of Contents (26 chapters)
1
Part 1 – Essential Tools
9
Part 2 – Essential Trigonometry
14
Part 3 – Essential Transformations
20
Part 4 – Essential Rendering Techniques

Technical requirements

As mentioned in the introduction, we will be using the programming language, Python, along with an editor called PyCharm and a plugin/graphics library called Pygame. You should be a programmer to embark on the content of this course but not necessarily a Python programmer, as someone with working knowledge in any procedural language will pick up Python quickly enough.

These are all cross-platform tools and can be used on Windows, macOS, and Linux. We’ll leave it up to you to find the relevant versions of the software for your machine, however, to get you started, download Python from python.org. As shown in Figure 1.1, under the Downloads tab, you can get the latest version of the software. At the time of writing, it is Python 3.10.0. It is highly recommended that you follow along with the exercises in this book using the versions shown in the book to reduce any errors you may come across in replicating the code. If you are reading this and there is a later version of Python available, you can find version 3.10.0 under the All releases option as follows:

Figure 1.1: The Downloads tab at python.org

Figure 1.1: The Downloads tab at python.org

Thus, the steps to get Python installed on your machine are as follows:

  1. Visit python.org and download a version of Python relevant to your operating system.
  2. Run the downloaded file and follow the directions to install the software.

In order to code and compile with Python, we require an editor; for this, we will be using PyCharm. The same advice stands for version numbers of this software. At the time of writing this book, PyCharm is on version 2021.3. There is a Profession and a free Community version of PyCharm, but we will only require the free version for this book. To install PyCharm on your machine, do as follows:

  1. Visit www.jetbrains.com/PyCharm/download.
  2. Download a version of the installer relevant to your machine.
  3. Run the installer to set up PyCharm.

Now that you have the fundamental software installed, we will proceed to create a basic graphics window before learning how to draw on the screen.