//--------------------------------------------------------
//最適化された行列同士の掛け算
//--------------------------------------------------------
void mulTranslate(float x, float y) {
// |_11 _12 _13| |1 0 x| |_11 _12 _11x+_12y+_13|
// |_21 _22 _23| × |0 1 y| = |_21 _22 _21x+_22y+_23|
// | 0 0 1| |0 0 1| | 0 0 1|
_13 += _11 * x + _12 * y;
_23 += _21 * x + _22 * y;
}
void mulScaling(float x, float y) {
// |_11 _12 _13| |x 0 0| |_11x _12y _13|
// |_21 _22 _23| × |0 y 0| = |_21x _22y _23|
// | 0 0 1| |0 0 1| | 0 0 1|
_11 *= x; _12 *= y;
_21 *= x; _22 *= y;
}
void mulRotate(float angle) {
// |_11 _12 _13| |c -s 0| |_11c+_12s _11(-s)+_12c _13|
// |_21 _22 _23| × |s c 0| = |_21c+_22s _21(-s)+_22c _23|
// | 0 0 1| |0 0 1| | 0 0 1|
float c = cos(angle);
float s = sin(angle);
float tmp;
//1行目
tmp = _11 * c + _12 * s;
_12 = _11 * -s + _12 * c;
_11 = tmp;
//2行目
tmp = _21 * c + _22 * s;
_22 = _21 * -s + _22 * c;
_21 = tmp;
}