Rotational Movement with Rectangles

Hey,

So I'm currently having an issue to rotate my paddle in my pinball game and was wondering if i could get some assistance on how to do this. I understand to rotate clockwise you use this formula.
1
2
(X') = (cos(angle), -sin(angle)) (x)
(Y') = (sin(angle), cos(angle)) (y)


Here is the relevant code
Rectangle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef _RECTANGLE_H
#define _RECTANGLE_H

#include<Physics\obb.h>

class Rectangle : public OBB
{
	public:
		Rectangle();
		Rectangle(float width, float height, math::Vector2D pos, float rotation);

		virtual float getArea();
		
	protected:
};
#endif // !_RECTANGLE_H 


Rectangle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Rectangle::Rectangle()
{

}

Rectangle::Rectangle(float width, float height, math::Vector2D pos, float rotation) : OBB(width, height, pos, rotation)
{
	m_centrePoints = pos;
	m_halfExtents = math::Vector2D(width, height);
	setOrientation(rotation);
}

float Rectangle::getArea()
{
	m_shapeArea = m_halfExtents.getX() * m_halfExtents.getY();
	return m_shapeArea;
}


paddle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef _PADDLE_H
#define _PADDLE_H

#include<SFML\Graphics.hpp>
#include<Graphics\rectangle.h>

class Paddle : public Rectangle, public sf::Drawable
{
	public:
		Paddle();
		Paddle(float width, float height, math::Vector2D pos, float rotation);

		void updateMovable(float time);
		void rotatePaddle(float angle);
		void draw(sf::RenderTarget &target, sf::RenderStates states) const;

	private:
		sf::RectangleShape drawObject;
};
#endif // !_PADDLE_H 

And this is my function in paddle.cpp
1
2
3
4
void Paddle::rotatePaddle(float angle)
{
	
}


I've watched a bunch of rotation tutorials however when i applied rotation onto my paddle object it just ends up being in a completely different area in the game window.

Much appropriated for any help i receive and a thanks in advance.
Note that rotating a point P my multiplying it by a matrix M will rotate P around the origin. To rotate it around some point P0 (e.g. the center of a rectangle), you need to do M(P - P0) + P0.
Thank you helios, this helped a lot.
Topic archived. No new replies allowed.