Exemple #1
0
void sh_rect::rotate(float angle) {
    angle *= torad;
    mat2x2 rot = mat2x2( cos(angle), -sin(angle),
                         sin(angle), cos(angle) );

    vec2 cur_cen = _center;

    move_position(-_center.x, -_center.y);


    _position = _position*rot;
    for(int i = 0; i < 6; i++) {
        data[i] = data[i]*rot;
    }

    move_position(cur_cen);

    _left = (_position.x - _width/2.0f);
    _right = (_position.x + _width/2.0f);
    _top = (_position.y + _height/2.0f);
    _bottom = (_position.y - _height/2.0f);

    // _rotation = _rotation*rot;

    glBindBuffer(GL_ARRAY_BUFFER, _vbo);
    glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(data), data);
}
Exemple #2
0
mat2x2 inline operator*(mat2x2 &l, mat2x2 &r) {
	return mat2x2((l.a*r.a%mod+l.b*r.c%mod)%mod, (l.a*r.b%mod+l.b*r.d%mod)%mod,
				  (l.a*r.c%mod+l.c*r.d%mod)%mod, (l.c*r.b%mod+l.d*r.d%mod)%mod);
}