I'm making program to draw some lines by using x y coordinates to image in picturebox. The image will be adjustable so can be resized or rotated but I want the drawn lines to follow the image along not staying on the picturebox coordinates. When zoomed in or out the lines still following the images but when rotated it jumps randomly not following the image.
Default program with 3 lines drawn
Zoomed image with lines still in place
Rotated image by 10 degrees. the lines jumps to random location.
I'm currently using this one with 2 coordinates to form a line but it makes the coordinates jumping everywhere randomly not rotated along with the image. this is the code for the black line 1.
---Edit---
this is the code to rotate clockwise but somehow it moves counter clockwise. the angle2 value is still unknown and that 32 is the closest position possible by trying one by one with rotating it counter clockwise. the coordinate didnt jump as random as before now it rotates along with the pic but the rotated location is still incorrect. after rotate it 360 degrees the coordinate location is slightly moved from original. and every rotation goes counter clockwise.
Original before rotating with 32 value in angle 2
float x = (float)bmp.Width / 2;
float y = (float)bmp.Height / 2;
ang = ang + 10;
double ang2 = 32;
double newLine1X1 = (line1X1 - x) * Math.Cos(ang2 /180) + (line1Y1 - y) * Math.Sin(ang2 /180) + x;
double newLine1Y1 = -(line1X1 - x) * Math.Sin(ang2 /180) + (line1Y1 - y) * Math.Cos(ang2 /180) + y;
double newLine1X2 = (line1X2 - x) * Math.Cos(ang2 /180) + (line1Y2 - y) * Math.Sin(ang2 /180) + x;
double newLine1Y2 = -(line1X2 - x) * Math.Sin(ang2 /180) + (line1Y2 - y) * Math.Cos(ang2 /180) + y;
line1X1 = (int)newLine1X1;
line1Y1 = (int)newLine1Y1;
line1X2 = (int)newLine1X2;
line1Y2 = (int)newLine1Y2;
Clockwise Rotation Code
float x = (float)bmp.Width / 2;
float y = (float)bmp.Height / 2;
ang = ang - 10;
double ang2 = -32;
double newLine1X1 = (line1X1 - x) * Math.Cos(ang2 /180) - (line1Y1 - y) * Math.Sin(ang2 /180) + x;
double newLine1Y1 = (line1X1 - x) * Math.Sin(ang2 /180) + (line1Y1 - y) * Math.Cos(ang2 /180) + y;
double newLine1X2 = (line1X2 - x) * Math.Cos(ang2 /180) - (line1Y2 - y) * Math.Sin(ang2 /180) + x;
double newLine1Y2 = (line1X2 - x) * Math.Sin(ang2 /180) + (line1Y2 - y) * Math.Cos(ang2 /180) + y;
line1X1 = (int)newLine1X1;
line1Y1 = (int)newLine1Y1;
line1X2 = (int)newLine1X2;
line1Y2 = (int)newLine1Y2;
Counter Clockwise Rotation Code
can anyone tell me how to fix this rotation error? Thank you very much.