I am implementing simple rotation but the object is not rotating around the local center instead it is rotating around world origin.
This is the code:
Matrix2D m = Matrix2D.Rotate((float) (Math.PI));
Point p = new Point(new Vector2D(-0.1f,0.7f),this, new PixelData(255, 255, 0, 0));
Point p2 = new Point(new Vector2D(0,0.8f),this, new PixelData(255, 255, 0, 0));
Point p3 = new Point(new Vector2D(0.1f,0.7f),this, new PixelData(255, 255, 0, 0));
Vector2D v = Matrix2D.MatrixTimesVector2D(m, p.getPosition());
Vector2D v2 = Matrix2D.MatrixTimesVector2D(m, p2.getPosition());
Vector2D v3 = Matrix2D.MatrixTimesVector2D(m, p3.getPosition());
Point z = new Point(v, this, p.getColour());
Point z2 = new Point(v2, this, p.getColour());
Point z3 = new Point(v3, this, p.getColour());
new Triangle(z2.Transform(), z.Transform(), z3.Transform(),this).DrawTriangle();
I checked my matrices and matrix multiplication is correct.
Result without rotation:
And after rotation:
Why i am getting this weird rotation ?