0
101 Feb 26, 2011 at 00:14

A 2D matrix that contains only a rotation cannot have a form other than (cos(a), sin(a), -sin(a), cos(a)) and that means I should only be storing 2 numbers - the other two are implicit. Not only does that improve my chances of hitting the cache with complex data objects, it means there are two less places for rounding errors to mess everything up. So, my 2D physics engine will now be storing orientations as two floats instead of four.

Is this:
a) Neat
b) Old hat
c) Wrong

#### 8 Replies

Please log in or register to post a reply.

0
165 Feb 26, 2011 at 00:43

Well, for 2D, you could do it with a single number - the angle. :)

But if you want to avoid trigonometric functions, it’s certainly possible to do it by storing only the first row of the matrix, reconstructing the second row on demand. This is sort of the 2D analogue of using quaternions instead of 3x3 rotation matrices. In fact, the first row of a 2D rotation matrix could be thought of as real and imaginary parts of a normalized complex number, which represents rotation in 2D in the same way that quaternions represent rotation in 3D.

0
104 Feb 26, 2011 at 00:59

hehe

0
101 Feb 26, 2011 at 02:56

There are some other advantages as well such as being to interpolate between angles in the same way as 3D quaternions.

0
101 Feb 26, 2011 at 13:01

@EricTheRed

There are some other advantages as well such as being to interpolate between angles in the same way as 3D quaternions.

Actually, there is no advantage. If you know your matrix is orthonormal (ie., only contains a rotation), it’s just as easy to interpolate angles as with only storing the first row.

0
101 Feb 26, 2011 at 15:02

or, infact, just as hard - unless you all know something I don’t I still need trig to interpolate a rotation matrix?

0
101 Feb 27, 2011 at 14:43

The point in case was that you could interpolate like quaternions. To interpolate quaternions you also need trigonometric functions :)

0
101 Feb 27, 2011 at 23:29

Well, atleast the inverse operator is nice and fast :yes:

0
101 Feb 28, 2011 at 12:47

Well, inverse operator for angle is nice and fast too.