v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Sifteo::AffineMatrix Struct Reference

An augmented 3x2 matrix, for doing 2D affine transforms. More...

#include <sifteo/math.h>

Public Member Functions

 AffineMatrix ()
 Create an uninitialized matrix.
 
 AffineMatrix (float _xx, float _yx, float _cx, float _xy, float _yy, float _cy)
 Create a matrix from six scalar values.
 
void operator*= (const AffineMatrix &m)
 Matrix multiplication.
 
void rotate (float angle)
 Compose this matrix with a rotation by 'angle' radians.
 
void scale (float s)
 Compose this matrix with a scale by factor 's'.
 
void translate (float x, float y)
 Compose this matrix with a translation by (x, y)
 
void translate (Float2 v)
 Compose this matrix with a translation by vector 'v'.
 

Static Public Member Functions

static AffineMatrix identity ()
 Create the identity matrix.
 
static AffineMatrix rotation (float angle)
 Create a matrix which rotates by 'angle' radians.
 
static AffineMatrix scaling (float s)
 Create a matrix which scales by a factor of 's'.
 
static AffineMatrix translation (float x, float y)
 Create a matrix which translates by (x, y)
 
static AffineMatrix translation (Float2 v)
 Create a matrix which translates by vector 'v'.
 

Public Attributes

float cx
 Matrix member cx, the constant offset for X.
 
float cy
 Matrix member cy, the constant offset for Y.
 
float xx
 Matrix member xx, the horizontal X delta.
 
float xy
 Matrix member xy, the horizontal Y delta.
 
float yx
 Matrix member yx, the vertical X delta.
 
float yy
 Matrix member yy, the vertical Y delta.
 

Detailed Description

An augmented 3x2 matrix, for doing 2D affine transforms.

[ xx yx cx ] [ xy yy cy ] [ 0 0 1 ]

The way we use affine transforms for background scaling are very similiar to the mechanism used by the GameBoy Advance PPU. There's a great tutorial on this at:

http://www.coranac.com/tonc/text/affine.htm


The documentation for this struct was generated from the following file: