markus / KCOM / Extensions / VectorExtentions.cs @ 1c7f408a
이력 | 보기 | 이력해설 | 다운로드 (860 Bytes)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.Windows; |
7 |
|
8 |
namespace KCOM |
9 |
{ |
10 |
public static class VectorExtentions |
11 |
{ |
12 |
public static Point Rotate(this Point pt, double angle, Point center) |
13 |
{ |
14 |
Vector v = new Vector(pt.X - center.X, pt.Y - center.Y).Rotate(angle); |
15 |
return new Point(v.X + center.X, v.Y + center.Y); |
16 |
} |
17 |
|
18 |
public static Vector Rotate(this Vector v, double degrees) |
19 |
{ |
20 |
return v.RotateRadians(degrees * Math.PI / 180); |
21 |
} |
22 |
|
23 |
public static Vector RotateRadians(this Vector v, double radians) |
24 |
{ |
25 |
double ca = Math.Cos(radians); |
26 |
double sa = Math.Sin(radians); |
27 |
return new Vector(ca * v.X - sa * v.Y, sa * v.X + ca * v.Y); |
28 |
} |
29 |
} |
30 |
} |