3D Math Primer for Graphics and Game Development

3D Math Primer for Graphics and Game Development By Fletcher Dunn and Ian Parberry

Download

Introduction

What is 3D Math?
This book is about 3D math, the study of the mathematics behind the geometry of a 3D world. 3D math is related to computational geometry, which deals with solving geometric problems algorithmically. 3D math and computational geometry have applications in a wide variety of fields that use computers to model or reason about the world in 3D, such as graphics, games, simulation, robotics, virtual reality, and cinematography. This book covers theory and practice in C++. The “theory” part is an explanation of the relationship between math and geometry in 3D. It also serves as a handy reference for techniques and equations. The “practice” part illustrates how these concepts can be applied in code. The programming language used is C++, but in principle, the theoretical techniques from this book can be applied in any programming language. This book is not just about computer graphics, simulation, or even computational geometry. However, if you plan to study those subjects, you will definitely need the information in this book
Why You Should Read This Book
If you want to learn about 3D math in order to program games or graphics, then this book is for you. There are many books out there that promise to teach you how to make a game or put cool pictures up on the screen, so why should you read this particular book? This book offers several unique advantages over other books about games or graphics programming:

+ A unique topic. This book fills a gap that has been left by other books on graphics, linear algebra, simulation, and programming. It is an introductory book, meaning we have focused our efforts on providing thorough coverage on fundamental 3D concepts — topics that are normally glossed over in a few quick pages or relegated to an appendix in other publications (because, after all, you already know all this stuff). Our book is definitely the book you should read first, before buying that “Write a 3D Video Game in 21 Days” book. This book is not only an introductory book, it is also a reference book — a “toolbox” of equations and techniques that you can browse through on a first reading and then revisit when the need for a specific tool arises.

+ A unique approach. We take a three-pronged approach to the subject matter: math, geometry, and code. The math part is the equations and numbers. This is where most books stop. Of course, the math is important, but to make it powerful, you have to have good intuition about how the math connects with the geometry. We will show you not just one but multiple ways to relate the numbers with the geometry on a variety of subjects, such as orientation in 3D, matrix multiplication, and quaternions. After the intuition comes the implementation; the code part is the practical part. We show real usable code that makes programming 3D math as easy as possible.
+ Unique authors. Our combined experience brings together academic authority with in-the-trenches practical advice. Fletcher Dunn has six years of professional game programming experience and several titles under his belt on a variety of gaming platforms. He is currently employed as the principal programmer at Terminal Reality and is the lead programmer on BloodRayne. Dr. Ian Parberry has 18 years of experience in research and teaching in academia. This is his sixth book, his third on game programming. He is currently a tenured full professor in the Department of Computer Sciences at the University of North Texas. He is nationally known as one of the pioneers of game programming in higher education and has been teaching game programming to undergraduates at the University of North Texas since 1993.

+ Unique pictures. You cannot learn about a subject like 3D by just reading text or looking at equations. You need pictures, and this book has plenty of them. Flipping through, you will notice that in many sections there is one on almost every page. In other words, we don’t just tell you something about 3D math, we show you. You’ll also notice that pictures often appear beside equations or code. Again, this is a result of our unique approach that combines mathematical theory, geometric intuition, and practical implementation.
+ Unique code. Unlike the code in some other books, the classes in this book are not designed to provide every possible operation you could ever want. They are designed to perform specific functions very well and to be easy to understand and difficult to misuse. Because of their simple and focused semantics, you can write a line of code and have it work the first time, without twiddling minus signs, swapping sines and cosines, transposing matrices, or otherwise employing “random engineering” until it looks right. Many other books exhibit a common class design flaw of providing every possible operation when only a few are actually useful.

+ A unique writing style. Our style is informal and entertaining, but formal and precise when clarity is important. Our goal is not to amuse you with unrelated anecdotes, but to engage you with interesting examples.

+ A unique web page. This book does not come with a CD. CDs are expensive and cannot be updated once they are released. Instead, we have created a companion web page, gamemath.com. There you will be able to experience interactive demos of some of the concepts that are the hardest to grasp from text and diagrams. You can also download the code (including any bug fixes!) and other useful utilities, find the answers to the exercises, and check out links to other sites concerning 3D math, graphics, and programming

What You Should Know Before Reading This Book

The theory part of this book assumes a prior knowledge of basic algebra and geometry, such as:

+ Manipulating algebraic expressions
+ Algebraic laws, such as the associative and distributive laws
+ Functions and variables
+ Basic 2D Euclidian geometry
In addition, some prior exposure to trigonometry is useful, but not required. A brief review of some key mathematical concepts is included in Appendix A. For the practice part, you need to understand some basics of programming in C++:

+ Program flow control constructs
+ Functions and parameters
+ Object-oriented programming and class design
No specific compiler or target platform is assumed. No “advanced” C++ language features are used. The few language features that you may be unfamiliar with, such as operator overloading and reference arguments, will be explained as they are needed.

Overview

Chapter 1 is the introduction, which you have almost finished reading. Hopefully, it has explained for whom this book is written and why we think you should read the rest of it.
Chapter 2 explains the Cartesian coordinate system in 2D and 3D and discusses how the Cartesian coordinate system is used to locate points in space.
Chapter 3 discusses examples of coordinate spaces and how they are nested in a hierarchy.
Chapter 4 introduces vectors and explains the geometric and mathematical interpretations of vectors.
Chapter 5 discusses mathematical operations on vectors and explains the geometric interpretation of each operation.
Chapter 6 provides a usable C++ 3D vector class.
Chapter 7 introduces matrices from a mathematical and geometric perspective and shows how matrices can be used to perform linear transformations.
Chapter 8 discusses different types of linear transformations and their corresponding matrices in detail.
Chapter 9 covers a few more interesting and useful properties of matrices.
Chapter 10 discusses different techniques for representing orientation and angular displacement in 3D.
Chapter 11 provides C++ classes for performing the math from Chapters 7 to 10.
Chapter 12 introduces a number of geometric primitives and discusses how to represent and manipulate them mathematically.
Chapter 13 presents an assortment of useful tests that can be performed on geometric primitives.
Chapter 14 discusses how to store and manipulate triangle meshes and presents a C++ class designed to hold triangle meshes.
Chapter 15 is a survey of computer graphics with special emphasis on key mathematical points.
Chapter 16 discusses a number of techniques for visibility determination, an important issue in computer graphics.
Chapter 17 reminds you to visit our web page and gives some suggestions for further reading.


Share This