각도계(Degree) 를 호도법(Radian) 으로
public static Double DegreeToRadian(Double deg) {
return deg * (Math.PI / 180);
}
II. 호도법(Radian) 을 각도계(Degree) 로
public static Double RadianToDegree(Double rad) {
return rad * (180 / Math.PI);
}
III. 두 점 사이의 거리 구하기
public static Double GetDistance(PointF p1, PointF p2) {
Double xdf = p2.X - p1.X;
Double ydf = p2.Y - p1.Y;
return Math.Sqrt(Math.Pow(xdf, 2) + Math.Pow(ydf, 2));
}
IV. 두 점간의 각도 구하기
public static Double GetAngle(PointF p1, PointF p2) {
Double xdf = p2.X - p1.X;
Double ydf = p2.Y - p1.Y;
Double ang = RadianToDegree(Math.Atan2(ydf, xdf));
return ang + 90;
}
V. 각도의 방향 구하기
public static PointF GetDirection(Double deg) {
return new PointF(-(Single)Math.Sin(DegreeToRadian(deg)),
(Single) Math.Cos(DegreeToRadian(deg)));
}
출처: http://slaner.tistory.com/109 [꿈꾸는 프로그래머]
'Programing > C#' 카테고리의 다른 글
C# 콘트롤 동적생성및 이벤트 공유 (0) | 2017.02.15 |
---|---|
먼곳의 물체의 각도 구하기,ATan2,ATan (0) | 2017.02.15 |
c# 프로그래밍-키값 알아내기,KeyDown,KeyCode,Keys (0) | 2017.02.14 |
c# 프로그래밍,마우스 클릭좌표 알아내기,mouse position,location,e.X ,e.Y (0) | 2017.02.12 |
c# , 다른 form 보이게 하고 데이타 전달,from data,show,폼이동 (0) | 2017.02.10 |