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
2x2 matrices
Started by squint, Feb 26 2011 12:14 AM
8 replies to this topic
#1
Posted 26 February 2011 - 12:14 AM
#2
Posted 26 February 2011 - 12:43 AM
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.
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.
reedbeta.com - developer blog, OpenGL demos, and other projects
#3
Posted 26 February 2011 - 12:59 AM
hehe
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.
#4
Posted 26 February 2011 - 02:56 AM
There are some other advantages as well such as being to interpolate between angles in the same way as 3D quaternions.
It's not what you know, it's what other people think you know.
Just hope you don't get quizzed on it.
Game engine design tutorials
Just hope you don't get quizzed on it.
Game engine design tutorials
#5
Posted 26 February 2011 - 01:01 PM
EricTheRed said:
There are some other advantages as well such as being to interpolate between angles in the same way as 3D quaternions.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.
-
Currently working on: the 3D engine for Tomb Raider.
#6
Posted 26 February 2011 - 03:02 PM
or, infact, just as hard - unless you all know something I don't I still need trig to interpolate a rotation matrix?
#7
Posted 27 February 2011 - 02:43 PM
The point in case was that you could interpolate like quaternions. To interpolate quaternions you also need trigonometric functions
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.
-
Currently working on: the 3D engine for Tomb Raider.
#8
Posted 27 February 2011 - 11:29 PM
Well, atleast the inverse operator is nice and fast :yes:
#9
Posted 28 February 2011 - 12:47 PM
Well, inverse operator for angle is nice and fast too.
Sorry my broken english!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












