# Essential Math WeblogThoughts on math for games

## 12/29/2004

### Errata: Figure 1.9

Filed under: Erratical — Jim @ 9:23 am

Reported by Richard Ruth: In Figure 1.9 on Page 26, the label on the hypotenuse should be $\sqrt{x^2 + y^2}$.

## 12/28/2004

### A New Beginning

Filed under: General — Jim @ 4:04 pm

Been a little busy lately trying to get a game out, but I did manage to squeeze in some time to create this new site using WordPress. It has some advantages in that I can display math and code a little easier, as you can see. I’m using MimeTeX for the math display — it’s got some issues with bold fonts, but otherwise I can enter the formulas I need in a LaTeX-like way without anyone needing to install MathML fonts. For the code, I’m using iG: Syntax Hiliter, with some tweaks to the colors.

Hopefully I’ll have some time in the next few weeks to type up some more errata, and what I and my co-lecturers are up to as we prep for GDC 2005.

## 6/29/2004

### Getting Axis and Angle from Rotation Matrix

Filed under: Erratical,Mathematical — Jim @ 11:36 am

There is a bug in the code that gets the axis and angle information from a rotation matrix. Where the angle is 180 degrees (the last else statement) it computes the reciprocal value incorrectly. The original code is:
[cpp]
float recip = 0.5f/s;
[/cpp]
The fixed code should be:
[cpp]
float recip = 1.0f/s;
[/cpp]
This should be corrected in both IvMatrix33 and IvMatrix44.

## 5/15/2004

### Correction: Quaternion Creation

Filed under: Erratical,Mathematical — Jim @ 8:37 pm

This is both a correction, and an improvement to the creation of a quaternion from two vectors. Or as it is commonly known, Shortest RotationArc.

The current code doesn’t handle the case where the two vectors are opposing; there’s an if statement to detect it, and a comment, but no recovery code. The problem is that there are an infinite number of orthogonal rotation axes — we just need to pick one. The solution is to check to see which axis the start vector (it could be the finish vector, it doesn’t matter) is generally pointing along. If it’s pointing generally along the $z$-axis, then we take the cross product with the $x$-axis to get our rotation axis. Otherwise we take the cross product with the $z$-axis.
(more…)

## 5/4/2004

### Correction: Quaternions

Filed under: Erratical,Mathematical — Jim @ 9:35 pm

Ah, our first errata. How bittersweet.

Eric Mumau sent me this one. On page 499, equation 10.11 is wrong. It should read:

$(2w^2-1)\mathbf{p}+2(\mathbf{v} \bullet \mathbf{p})\mathbf{v} + 2w(\mathbf{v} \times \mathbf{p})$

Correspondingly, the following equation should read:

$R_\mathbf{q}(\mathbf{p}) = (2 \cos^2 (\theta/2)-1)\mathbf{p} + 2(\hat{\mathbf{r}}\sin(\theta/2)\bullet\mathbf{p})\hat{\mathbf{r}}\sin(\theta/2) + 2\cos(\theta/2)(\hat{\mathbf{r}}\sin(\theta/2)\times\mathbf{p})$

The rest of the page follows as before.

This affects the code which starts at the bottom of page 499. At the top of 500, the first three lines should be rewritten as:
[cpp]
float vMult = 2.0f*(x*vector.x + y*vector.y + z*vector.z);
float crossMult = 2.0f*w;
float pMult = crossMult*w – 1.0f;
[/cpp]
Note that the code on the CD is not the same as that given in the text, and in fact will actually work. However, it is slightly less efficient than what is given here.

## 4/30/2004

### Post GDC musings

Filed under: General — Jim @ 9:21 pm

So it’s been about a month and a half since GDC. Our book was a success, selling out the show floor completely. The course seemed to go over well, too. Despite my complete loss of voice (after the talk it was actually gone for a whole day), folks seemed to like it, giving us the best ratings I’ve seen since I started doing the thing five years ago. So after the celebratory martinis and steak, now what?

Well, this blog is part of that. What we’d like to do is keep learning and writing about these topics, and expanding on both the book and the course. So we might post about we’re currently working on, or maybe expand on a topic we covered in the course or the book. We hope you’ll enjoy it.