Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello there, I have a small project about creating vector shapes and manipulating with them. I stuck at creating a rotation tool. Can someone throw a quick eye at it and give me a hint how to deal with that ?
Posted
Updated 18-Oct-15 22:31pm
v2
Comments
Style-7 19-Oct-15 4:39am    
set a center point and rotate coordinates x y by sin and cos functions
elGp 19-Oct-15 10:30am    
I do something wrong

<pre lang="c#">public void RotateTo(PointF p)
{
if (selection != null)
{

PointF c = new PointF(Selection.Rectangle.X + Selection.Rectangle.Width / 2, Selection.Rectangle.Y + Selection.Rectangle.Height / 2);


double x =c.X;
double y = c.Y;

double tempX = x * Math.Cos(90) - y * Math.Sin(90);
double tempY = y * Math.Sin(90)+ x * Math.Cos(90);
x =(float) tempX;
y =(float) tempY;
selection.Location = new PointF(c.X+(float)x-lastLocation.X, c.Y+(float)y-lastLocation.Y);
lastLocation = selection.Location;
}
}</pre>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900